From: Artem Bityutskiy Date: Sat, 25 Apr 2026 07:25:32 +0000 (+0300) Subject: intel_idle: Drop C-states redundant when PC6 is disabled X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86b488b19f969e4f32246dba042638bf1a1240ac;p=thirdparty%2Flinux.git intel_idle: Drop C-states redundant when PC6 is disabled On modern Xeon platforms, such as Granite Rapids, Sierra Forest, and Clearwater Forest, there are two flavors of requestable C6 states: C6 and C6P. C6 allows only core C6 (CC6), while C6P allows both CC6 and package C6 (PC6). PC6 saves more power but also has a higher exit latency, so many users disable it in BIOS. When PC6 is disabled, C6P becomes identical to C6 — the CPU treats C6P requests as C6 requests. Exposing both C6 and C6P to user space in this situation is confusing: two states with the same name look different but behave the same. It also adds unnecessary overhead to the cpuidle subsystem, which is a fast path: the governor evaluates every registered state on idle entry. Drop C-states that are redundant when PC6 is disabled by marking them with CPUIDLE_FLAG_UNUSABLE, which causes cpuidle to exclude them when registering idle states. Signed-off-by: Artem Bityutskiy Link: https://patch.msgid.link/20260425072532.358365-5-dedekind1@gmail.com Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index def04b1ab3551..b2705d79a4ee7 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -2129,6 +2129,53 @@ static void __init spr_idle_state_table_update(void) } } +/** + * drop_pc6_redundant_cstates() - Drop C-states redundant when PC6 is disabled. + * @states: Idle states table to modify. + * + * When PC6 is disabled in BIOS, C-states that exist solely to enable PC6 + * entry (such as C6P or C6SP) become identical to shallower C-states like + * C6, and are therefore redundant. Should be called only on systems with + * multiple C6 flavors. + */ +static void __init drop_pc6_redundant_cstates(struct cpuidle_state *states) +{ + int count; + + if (!skx_is_pc6_disabled()) + /* PC6 is not disabled, nothing to do */ + return; + + for (count = 0; states[count].enter; count++) + continue; + + if (count < 2) { + pr_debug("Too few idle states to drop PC6-redundant states\n"); + return; + } + + /* + * Sanity check: At this point all platforms with multiple C6 flavors + * use the CPUIDLE_FLAG_PARTIAL_HINT_MATCH flag. And the last state in + * the table is the one that becomes redundant when PC6 is disabled. + */ + if (!(states[count - 1].flags & CPUIDLE_FLAG_PARTIAL_HINT_MATCH)) { + pr_debug("Can't drop PC6-redundant states: unexpected flags\n"); + return; + } + + /* + * On all current platforms with multiple C6 flavors, there is only one + * C-state that becomes redundant when PC6 is disabled. This state is + * the last one in the table. Drop it by marking it with + * CPUIDLE_FLAG_UNUSABLE so that cpuidle excludes it when registering + * idle states. + */ + pr_info("Dropping idle state %s because PC6 is disabled\n", + states[count - 1].name); + states[count - 1].flags |= CPUIDLE_FLAG_UNUSABLE; +} + /** * byt_cht_auto_demotion_disable - Disable Bay/Cherry Trail auto-demotion. */ @@ -2218,6 +2265,12 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) case INTEL_ATOM_AIRMONT: byt_cht_auto_demotion_disable(); break; + case INTEL_GRANITERAPIDS_D: + case INTEL_GRANITERAPIDS_X: + case INTEL_ATOM_CRESTMONT_X: + case INTEL_ATOM_DARKMONT_X: + drop_pc6_redundant_cstates(cpuidle_state_table); + break; } for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {