Message ID | 20250210071253.2991030-1-dedekind1@gmail.com (mailing list archive) |
---|---|
State | Queued |
Delegated to: | Rafael Wysocki |
Headers | show |
Series | intel_idle: cleanup BYT/CHT auto demotion disable | expand |
On Mon, Feb 10, 2025 at 8:12 AM Artem Bityutskiy <dedekind1@gmail.com> wrote: > > From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> > > 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. > > Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> > --- > drivers/idle/intel_idle.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c > index 118fe1d37c22..324814dc34fa 100644 > --- a/drivers/idle/intel_idle.c > +++ b/drivers/idle/intel_idle.c > @@ -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); > - } > } > > /** > -- Applied as 6.15 material, thanks!
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 118fe1d37c22..324814dc34fa 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -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); - } } /**