Skip to content

Commit c93d13b

Browse files
dedekindrafaeljw
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 0ad2507 commit c93d13b

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
};
@@ -1463,13 +1462,11 @@ static const struct idle_cpu idle_cpu_snx __initconst = {
14631462
static const struct idle_cpu idle_cpu_byt __initconst = {
14641463
.state_table = byt_cstates,
14651464
.disable_promotion_to_c1e = true,
1466-
.byt_auto_demotion_disable_flag = true,
14671465
};
14681466

14691467
static const struct idle_cpu idle_cpu_cht __initconst = {
14701468
.state_table = cht_cstates,
14711469
.disable_promotion_to_c1e = true,
1472-
.byt_auto_demotion_disable_flag = true,
14731470
};
14741471

14751472
static const struct idle_cpu idle_cpu_ivb __initconst = {
@@ -2055,6 +2052,15 @@ static void __init spr_idle_state_table_update(void)
20552052
}
20562053
}
20572054

2055+
/**
2056+
* byt_cht_auto_demotion_disable - Disable Bay/Cherry Trail auto-demotion.
2057+
*/
2058+
static void __init byt_cht_auto_demotion_disable(void)
2059+
{
2060+
wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
2061+
wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
2062+
}
2063+
20582064
static bool __init intel_idle_verify_cstate(unsigned int mwait_hint)
20592065
{
20602066
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)
21362142
case INTEL_ATOM_GRACEMONT:
21372143
adl_idle_state_table_update();
21382144
break;
2145+
case INTEL_ATOM_SILVERMONT:
2146+
case INTEL_ATOM_AIRMONT:
2147+
byt_cht_auto_demotion_disable();
2148+
break;
21392149
}
21402150

21412151
for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
@@ -2178,11 +2188,6 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
21782188

21792189
drv->state_count++;
21802190
}
2181-
2182-
if (icpu->byt_auto_demotion_disable_flag) {
2183-
wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
2184-
wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
2185-
}
21862191
}
21872192

21882193
/**

0 commit comments

Comments
 (0)