intel_idle: cleanup BYT/CHT auto demotion disable
Artem Bityutskiy
maintainerPATCH 1/1 intel_idle: cleanup BYT/CHT auto demotion disable
From: Artem Bityutskiy <[email protected]>
Bay Trail (BYT) and Cherry Trail (CHT) platforms have a very specific way of disabling auto-demotion via specific MSR bits. Clean up the code so that BYT/CHT-specifics do not show up in the common 'struct idle_cpu' data structure.
Remove the 'byt_auto_demotion_disable_flag' flag from 'struct idle_cpu', because a better coding pattern is to avoid very case-specific fields like 'bool byt_auto_demotion_disable_flag' in a common data structure, which is used for all platforms, not only BYT/CHT. The code is just more readable when common data structures contain only commonly used fields.
Instead, match BYT/CHT in the 'intel_idle_init_cstates_icpu()' function, and introduce a small helper to take care of BYT/CHT auto-demotion. This is consistent with how platform-specific things are done for other platforms.
No intended functional changes, compile-tested only.
--- drivers/idle/intel_idle.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/idle/intel_idle.c +13 -8
@@ -89,7 +89,6 @@ struct idle_cpu {* Indicate which enable bits to clear here. */ unsigned long auto_demotion_disable_flags; -bool byt_auto_demotion_disable_flag;bool disable_promotion_to_c1e;bool use_acpi; };
@@ -1463,13 +1462,11 @@ static const struct idle_cpu idle_cpu_snx __initconst = {static const struct idle_cpu idle_cpu_byt__initconst = { .state_table = byt_cstates, .disable_promotion_to_c1e = true, - .byt_auto_demotion_disable_flag = true, };static const struct idle_cpu idle_cpu_cht__initconst = { .state_table = cht_cstates, .disable_promotion_to_c1e = true, - .byt_auto_demotion_disable_flag = true, };static const struct idle_cpu idle_cpu_ivb__initconst = {
@@ -2055,6 +2052,15 @@ static void __init spr_idle_state_table_update(void) } } +/** +* byt_cht_auto_demotion_disable - Disable Bay/Cherry Trail auto-demotion. +*/ +static void __init byt_cht_auto_demotion_disable (void ) +{ +wrmsrl (MSR_CC6_DEMOTION_POLICY_CONFIG ,0 ); +wrmsrl (MSR_MC6_DEMOTION_POLICY_CONFIG ,0 ); +} +static bool __init intel_idle_verify_cstate (unsigned int mwait_hint) { unsigned int mwait_cstate = (MWAIT_HINT2CSTATE(mwait_hint) + 1) &
@@ -2136,6 +2142,10 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)case INTEL_ATOM_GRACEMONT :adl_idle_state_table_update ();break ; +case INTEL_ATOM_SILVERMONT : +case INTEL_ATOM_AIRMONT : +byt_cht_auto_demotion_disable (); +break ; }for (cstate =0 ; cstate <CPUIDLE_STATE_MAX ; ++cstate) {
@@ -2178,11 +2188,6 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) drv->state_count++; } - -if (icpu->byt_auto_demotion_disable_flag) { -wrmsrl (MSR_CC6_DEMOTION_POLICY_CONFIG ,0 ); -wrmsrl (MSR_MC6_DEMOTION_POLICY_CONFIG ,0 ); - } }/**
Signature · 1 line
2.47.1
Quoted 82 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
Bay Trail (BYT) and Cherry Trail (CHT) platforms have a very specific way of disabling auto-demotion via specific MSR bits. Clean up the code so that BYT/CHT-specifics do not show up in the common 'struct
idle_cpu' data structure.Remove the '
byt_auto_demotion_disable_flag' flag from 'structidle_cpu', because a better coding pattern is to avoid very case-specific fields like 'boolbyt_auto_demotion_disable_flag' in a common data structure, which is used for all platforms, not only BYT/CHT. The code is just more readable when common data structures contain only commonly used fields.Instead, match BYT/CHT in the '
intel_idle_init_cstates_icpu()' function, and introduce a small helper to take care of BYT/CHT auto-demotion. This is consistent with how platform-specific things are done for other platforms.No intended functional changes, compile-tested only.
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/idle/intel_idle.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)drivers/idle/intel_idle.c +13
-3@@ -89,7 +89,6 @@ struct idle_cpu {* Indicate which enable bits to clear here. */ unsigned long auto_demotion_disable_flags; -bool byt_auto_demotion_disable_flag;bool disable_promotion_to_c1e;bool use_acpi; };@@ -1463,13 +1462,11 @@ static const struct idle_cpu idle_cpu_snx __initconst = {static const struct idle_cpu idle_cpu_byt__initconst = { .state_table = byt_cstates, .disable_promotion_to_c1e = true, - .byt_auto_demotion_disable_flag = true, };static const struct idle_cpu idle_cpu_cht__initconst = { .state_table = cht_cstates, .disable_promotion_to_c1e = true, - .byt_auto_demotion_disable_flag = true, };static const struct idle_cpu idle_cpu_ivb__initconst = {@@ -2055,6 +2052,15 @@ static void __init spr_idle_state_table_update(void) } } +/** +* byt_cht_auto_demotion_disable - Disable Bay/Cherry Trail auto-demotion. +*/ +static void __init byt_cht_auto_demotion_disable (void ) +{ +wrmsrl (MSR_CC6_DEMOTION_POLICY_CONFIG ,0 ); +wrmsrl (MSR_MC6_DEMOTION_POLICY_CONFIG ,0 ); +} +static bool __init intel_idle_verify_cstate (unsigned int mwait_hint) { unsigned int mwait_cstate = (MWAIT_HINT2CSTATE(mwait_hint) + 1) &@@ -2136,6 +2142,10 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)case INTEL_ATOM_GRACEMONT :adl_idle_state_table_update ();break ; +case INTEL_ATOM_SILVERMONT : +case INTEL_ATOM_AIRMONT : +byt_cht_auto_demotion_disable (); +break ; }for (cstate =0 ; cstate <CPUIDLE_STATE_MAX ; ++cstate) {@@ -2178,11 +2188,6 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) drv->state_count++;
drivers/idle/intel_idle.c static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
Quoted 10 lines
drivers/idle/intel_idle.c +0
-6} - -if (icpu->byt_auto_demotion_disable_flag) { -wrmsrl (MSR_CC6_DEMOTION_POLICY_CONFIG ,0 ); -wrmsrl (MSR_MC6_DEMOTION_POLICY_CONFIG ,0 ); - } }/** --
Applied as 6.15 material, thanks!