]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
intel_idle: Drop C-states redundant when PC6 is disabled
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Sat, 25 Apr 2026 07:25:32 +0000 (10:25 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 20 May 2026 20:36:02 +0000 (22:36 +0200)
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>
drivers/idle/intel_idle.c

index def04b1ab35511b6dddbe796869074615a161023..b2705d79a4ee7bde84f2ed97df2ae5f81a5118d5 100644 (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) {