perf(cpus): inline the cpu_get_rev_var call

Similar to the cpu_rev_var_xy functions, branching far away so early in
the reset sequence incurs significant slowdowns. Inline the function.

Change-Id: Ifc349015902cd803e11a1946208141bfe7606b89
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
This commit is contained in:
Boyan Karatotev 2024-12-04 15:25:27 +00:00
parent 7791ce21a6
commit 36eeb59f9e
2 changed files with 26 additions and 18 deletions

View file

@ -440,6 +440,29 @@
msr \_reg, x0
.endm
/*
* Extract CPU revision and variant, and combine them into a single numeric for
* easier comparison.
*
* _res:
* register where the result will be placed
* _tmp:
* register to clobber for temporaries
*/
.macro get_rev_var _res:req, _tmp:req
mrs \_tmp, midr_el1
/*
* Extract the variant[23:20] and revision[3:0] from MIDR, and pack them
* as variant[7:4] and revision[3:0] of x0.
*
* First extract x1[23:16] to x0[7:0] and zero fill the rest. Then
* extract x1[3:0] into x0[3:0] retaining other bits.
*/
ubfx \_res, \_tmp, #(MIDR_VAR_SHIFT - MIDR_REV_BITS), #(MIDR_REV_BITS + MIDR_VAR_BITS)
bfxil \_res, \_tmp, #MIDR_REV_SHIFT, #MIDR_REV_BITS
.endm
/*
* Apply erratum
*
@ -560,7 +583,7 @@
/*
* provide a shorthand for the name format for annoying errata
* body: clobber x0 to x3
* body: clobber x0 to x4
*/
.macro check_erratum_custom_start _cpu:req, _cve:req, _id:req
func check_erratum_\_cpu\()_\_id
@ -588,8 +611,7 @@
.macro cpu_reset_func_start _cpu:req
func \_cpu\()_reset_func
mov x15, x30
bl cpu_get_rev_var
mov x14, x0
get_rev_var x14, x0
/* short circuit the location to avoid searching the list */
adrp x12, \_cpu\()_errata_list_start

View file

@ -216,23 +216,9 @@ error_exit:
ret
endfunc get_cpu_ops_ptr
/*
* Extract CPU revision and variant, and combine them into a single numeric for
* easier comparison.
*/
.globl cpu_get_rev_var
func cpu_get_rev_var
mrs x1, midr_el1
/*
* Extract the variant[23:20] and revision[3:0] from MIDR, and pack them
* as variant[7:4] and revision[3:0] of x0.
*
* First extract x1[23:16] to x0[7:0] and zero fill the rest. Then
* extract x1[3:0] into x0[3:0] retaining other bits.
*/
ubfx x0, x1, #(MIDR_VAR_SHIFT - MIDR_REV_BITS), #(MIDR_REV_BITS + MIDR_VAR_BITS)
bfxil x0, x1, #MIDR_REV_SHIFT, #MIDR_REV_BITS
get_rev_var x0, x1
ret
endfunc cpu_get_rev_var