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 <artem.bityutskiy@linux.intel.com>
Link: https://patch.msgid.link/20260425072532.358365-5-dedekind1@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Artem Bityutskiy 2026-04-25 10:25:32 +03:00 committed by Rafael J. Wysocki
parent 27428514d2
commit 86b488b19f

View File

@ -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) {