Skip to content

Commit 84d7dd3

Browse files
committed
intel_idle: clean up BYT/CHT auto demotion disable
JIRA: https://issues.redhat.com/browse/RHEL-85522 commit c93d13b Author: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Date: Mon Feb 10 09:12:53 2025 +0200 intel_idle: clean up BYT/CHT auto demotion disable 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> Link: https://patch.msgid.link/20250210071253.2991030-1-dedekind1@gmail.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent cb952e0 commit 84d7dd3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

drivers/idle/intel_idle.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ struct idle_cpu {
8989
* Indicate which enable bits to clear here.
9090
*/
9191
unsigned long auto_demotion_disable_flags;
92-
bool byt_auto_demotion_disable_flag;
9392
bool disable_promotion_to_c1e;
9493
bool use_acpi;
9594
};
@@ -1472,13 +1471,11 @@ static const struct idle_cpu idle_cpu_snx __initconst = {
14721471
static const struct idle_cpu idle_cpu_byt __initconst = {
14731472
.state_table = byt_cstates,
14741473
.disable_promotion_to_c1e = true,
1475-
.byt_auto_demotion_disable_flag = true,
14761474
};
14771475

14781476
static const struct idle_cpu idle_cpu_cht __initconst = {
14791477
.state_table = cht_cstates,
14801478
.disable_promotion_to_c1e = true,
1481-
.byt_auto_demotion_disable_flag = true,
14821479
};
14831480

14841481
static const struct idle_cpu idle_cpu_ivb __initconst = {
@@ -2065,6 +2062,15 @@ static void __init spr_idle_state_table_update(void)
20652062
}
20662063
}
20672064

2065+
/**
2066+
* byt_cht_auto_demotion_disable - Disable Bay/Cherry Trail auto-demotion.
2067+
*/
2068+
static void __init byt_cht_auto_demotion_disable(void)
2069+
{
2070+
wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
2071+
wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
2072+
}
2073+
20682074
static bool __init intel_idle_verify_cstate(unsigned int mwait_hint)
20692075
{
20702076
unsigned int mwait_cstate = (MWAIT_HINT2CSTATE(mwait_hint) + 1) &
@@ -2146,6 +2152,10 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
21462152
case INTEL_ATOM_GRACEMONT:
21472153
adl_idle_state_table_update();
21482154
break;
2155+
case INTEL_ATOM_SILVERMONT:
2156+
case INTEL_ATOM_AIRMONT:
2157+
byt_cht_auto_demotion_disable();
2158+
break;
21492159
}
21502160

21512161
for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
@@ -2191,11 +2201,6 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
21912201

21922202
drv->state_count++;
21932203
}
2194-
2195-
if (icpu->byt_auto_demotion_disable_flag) {
2196-
wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
2197-
wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
2198-
}
21992204
}
22002205

22012206
/**

0 commit comments

Comments
 (0)