powernv/idle: Power9 idle cleanup
v4 cover powernv/idle: Power9 idle cleanup
v3: https://lkml.org/lkml/2020/7/17/1093
Changelog v3-->v4:
Based on comments from Nicholas Piggin and Gautham Shenoy,
1. Changed the naming of pnv_first_spr_loss_level from pnv_first_fullstate_loss_level to deep_spr_loss_state
2. Make the P9 PVR check only on the top level function pnv_probe_idle_states and let the rest of the checks be DT based because it is faster to do so
Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Replace CPU features check with PVR check powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above
arch/powerpc/platforms/powernv/idle.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Signature · 1 line
2.25.4
PATCH v4 1/3 powerpc/powernv/idle: Replace CPU features check with PVR check
As the idle framework's architecture is incomplete, hence instead of checking for just the processor type advertised in the device tree CPU features; check for the Processor Version Register (PVR) so that finer granularity can be leveraged while making processor checks.
Hence, making the PVR check on the outer level function, subsequently in the hierarchy keeping the CPU_FTR_ARCH_300 check intact as it is a faster check to do because of static branches
--- arch/powerpc/platforms/powernv/idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/idle.c +1 -1
@@ -1205,7 +1205,7 @@ static void __init pnv_probe_idle_states(void)return ; } -if (cpu_has_feature (CPU_FTR_ARCH_300 )) +if (pvr_version_is (PVR_POWER9 ))pnv_power9_idle_init ();for (i =0 ; i < nr_pnv_idle_states; i++)
Signature · 1 line
2.25.4
PATCH v4 2/3 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable
In reply to Pratik Rajesh SampatReplace the variable name from using "pnv_first_spr_loss_level" to "deep_spr_loss_state".
pnv_first_spr_loss_level is supposed to be the earliest state that has OPAL_PM_LOSE_FULL_CONTEXT set, in other places the kernel uses the "deep" states as terminology. Hence renaming the variable to be coherent to its semantics.
--- arch/powerpc/platforms/powernv/idle.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/powerpc/platforms/powernv/idle.c +9 -9
@@ -48,7 +48,7 @@ static bool default_stop_found;* First stop state levels when SPR and TB loss can occur. */ static u64 pnv_first_tb_loss_level =MAX_STOP_STATE +1 ; -static u64 pnv_first_spr_loss_level =MAX_STOP_STATE +1 ; +static u64 deep_spr_loss_state =MAX_STOP_STATE +1 ;/* * psscr value and mask of the deepest stop idle state.
@@ -657,7 +657,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)*/ mmcr0 =mfspr (SPRN_MMCR0 ); } -if ((psscr &PSSCR_RL_MASK ) >= pnv_first_spr_loss_level) { +if ((psscr &PSSCR_RL_MASK ) >= deep_spr_loss_state) { sprs.lpcr =mfspr (SPRN_LPCR ); sprs.hfscr =mfspr (SPRN_HFSCR ); sprs.fscr =mfspr (SPRN_FSCR );
@@ -741,7 +741,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)* just always test PSSCR for SPR/TB state loss. */ pls = (psscr &PSSCR_PLS ) >>PSSCR_PLS_SHIFT ; -if (likely (pls < pnv_first_spr_loss_level)) { +if (likely (pls < deep_spr_loss_state)) {if (sprs_saved)atomic_stop_thread_idle (); goto out;
@@ -1088,7 +1088,7 @@ static void __init pnv_power9_idle_init(void)* the deepest loss-less (OPAL_PM_STOP_INST_FAST) stop state. */ pnv_first_tb_loss_level =MAX_STOP_STATE +1 ; - pnv_first_spr_loss_level =MAX_STOP_STATE +1 ; + deep_spr_loss_state =MAX_STOP_STATE +1 ;for (i =0 ; i < nr_pnv_idle_states; i++) {int err;struct pnv_idle_states_t *state = &pnv_idle_states[i];
@@ -1099,8 +1099,8 @@ static void __init pnv_power9_idle_init(void) pnv_first_tb_loss_level = psscr_rl;if ((state->flags &OPAL_PM_LOSE_FULL_CONTEXT ) && - (pnv_first_spr_loss_level > psscr_rl)) - pnv_first_spr_loss_level = psscr_rl; + (deep_spr_loss_state > psscr_rl)) + deep_spr_loss_state = psscr_rl;/* * The idle code does not deal with TB loss occurring
@@ -1111,8 +1111,8 @@ static void __init pnv_power9_idle_init(void)* compatibility. */ if ((state->flags &OPAL_PM_TIMEBASE_STOP ) && - (pnv_first_spr_loss_level > psscr_rl)) - pnv_first_spr_loss_level = psscr_rl; + (deep_spr_loss_state > psscr_rl)) + deep_spr_loss_state = psscr_rl; err = validate_psscr_val_mask(&state->psscr_val, &state->psscr_mask,
@@ -1158,7 +1158,7 @@ static void __init pnv_power9_idle_init(void) }pr_info ("cpuidle-powernv: First stop level that may lose SPRs = 0x%llx\n" , - pnv_first_spr_loss_level); + deep_spr_loss_state);pr_info ("cpuidle-powernv: First stop level that may lose timebase = 0x%llx\n" , pnv_first_tb_loss_level);
Signature · 1 line
2.25.4
Re: [PATCH v4 2/3] powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable
Quoted 9 lines · Pratik Rajesh Sampat
Replace the variable name from using "
pnv_first_spr_loss_level" to "deep_spr_loss_state".
pnv_first_spr_loss_levelis supposed to be the earliest state that hasOPAL_PM_LOSE_FULL_CONTEXTset, in other places the kernel uses the "deep" states as terminology. Hence renaming the variable to be coherent to its semantics.Signed-off-by Pratik Rajesh Sampat <[email protected]>
Quoted 78 lines
--- arch/powerpc/platforms/powernv/idle.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)arch/powerpc/platforms/powernv/idle.c +9
-9@@ -48,7 +48,7 @@ static bool default_stop_found;* First stop state levels when SPR and TB loss can occur. */ static u64 pnv_first_tb_loss_level =MAX_STOP_STATE +1 ; -static u64 pnv_first_spr_loss_level =MAX_STOP_STATE +1 ; +static u64 deep_spr_loss_state =MAX_STOP_STATE +1 ;/* * psscr value and mask of the deepest stop idle state. @@ -657,7 +657,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)*/ mmcr0 =mfspr (SPRN_MMCR0 ); } -if ((psscr &PSSCR_RL_MASK ) >= pnv_first_spr_loss_level) { +if ((psscr &PSSCR_RL_MASK ) >= deep_spr_loss_state) { sprs.lpcr =mfspr (SPRN_LPCR ); sprs.hfscr =mfspr (SPRN_HFSCR ); sprs.fscr =mfspr (SPRN_FSCR );@@ -741,7 +741,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)* just always test PSSCR for SPR/TB state loss. */ pls = (psscr &PSSCR_PLS ) >>PSSCR_PLS_SHIFT ; -if (likely (pls < pnv_first_spr_loss_level)) { +if (likely (pls < deep_spr_loss_state)) {if (sprs_saved)atomic_stop_thread_idle (); goto out;@@ -1088,7 +1088,7 @@ static void __init pnv_power9_idle_init(void)* the deepest loss-less (OPAL_PM_STOP_INST_FAST) stop state. */ pnv_first_tb_loss_level =MAX_STOP_STATE +1 ; - pnv_first_spr_loss_level =MAX_STOP_STATE +1 ; + deep_spr_loss_state =MAX_STOP_STATE +1 ;for (i =0 ; i < nr_pnv_idle_states; i++) {int err;struct pnv_idle_states_t *state = &pnv_idle_states[i];@@ -1099,8 +1099,8 @@ static void __init pnv_power9_idle_init(void) pnv_first_tb_loss_level = psscr_rl;if ((state->flags &OPAL_PM_LOSE_FULL_CONTEXT ) && - (pnv_first_spr_loss_level > psscr_rl)) - pnv_first_spr_loss_level = psscr_rl; + (deep_spr_loss_state > psscr_rl)) + deep_spr_loss_state = psscr_rl;/* * The idle code does not deal with TB loss occurring @@ -1111,8 +1111,8 @@ static void __init pnv_power9_idle_init(void)* compatibility. */ if ((state->flags &OPAL_PM_TIMEBASE_STOP ) && - (pnv_first_spr_loss_level > psscr_rl)) - pnv_first_spr_loss_level = psscr_rl; + (deep_spr_loss_state > psscr_rl)) + deep_spr_loss_state = psscr_rl; err = validate_psscr_val_mask(&state->psscr_val, &state->psscr_mask,@@ -1158,7 +1158,7 @@ static void __init pnv_power9_idle_init(void) }pr_info ("cpuidle-powernv: First stop level that may lose SPRs = 0x%llx\n" , - pnv_first_spr_loss_level); + deep_spr_loss_state);pr_info ("cpuidle-powernv: First stop level that may lose timebase = 0x%llx\n" , pnv_first_tb_loss_level);Signature · 1 line
2.25.4
PATCH v4 3/3 powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above
In reply to Pratik Rajesh SampatPOWER9 onwards the support for the registers HID1, HID4, HID5 has been receded.
Although mfspr on the above registers worked in Power9, In Power10 simulator is unrecognized. Moving their assignment under the check for machines lower than Power9
--- arch/powerpc/platforms/powernv/idle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/powernv/idle.c +3 -3
@@ -73,9 +73,6 @@ static int pnv_save_sprs_for_deep_states(void)*/ uint64_t lpcr_val =mfspr (SPRN_LPCR );uint64_t hid0_val =mfspr (SPRN_HID0 ); -uint64_t hid1_val =mfspr (SPRN_HID1 ); -uint64_t hid4_val =mfspr (SPRN_HID4 ); -uint64_t hid5_val =mfspr (SPRN_HID5 );uint64_t hmeer_val =mfspr (SPRN_HMEER );uint64_t msr_val =MSR_IDLE ;uint64_t psscr_val = pnv_deepest_stop_psscr_val;
@@ -117,6 +114,9 @@ static int pnv_save_sprs_for_deep_states(void)/* Only p8 needs to set extra HID regiters */ if (!cpu_has_feature (CPU_FTR_ARCH_300 )) { +uint64_t hid1_val =mfspr (SPRN_HID1 ); +uint64_t hid4_val =mfspr (SPRN_HID4 ); +uint64_t hid5_val =mfspr (SPRN_HID5 ); rc =opal_slw_set_reg (pir,SPRN_HID1 , hid1_val);if (rc !=0 )
Signature · 1 line
2.25.4
Michael Ellerman
AppliedQuoted 10 lines · Pratik Rajesh Sampat
v3: https://lkml.org/lkml/2020/7/17/1093
Changelog v3-->v4:
Based on comments from Nicholas Piggin and Gautham Shenoy,
1. Changed the naming ofpnv_first_spr_loss_levelfrompnv_first_fullstate_loss_leveltodeep_spr_loss_state
2. Make the P9 PVR check only on the top level functionpnv_probe_idle_statesand let the rest of the checks be DT based because it is faster to do so[...]
Applied to powerpc/next.
[1/3] powerpc/powernv/idle: Replace CPU feature check with PVR check
https://git.kernel.org/powerpc/c/8747bf36f312356f8a295a0c39ff092d65ce75ae [2/3] powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable https://git.kernel.org/powerpc/c/dcbbfa6b05daca94ebcdbce80a7cf05c717d2942 [3/3] powerpc/powernv/idle: Exclude mfspr on HID1, 4, 5 on P9 and above https://git.kernel.org/powerpc/c/5c92fb1b46102e1efe0eed69e743f711bc1c7d2e
cheers