Skip to contentSkip to conversation

cpufreq: CPPC: add autonomous mode boot parameter support

PATCH Superseded Sumit Gupta 3 participants 12 messages May 15 – May 18

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Sumit Gupta

author reviewer
#0 lore raw

v3 cover cpufreq: CPPC: add autonomous mode boot parameter support

This series adds a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup, avoiding per-CPU sysfs scripting at every boot.

When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

Patch 1: sets CPPC Enable Register for both OS-driven and autonomous CPPC control modes. It can be applied independently of patch 2.

Patch 2: adds the auto_sel_mode boot parameter with two modes:
- performance (or 1): override EPP to performance preference (0x0)
- default_epp (or 2): preserve EPP value programmed by BIOS/firmware

Patch 2 depends on Pierre's series [3] ("cpufreq: Set policy->min and max as real QoS constraints") so that policy->min/max set during cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy().

v2[2] -> v3:
- Split cppc_set_enable() into a separate patch (1/2).
- Change auto_sel_mode to accept EPP mode (string or numeric).
- Drop clamp on desired_perf; initialize it to max_perf as a starting hint.
- cppc_set_perf() failure during autonomous setup is non-fatal.
- cppc_set_auto_sel() failure: fall back to OS-driven mode.
- Documentation: list 'performance' and 'default_epp' modes as per code.
- Removed Randy Dunlap's reviewed-by from documentation as some change.

Sumit Gupta (2):
cpufreq: CPPC: Set CPPC Enable register in cpu_init
cpufreq: CPPC: add autonomous mode boot parameter support

 .../admin-guide/kernel-parameters.txt         |  16 +++
 drivers/cpufreq/cppc_cpufreq.c                | 130 +++++++++++++++++-
 2 files changed, 141 insertions(+), 5 deletions(-)

[1] v1: https://lore.kernel.org/lkml/[email protected]/
[2] v2: https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/

Signature · 1 line
2.34.1
author reviewer
#1 lore raw

PATCH v3 1/2 cpufreq: CPPC: Set CPPC Enable register in cpu_init

As per ACPI 6.x s8.4.6.1.4 (CPPC Enable register):
"If supported by the platform, OSPM writes a one to this register
to enable CPPC on this processor. If not implemented, OSPM assumes the platform always has CPPC enabled."

Call cppc_set_enable() at the start of cppc_cpufreq_cpu_init() so this is done for both OS-driven and autonomous CPPC control modes. Errors are logged but non-fatal as the register is optional.

---
 drivers/cpufreq/cppc_cpufreq.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/cpufreq/cppc_cpufreq.c +8 -0
index c1ba6c656f61..6b54427b52e1 100644
@@ -655,6 +655,14 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	caps = &cpu_data->perf_caps;
 	policy->driver_data = cpu_data;
 
+	/*
+	 * Enable CPPC for both OS-driven and autonomous modes.
+	 * The Enable register is optional - some platforms may not support it
+	 */
+	ret = cppc_set_enable(cpu, true);
+	if (ret && ret != -EOPNOTSUPP)
+		pr_warn("Failed to enable CPPC for CPU%d (%d)\n", cpu, ret);
+
 	/*
 	 * Set min to lowest nonlinear perf to avoid any efficiency penalty (see
 	 * Section 8.4.7.1.1.5 of ACPI 6.1 spec)
Signature · 1 line
2.34.1
author reviewer
#2 lore raw

PATCH v3 2/2 cpufreq: CPPC: add autonomous mode boot parameter support

In reply to Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
- performance (or 1): override EPP to performance preference (0x0)
- default_epp (or 2): preserve EPP value programmed by BIOS/firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/[email protected]/

---
 .../admin-guide/kernel-parameters.txt         |  16 +++
 drivers/cpufreq/cppc_cpufreq.c                | 122 +++++++++++++++++-
 2 files changed, 133 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +16 -0
index 0eb64aab3685..7e4b3a8fd76f 100644
@@ -1048,6 +1048,22 @@ Kernel parameters
 			policy to use. This governor must be registered in the
 			kernel before the cpufreq driver probes.
 
+	cppc_cpufreq.auto_sel_mode=
+			[CPU_FREQ] Enable ACPI CPPC autonomous performance
+			selection. When enabled, hardware automatically adjusts
+			CPU frequency on all CPUs based on workload demands.
+			In Autonomous mode, Energy Performance Preference (EPP)
+			hints guide hardware toward performance (0x0) or energy
+			efficiency (0xff).
+			Requires ACPI CPPC autonomous selection register
+			support.
+			Accepts:
+			  performance, 1: enable auto_sel + set EPP to
+					  performance (0x0)
+			  default_epp, 2: enable auto_sel, preserve EPP value
+					  programmed by BIOS/firmware
+			Unset: cpufreq governors are used (auto_sel disabled).
+
 	cpu_init_udelay=N
 			[X86,EARLY] Delay for N microsec between assert and de-assert
 			of APIC INIT to start processors.  This delay occurs
drivers/cpufreq/cppc_cpufreq.c +117 -5

144 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw
Quoted 44 lines · Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
- performance (or 1): override EPP to performance preference (0x0)
- default_epp (or 2): preserve EPP value programmed by BIOS/firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/[email protected]/

---
  .../admin-guide/kernel-parameters.txt         |  16 +++
  drivers/cpufreq/cppc_cpufreq.c                | 122 +++++++++++++++++-
  2 files changed, 133 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
index 0eb64aab3685..7e4b3a8fd76f 100644
@@ -1048,6 +1048,22 @@ Kernel parameters
  			policy to use. This governor must be registered in the
  			kernel before the cpufreq driver probes.
 
+	cppc_cpufreq.auto_sel_mode=
+			[CPU_FREQ] Enable ACPI CPPC autonomous performance
+			selection. When enabled, hardware automatically adjusts
+			CPU frequency on all CPUs based on workload demands.
+			In Autonomous mode, Energy Performance Preference (EPP)

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 1065

Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10 -0
+			hints guide hardware toward performance (0x0) or energy
+			efficiency (0xff).
+			Requires ACPI CPPC autonomous selection register
+			support.
+			Accepts:
+			  performance, 1: enable auto_sel + set EPP to
+					  performance (0x0)
+			  default_epp, 2: enable auto_sel, preserve EPP value
+					  programmed by BIOS/firmware
+			Unset: cpufreq governors are used (auto_sel disabled).

Rather than unset doing nothing, have you considered having it take a midpoint like 128? That's what we do in amd-pstate (default to balance_performance). I think it turns into a reasonable balance.

Quoted 155 lines
Documentation/admin-guide/kernel-parameters.txt +1 -0
+
  	cpu_init_udelay=N
  			[X86,EARLY] Delay for N microsec between assert and de-assert
  			of APIC INIT to start processors.  This delay occurs
drivers/cpufreq/cppc_cpufreq.c +117 -5
index 6b54427b52e1..5f4d735e7c7d 100644
@@ -28,6 +28,43 @@
 
  static struct cpufreq_driver cppc_cpufreq_driver;
 
+/* Autonomous Selection boot parameter modes */
+enum {
+	AUTO_SEL_PERFORMANCE = 1,
+	AUTO_SEL_DEFAULT_EPP = 2,
+};
+
+static int auto_sel_mode;
+
+static int auto_sel_mode_set(const char *val, const struct kernel_param *kp)
+{
+	if (sysfs_streq(val, "performance") || sysfs_streq(val, "1"))
+		*(int *)kp->arg = AUTO_SEL_PERFORMANCE;
+	else if (sysfs_streq(val, "default_epp") || sysfs_streq(val, "2"))
+		*(int *)kp->arg = AUTO_SEL_DEFAULT_EPP;
+	else
+		return -EINVAL;
+
+	return 0;
+}
+
+static int auto_sel_mode_get(char *buffer, const struct kernel_param *kp)
+{
+	switch (*(int *)kp->arg) {
+	case AUTO_SEL_PERFORMANCE:
+		return sysfs_emit(buffer, "performance\n");
+	case AUTO_SEL_DEFAULT_EPP:
+		return sysfs_emit(buffer, "default_epp\n");
+	default:
+		return sysfs_emit(buffer, "disabled\n");
+	}
+}
+
+static const struct kernel_param_ops auto_sel_mode_ops = {
+	.set = auto_sel_mode_set,
+	.get = auto_sel_mode_get,
+};
+
  #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE
  static enum {
  	FIE_UNSET = -1,
@@ -715,11 +752,75 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
  	policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
  	cpu_data->perf_ctrls.desired_perf =  caps->highest_perf;
 
-	ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
-	if (ret) {
-		pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
-			 caps->highest_perf, cpu, ret);
-		goto out;
+	/*
+	 * Enable autonomous mode on first init if boot param is set.
+	 * Check last_governor to detect first init and skip if auto_sel
+	 * is already enabled.
+	 */
+	if (auto_sel_mode && policy->last_governor[0] == '\0' &&
+	    !cpu_data->perf_ctrls.auto_sel) {
+		/* Init min/max_perf from caps if not already set by HW. */
+		if (!cpu_data->perf_ctrls.min_perf)
+			cpu_data->perf_ctrls.min_perf = caps->lowest_nonlinear_perf;
+		if (!cpu_data->perf_ctrls.max_perf)
+			cpu_data->perf_ctrls.max_perf = policy->boost_enabled ?
+				caps->highest_perf : caps->nominal_perf;
+
+		/*
+		 * In autonomous mode desired_perf is only a hint; EPP and
+		 * the platform drive actual selection within [min, max].
+		 * Initialize it to max_perf so HW starts at the upper bound.
+		 */
+		cpu_data->perf_ctrls.desired_perf = cpu_data->perf_ctrls.max_perf;
+
+		policy->cur = cppc_perf_to_khz(caps,
+					       cpu_data->perf_ctrls.desired_perf);
+
+		/*
+		 * Override EPP only in 'performance' mode; 'default_epp' mode
+		 * preserves the BIOS/firmware programmed EPP value.
+		 * EPP is optional - some platforms may not support it.
+		 */
+		if (auto_sel_mode == AUTO_SEL_PERFORMANCE) {
+			ret = cppc_set_epp(cpu, CPPC_EPP_PERFORMANCE_PREF);
+			if (ret && ret != -EOPNOTSUPP)
+				pr_warn("Failed to set EPP for CPU%d (%d)\n", cpu, ret);
+			else if (!ret)
+				cpu_data->perf_ctrls.energy_perf = CPPC_EPP_PERFORMANCE_PREF;
+		}
+
+		/* Program min/max/desired into CPPC regs (non-fatal on failure). */
+		ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
+		if (ret)
+			pr_warn("set_perf failed CPU%d (%d); using HW values\n",
+				cpu, ret);
+
+		ret = cppc_set_auto_sel(cpu, true);
+		if (ret && ret != -EOPNOTSUPP)
+			pr_warn("auto_sel CPU%d failed (%d); using OS mode\n",
+				cpu, ret);
+		else if (!ret)
+			cpu_data->perf_ctrls.auto_sel = true;
+	}
+
+	if (cpu_data->perf_ctrls.auto_sel) {
+		/* Sync policy limits from HW when autonomous mode is active */
+		policy->min = cppc_perf_to_khz(caps,
+					       cpu_data->perf_ctrls.min_perf ?:
+					       caps->lowest_nonlinear_perf);
+		policy->max = cppc_perf_to_khz(caps,
+					       cpu_data->perf_ctrls.max_perf ?:
+					       (policy->boost_enabled ?
+						caps->highest_perf :
+						caps->nominal_perf));
+	} else {
+		/* Normal mode: governors control frequency */
+		ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
+		if (ret) {
+			pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
+				 caps->highest_perf, cpu, ret);
+			goto out;
+		}
  	}
 
  	cppc_cpufreq_cpu_fie_init(policy);
@@ -1079,10 +1180,21 @@ static int __init cppc_cpufreq_init(void)
 
  static void __exit cppc_cpufreq_exit(void)
  {
+	unsigned int cpu;
+
+	for_each_present_cpu(cpu)
+		cppc_set_auto_sel(cpu, false);
+
  	cpufreq_unregister_driver(&cppc_cpufreq_driver);
  	cppc_freq_invariance_exit();
  }
 
+module_param_cb(auto_sel_mode, &auto_sel_mode_ops, &auto_sel_mode, 0444);
+MODULE_PARM_DESC(auto_sel_mode,
+		 "Enable CPPC autonomous performance selection at boot: "
+		 "performance or 1 (EPP=performance), "
+		 "default_epp or 2 (preserve BIOS/firmware EPP)");
+
  module_exit(cppc_cpufreq_exit);
  MODULE_AUTHOR("Ashwin Chaugule");
  MODULE_DESCRIPTION("CPUFreq driver based on the ACPI CPPC v5.0+ spec");
author reviewer
#4 lore raw

Hi Mario,

Quoted 60 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 56 lines · Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
   - performance (or 1): override EPP to performance preference (0x0)
   - default_epp (or 2): preserve EPP value programmed by BIOS/firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/[email protected]/
---
  .../admin-guide/kernel-parameters.txt         |  16 +++ drivers/cpufreq/cppc_cpufreq.c                | 122 +++++++++++++++++-

  2 files changed, 133 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 0eb64aab3685..7e4b3a8fd76f 100644
@@ -1048,6 +1048,22 @@ Kernel parameters

                      policy to use. This governor must be registered in the kernel before the cpufreq driver probes.

+     cppc_cpufreq.auto_sel_mode=
+                     [CPU_FREQ] Enable ACPI CPPC autonomous performance +                     selection. When enabled, hardware automatically adjusts
+                     CPU frequency on all CPUs based on workload demands.
+                     In Autonomous mode, Energy Performance Preference (EPP)
+                     hints guide hardware toward performance (0x0) or energy
+                     efficiency (0xff).
+                     Requires ACPI CPPC autonomous selection register +                     support.
+                     Accepts:
+                       performance, 1: enable auto_sel + set EPP to +                                       performance (0x0)
+                       default_epp, 2: enable auto_sel, preserve EPP

Quoted 8 lines
Quoted 4 lines

value
+                                       programmed by BIOS/firmware +                     Unset: cpufreq governors are used (auto_sel disabled).

Rather than unset doing nothing, have you considered having it take a midpoint like 128?  That's what we do in amd-pstate (default to balance_performance).  I think it turns into a reasonable balance.

Thanks for the suggestion.
I can add balance_performance that enables auto_sel with EPP=128 in v4.

On changing the driver default (no param behavior) to auto enable balance_performance, it would be good to keep the current behavior for now since cppc_cpufreq is generic across ARM64/RISC-V platforms where EPP and Autonomous Selection registers are optional.
A default change would affect existing users relying on governors.

Thank you,
Sumit Gupta

Quoted 174 lines
Quoted 173 lines

+
      cpu_init_udelay=N
                      [X86,EARLY] Delay for N microsec between assert and de-assert of APIC INIT to start processors.  This delay occurs

drivers/cpufreq/cppc_cpufreq.c +37 -0
index 6b54427b52e1..5f4d735e7c7d 100644
@@ -28,6 +28,43 @@
 
   static struct cpufreq_driver cppc_cpufreq_driver;
 
+/* Autonomous Selection boot parameter modes */
+enum {
+     AUTO_SEL_PERFORMANCE = 1,
+     AUTO_SEL_DEFAULT_EPP = 2,
+};
+
+static int auto_sel_mode;
+
+static int auto_sel_mode_set(const char *val, const struct 
 kernel_param *kp)
+{
+     if (sysfs_streq(val, "performance") || sysfs_streq(val, "1"))
+             *(int *)kp->arg = AUTO_SEL_PERFORMANCE;
+     else if (sysfs_streq(val, "default_epp") || sysfs_streq(val, "2"))
+             *(int *)kp->arg = AUTO_SEL_DEFAULT_EPP;
+     else
+             return -EINVAL;
+
+     return 0;
+}
+
+static int auto_sel_mode_get(char *buffer, const struct kernel_param 
 *kp)
+{
+     switch (*(int *)kp->arg) {
+     case AUTO_SEL_PERFORMANCE:
+             return sysfs_emit(buffer, "performance\n");
+     case AUTO_SEL_DEFAULT_EPP:
+             return sysfs_emit(buffer, "default_epp\n");
+     default:
+             return sysfs_emit(buffer, "disabled\n");
+     }
+}
+
+static const struct kernel_param_ops auto_sel_mode_ops = {
+     .set = auto_sel_mode_set,
+     .get = auto_sel_mode_get,
+};
+
   #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE

  static enum {
      FIE_UNSET = -1,

drivers/cpufreq/cppc_cpufreq.c +8 -5
@@ -715,11 +752,75 @@ static int cppc_cpufreq_cpu_init(struct 
 cpufreq_policy *policy)
       policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
       cpu_data->perf_ctrls.desired_perf = caps->highest_perf;
 
-     ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
-     if (ret) {
-             pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
-                      caps->highest_perf, cpu, ret);
-             goto out;
+     /*
+      * Enable autonomous mode on first init if boot param is set.
+      * Check last_governor to detect first init and skip if auto_sel
+      * is already enabled.
+      */
+     if (auto_sel_mode && policy->last_governor[0] == '\0' &&
+         !cpu_data->perf_ctrls.auto_sel) {
+             /* Init min/max_perf from caps if not already set by 

HW. */
+             if (!cpu_data->perf_ctrls.min_perf)
+                     cpu_data->perf_ctrls.min_perf = caps->lowest_nonlinear_perf;
+             if (!cpu_data->perf_ctrls.max_perf)
+                     cpu_data->perf_ctrls.max_perf = policy->boost_enabled ?
+                             caps->highest_perf : caps->nominal_perf; +
+             /*
+              * In autonomous mode desired_perf is only a hint; EPP and +              * the platform drive actual selection within [min, max]. +              * Initialize it to max_perf so HW starts at the upper bound.
+              */
+             cpu_data->perf_ctrls.desired_perf = cpu_data->perf_ctrls.max_perf;

drivers/cpufreq/cppc_cpufreq.c +6 -0
+
+             policy->cur = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.desired_perf);
+
+             /*
+              * Override EPP only in 'performance' mode; 

'default_epp' mode
+              * preserves the BIOS/firmware programmed EPP value. +              * EPP is optional - some platforms may not support it. +              */
+             if (auto_sel_mode == AUTO_SEL_PERFORMANCE) { +                     ret = cppc_set_epp(cpu, CPPC_EPP_PERFORMANCE_PREF);
+                     if (ret && ret != -EOPNOTSUPP)
+                             pr_warn("Failed to set EPP for CPU%d (%d)\n", cpu, ret);
+                     else if (!ret)
+ cpu_data->perf_ctrls.energy_perf = CPPC_EPP_PERFORMANCE_PREF; +             }
+
+             /* Program min/max/desired into CPPC regs (non-fatal on failure). */
+             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret)
+                     pr_warn("set_perf failed CPU%d (%d); using HW values\n",
+                             cpu, ret);
+
+             ret = cppc_set_auto_sel(cpu, true);
+             if (ret && ret != -EOPNOTSUPP)
+                     pr_warn("auto_sel CPU%d failed (%d); using OS mode\n",
+                             cpu, ret);
+             else if (!ret)
+                     cpu_data->perf_ctrls.auto_sel = true; +     }
+
+     if (cpu_data->perf_ctrls.auto_sel) {
+             /* Sync policy limits from HW when autonomous mode is active */
+             policy->min = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.min_perf ?:
+ caps->lowest_nonlinear_perf);
+             policy->max = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.max_perf ?:
+ (policy->boost_enabled ?
+ caps->highest_perf :
+ caps->nominal_perf));
+     } else {
+             /* Normal mode: governors control frequency */ +             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret) {
+                     pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
+                              caps->highest_perf, cpu, ret); +                     goto out;
+             }
      }

      cppc_cpufreq_cpu_fie_init(policy);

drivers/cpufreq/cppc_cpufreq.c +11 -0
@@ -1079,10 +1180,21 @@ static int __init cppc_cpufreq_init(void)
 
   static void __exit cppc_cpufreq_exit(void)
   {
+     unsigned int cpu;
+
+     for_each_present_cpu(cpu)
+             cppc_set_auto_sel(cpu, false);
+
       cpufreq_unregister_driver(&cppc_cpufreq_driver);
       cppc_freq_invariance_exit();
   }
 
+module_param_cb(auto_sel_mode, &auto_sel_mode_ops, &auto_sel_mode, 
 0444);
+MODULE_PARM_DESC(auto_sel_mode,
+              "Enable CPPC autonomous performance selection at boot: "
+              "performance or 1 (EPP=performance), "
+              "default_epp or 2 (preserve BIOS/firmware EPP)");
+
   module_exit(cppc_cpufreq_exit);
   MODULE_AUTHOR("Ashwin Chaugule");

  MODULE_DESCRIPTION("CPUFreq driver based on the ACPI CPPC v5.0+ spec");

#5 lore raw
Quoted 76 lines · Sumit Gupta

Hi Mario,

Quoted 60 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 56 lines · Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
   - performance (or 1): override EPP to performance preference (0x0)
   - default_epp (or 2): preserve EPP value programmed by BIOS/firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/20260511135538.522653-1- [email protected]/
---
  .../admin-guide/kernel-parameters.txt         |  16 +++ drivers/cpufreq/cppc_cpufreq.c                | 122 +++++++++++++++++-

  2 files changed, 133 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 0eb64aab3685..7e4b3a8fd76f 100644
@@ -1048,6 +1048,22 @@ Kernel parameters

                      policy to use. This governor must be registered in the kernel before the cpufreq driver probes.

+     cppc_cpufreq.auto_sel_mode=
+                     [CPU_FREQ] Enable ACPI CPPC autonomous performance +                     selection. When enabled, hardware automatically adjusts
+                     CPU frequency on all CPUs based on workload demands.
+                     In Autonomous mode, Energy Performance Preference (EPP)
+                     hints guide hardware toward performance (0x0) or energy
+                     efficiency (0xff).
+                     Requires ACPI CPPC autonomous selection register +                     support.
+                     Accepts:
+                       performance, 1: enable auto_sel + set EPP to +                                       performance (0x0)
+                       default_epp, 2: enable auto_sel, preserve EPP

Quoted 8 lines
Quoted 4 lines

value
+                                       programmed by BIOS/firmware +                     Unset: cpufreq governors are used (auto_sel disabled).

Rather than unset doing nothing, have you considered having it take a midpoint like 128?  That's what we do in amd-pstate (default to balance_performance).  I think it turns into a reasonable balance.

Thanks for the suggestion.
I can add balance_performance that enables auto_sel with EPP=128 in v4.

Quoted 8 lines

On changing the driver default (no param behavior) to auto enable balance_performance, it would be good to keep the current behavior for now since cppc_cpufreq is generic across ARM64/RISC-V platforms where EPP and Autonomous Selection registers are optional.
A default change would affect existing users relying on governors.

Thank you,
Sumit Gupta

But couldn't you make the "no module parameter set" follow the behavior to only set the registers if they're available?

So the systems that support it start using it, the ones that don't it's a NOP.

Quoted 176 lines
Quoted 176 lines
Quoted 175 lines

+
      cpu_init_udelay=N
                      [X86,EARLY] Delay for N microsec between assert and de-assert of APIC INIT to start processors.  This delay occurs

drivers/cpufreq/cppc_cpufreq.c +37 -0
index 6b54427b52e1..5f4d735e7c7d 100644
@@ -28,6 +28,43 @@
 
   static struct cpufreq_driver cppc_cpufreq_driver;
 
+/* Autonomous Selection boot parameter modes */
+enum {
+     AUTO_SEL_PERFORMANCE = 1,
+     AUTO_SEL_DEFAULT_EPP = 2,
+};
+
+static int auto_sel_mode;
+
+static int auto_sel_mode_set(const char *val, const struct 
 kernel_param *kp)
+{
+     if (sysfs_streq(val, "performance") || sysfs_streq(val, "1"))
+             *(int *)kp->arg = AUTO_SEL_PERFORMANCE;
+     else if (sysfs_streq(val, "default_epp") || sysfs_streq(val, "2"))
+             *(int *)kp->arg = AUTO_SEL_DEFAULT_EPP;
+     else
+             return -EINVAL;
+
+     return 0;
+}
+
+static int auto_sel_mode_get(char *buffer, const struct kernel_param 
 *kp)
+{
+     switch (*(int *)kp->arg) {
+     case AUTO_SEL_PERFORMANCE:
+             return sysfs_emit(buffer, "performance\n");
+     case AUTO_SEL_DEFAULT_EPP:
+             return sysfs_emit(buffer, "default_epp\n");
+     default:
+             return sysfs_emit(buffer, "disabled\n");
+     }
+}
+
+static const struct kernel_param_ops auto_sel_mode_ops = {
+     .set = auto_sel_mode_set,
+     .get = auto_sel_mode_get,
+};
+
   #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE

  static enum {
      FIE_UNSET = -1,

drivers/cpufreq/cppc_cpufreq.c +8 -5
@@ -715,11 +752,75 @@ static int cppc_cpufreq_cpu_init(struct 
 cpufreq_policy *policy)
       policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
       cpu_data->perf_ctrls.desired_perf = caps->highest_perf;
 
-     ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
-     if (ret) {
-             pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
-                      caps->highest_perf, cpu, ret);
-             goto out;
+     /*
+      * Enable autonomous mode on first init if boot param is set.
+      * Check last_governor to detect first init and skip if auto_sel
+      * is already enabled.
+      */
+     if (auto_sel_mode && policy->last_governor[0] == '\0' &&
+         !cpu_data->perf_ctrls.auto_sel) {
+             /* Init min/max_perf from caps if not already set by 

HW. */
+             if (!cpu_data->perf_ctrls.min_perf) +                     cpu_data->perf_ctrls.min_perf = caps-

Quoted 1 line

lowest_nonlinear_perf;

+             if (!cpu_data->perf_ctrls.max_perf)
+                     cpu_data->perf_ctrls.max_perf = policy-

Quoted 1 line

boost_enabled ?

+                             caps->highest_perf : caps->nominal_perf; +
+             /*
+              * In autonomous mode desired_perf is only a hint; EPP and +              * the platform drive actual selection within [min, max]. +              * Initialize it to max_perf so HW starts at the upper bound.
+              */
+             cpu_data->perf_ctrls.desired_perf = cpu_data-

Quoted 1 line

perf_ctrls.max_perf;

drivers/cpufreq/cppc_cpufreq.c +6 -0
+
+             policy->cur = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.desired_perf);
+
+             /*
+              * Override EPP only in 'performance' mode; 

'default_epp' mode
+              * preserves the BIOS/firmware programmed EPP value. +              * EPP is optional - some platforms may not support it. +              */
+             if (auto_sel_mode == AUTO_SEL_PERFORMANCE) { +                     ret = cppc_set_epp(cpu, CPPC_EPP_PERFORMANCE_PREF);
+                     if (ret && ret != -EOPNOTSUPP)
+                             pr_warn("Failed to set EPP for CPU%d (%d)\n", cpu, ret);
+                     else if (!ret)
+ cpu_data->perf_ctrls.energy_perf = CPPC_EPP_PERFORMANCE_PREF; +             }
+
+             /* Program min/max/desired into CPPC regs (non-fatal on failure). */
+             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret)
+                     pr_warn("set_perf failed CPU%d (%d); using HW values\n",
+                             cpu, ret);
+
+             ret = cppc_set_auto_sel(cpu, true);
+             if (ret && ret != -EOPNOTSUPP)
+                     pr_warn("auto_sel CPU%d failed (%d); using OS mode\n",
+                             cpu, ret);
+             else if (!ret)
+                     cpu_data->perf_ctrls.auto_sel = true; +     }
+
+     if (cpu_data->perf_ctrls.auto_sel) {
+             /* Sync policy limits from HW when autonomous mode is active */
+             policy->min = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.min_perf ?:
+ caps->lowest_nonlinear_perf);
+             policy->max = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.max_perf ?:
+ (policy->boost_enabled ?
+ caps->highest_perf :
+ caps->nominal_perf));
+     } else {
+             /* Normal mode: governors control frequency */ +             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret) {
+                     pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
+                              caps->highest_perf, cpu, ret); +                     goto out;
+             }
      }

      cppc_cpufreq_cpu_fie_init(policy);

drivers/cpufreq/cppc_cpufreq.c +11 -0
@@ -1079,10 +1180,21 @@ static int __init cppc_cpufreq_init(void)
 
   static void __exit cppc_cpufreq_exit(void)
   {
+     unsigned int cpu;
+
+     for_each_present_cpu(cpu)
+             cppc_set_auto_sel(cpu, false);
+
       cpufreq_unregister_driver(&cppc_cpufreq_driver);
       cppc_freq_invariance_exit();
   }
 
+module_param_cb(auto_sel_mode, &auto_sel_mode_ops, &auto_sel_mode, 
 0444);
+MODULE_PARM_DESC(auto_sel_mode,
+              "Enable CPPC autonomous performance selection at boot: "
+              "performance or 1 (EPP=performance), "
+              "default_epp or 2 (preserve BIOS/firmware EPP)");
+
   module_exit(cppc_cpufreq_exit);
   MODULE_AUTHOR("Ashwin Chaugule");

  MODULE_DESCRIPTION("CPUFreq driver based on the ACPI CPPC v5.0+ spec");

author reviewer
#6 lore raw
Quoted 91 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 87 lines · Sumit Gupta

Hi Mario,

Quoted 65 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 61 lines · Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
   - performance (or 1): override EPP to performance preference (0x0)
   - default_epp (or 2): preserve EPP value programmed by BIOS/firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/20260511135538.522653-1-
[email protected]/
---
  .../admin-guide/kernel-parameters.txt         |  16 +++ drivers/cpufreq/cppc_cpufreq.c                | 122
+++++++++++++++++-

  2 files changed, 133 insertions(+), 5 deletions(-)
(quoted diff) renamed from Documentation/admin-guide/kernel-parameters.txt +0 -0

Documentation/admin-guide/kernel-parameters.txt
index 0eb64aab3685..7e4b3a8fd76f 100644

Documentation/admin-guide/kernel-parameters.txt +0 -0
@@ -1048,6 +1048,22 @@ Kernel parameters

                      policy to use. This governor must be registered in the
                      kernel before the cpufreq driver probes.

+     cppc_cpufreq.auto_sel_mode=
+                     [CPU_FREQ] Enable ACPI CPPC autonomous performance
+                     selection. When enabled, hardware automatically adjusts
+                     CPU frequency on all CPUs based on workload demands.
+                     In Autonomous mode, Energy Performance Preference (EPP)
+                     hints guide hardware toward performance (0x0) or energy
+                     efficiency (0xff).
+                     Requires ACPI CPPC autonomous selection register +                     support.
+                     Accepts:
+                       performance, 1: enable auto_sel + set EPP to +                                       performance (0x0)
+                       default_epp, 2: enable auto_sel, preserve EPP

Quoted 8 lines
Quoted 4 lines

value
+                                       programmed by BIOS/firmware +                     Unset: cpufreq governors are used (auto_sel disabled).

Rather than unset doing nothing, have you considered having it take a midpoint like 128?  That's what we do in amd-pstate (default to balance_performance).  I think it turns into a reasonable balance.

Thanks for the suggestion.
I can add balance_performance that enables auto_sel with EPP=128 in v4.

On changing the driver default (no param behavior) to auto enable balance_performance, it would be good to keep the current behavior for now since cppc_cpufreq is generic across ARM64/RISC-V platforms where EPP and Autonomous Selection registers are optional.
A default change would affect existing users relying on governors.

Quoted 9 lines
Quoted 2 lines

Thank you,
Sumit Gupta

But couldn't you make the "no module parameter set" follow the behavior to only set the registers if they're available?

So the systems that support it start using it, the ones that don't it's a NOP.

Would it work to add balance_performance as a new mode in v4, and discuss changing the default separately as a follow-up?

Runtime detection helps for unsupported platforms. But platforms which support the registers use OS governors today, and silently switching them to autonomous mode on a kernel update is a behavior change for existing users. They would also have no way to boot into sw governor.

Thank you,
Sumit Gupta

Quoted 186 lines
Quoted 185 lines
Quoted 185 lines
Quoted 184 lines

+
      cpu_init_udelay=N
                      [X86,EARLY] Delay for N microsec between assert and de-assert
                      of APIC INIT to start processors. This delay occurs

drivers/cpufreq/ renamed from drivers/cpufreq/cppc_cpufreq.c +0 -0

cppc_cpufreq.c
index 6b54427b52e1..5f4d735e7c7d 100644

drivers/cpufreq/cppc_cpufreq.c +37 -0
@@ -28,6 +28,43 @@
 
   static struct cpufreq_driver cppc_cpufreq_driver;
 
+/* Autonomous Selection boot parameter modes */
+enum {
+     AUTO_SEL_PERFORMANCE = 1,
+     AUTO_SEL_DEFAULT_EPP = 2,
+};
+
+static int auto_sel_mode;
+
+static int auto_sel_mode_set(const char *val, const struct
 kernel_param *kp)
+{
+     if (sysfs_streq(val, "performance") || sysfs_streq(val, "1"))
+             *(int *)kp->arg = AUTO_SEL_PERFORMANCE;
+     else if (sysfs_streq(val, "default_epp") || sysfs_streq(val, 
 "2"))
+             *(int *)kp->arg = AUTO_SEL_DEFAULT_EPP;
+     else
+             return -EINVAL;
+
+     return 0;
+}
+
+static int auto_sel_mode_get(char *buffer, const struct kernel_param
 *kp)
+{
+     switch (*(int *)kp->arg) {
+     case AUTO_SEL_PERFORMANCE:
+             return sysfs_emit(buffer, "performance\n");
+     case AUTO_SEL_DEFAULT_EPP:
+             return sysfs_emit(buffer, "default_epp\n");
+     default:
+             return sysfs_emit(buffer, "disabled\n");
+     }
+}
+
+static const struct kernel_param_ops auto_sel_mode_ops = {
+     .set = auto_sel_mode_set,
+     .get = auto_sel_mode_get,
+};
+

  #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE
  static enum {
      FIE_UNSET = -1,

drivers/cpufreq/cppc_cpufreq.c +8 -5
@@ -715,11 +752,75 @@ static int cppc_cpufreq_cpu_init(struct
 cpufreq_policy *policy)
       policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
       cpu_data->perf_ctrls.desired_perf = caps->highest_perf;
 
-     ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
-     if (ret) {
-             pr_debug("Err setting perf value:%d on CPU:%d. 
 ret:%d\n",
-                      caps->highest_perf, cpu, ret);
-             goto out;
+     /*
+      * Enable autonomous mode on first init if boot param is set.
+      * Check last_governor to detect first init and skip if auto_sel
+      * is already enabled.
+      */
+     if (auto_sel_mode && policy->last_governor[0] == '\0' &&
+         !cpu_data->perf_ctrls.auto_sel) {
+             /* Init min/max_perf from caps if not already set by

HW. */
+             if (!cpu_data->perf_ctrls.min_perf) +                     cpu_data->perf_ctrls.min_perf = caps-

Quoted 1 line

lowest_nonlinear_perf;

+             if (!cpu_data->perf_ctrls.max_perf)
+                     cpu_data->perf_ctrls.max_perf = policy-

Quoted 1 line

boost_enabled ?

+                             caps->highest_perf : caps->nominal_perf; +
+             /*
+              * In autonomous mode desired_perf is only a hint; EPP and
+              * the platform drive actual selection within [min, max].
+              * Initialize it to max_perf so HW starts at the upper bound.
+              */
+             cpu_data->perf_ctrls.desired_perf = cpu_data-

Quoted 1 line

perf_ctrls.max_perf;

drivers/cpufreq/cppc_cpufreq.c +6 -0
+
+             policy->cur = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.desired_perf);
+
+             /*
+              * Override EPP only in 'performance' mode;

'default_epp' mode
+              * preserves the BIOS/firmware programmed EPP value. +              * EPP is optional - some platforms may not support it. +              */
+             if (auto_sel_mode == AUTO_SEL_PERFORMANCE) { +                     ret = cppc_set_epp(cpu, CPPC_EPP_PERFORMANCE_PREF);
+                     if (ret && ret != -EOPNOTSUPP)
+                             pr_warn("Failed to set EPP for CPU%d (%d)\n", cpu, ret);
+                     else if (!ret)
+ cpu_data->perf_ctrls.energy_perf = CPPC_EPP_PERFORMANCE_PREF; +             }
+
+             /* Program min/max/desired into CPPC regs (non-fatal on failure). */
+             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret)
+                     pr_warn("set_perf failed CPU%d (%d); using HW values\n",
+                             cpu, ret);
+
+             ret = cppc_set_auto_sel(cpu, true);
+             if (ret && ret != -EOPNOTSUPP)
+                     pr_warn("auto_sel CPU%d failed (%d); using OS mode\n",
+                             cpu, ret);
+             else if (!ret)
+                     cpu_data->perf_ctrls.auto_sel = true; +     }
+
+     if (cpu_data->perf_ctrls.auto_sel) {
+             /* Sync policy limits from HW when autonomous mode is active */
+             policy->min = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.min_perf ?:
+ caps->lowest_nonlinear_perf);
+             policy->max = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.max_perf ?:
+ (policy->boost_enabled ?
+ caps->highest_perf :
+ caps->nominal_perf));
+     } else {
+             /* Normal mode: governors control frequency */ +             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret) {
+                     pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
+                              caps->highest_perf, cpu, ret); +                     goto out;
+             }
      }

      cppc_cpufreq_cpu_fie_init(policy);

drivers/cpufreq/cppc_cpufreq.c +8 -0
@@ -1079,10 +1180,21 @@ static int __init cppc_cpufreq_init(void)
 
   static void __exit cppc_cpufreq_exit(void)
   {
+     unsigned int cpu;
+
+     for_each_present_cpu(cpu)
+             cppc_set_auto_sel(cpu, false);
+
       cpufreq_unregister_driver(&cppc_cpufreq_driver);
       cppc_freq_invariance_exit();
   }
 
+module_param_cb(auto_sel_mode, &auto_sel_mode_ops, &auto_sel_mode,
 0444);
+MODULE_PARM_DESC(auto_sel_mode,
+              "Enable CPPC autonomous performance selection at 

boot: "
+              "performance or 1 (EPP=performance), "
+              "default_epp or 2 (preserve BIOS/firmware EPP)"); +
  module_exit(cppc_cpufreq_exit);
  MODULE_AUTHOR("Ashwin Chaugule"); MODULE_DESCRIPTION("CPUFreq driver based on the ACPI CPPC v5.0+ spec");

#7 lore raw
Quoted 99 lines · Sumit Gupta
Quoted 97 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 81 lines · Sumit Gupta

Hi Mario,

Quoted 65 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 61 lines · Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
   - performance (or 1): override EPP to performance preference (0x0)
   - default_epp (or 2): preserve EPP value programmed by BIOS/ firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/20260511135538.522653-1-
[email protected]/
---
  .../admin-guide/kernel-parameters.txt         |  16 +++ drivers/cpufreq/cppc_cpufreq.c                | 122 +++++++++++++
++++-

  2 files changed, 133 insertions(+), 5 deletions(-)
(quoted diff) renamed from Documentation/admin-guide/kernel-parameters.txt +0 -0

Documentation/admin-guide/kernel-parameters.txt
index 0eb64aab3685..7e4b3a8fd76f 100644

Documentation/admin-guide/kernel-parameters.txt +0 -0
@@ -1048,6 +1048,22 @@ Kernel parameters

                      policy to use. This governor must be registered in the
                      kernel before the cpufreq driver probes.

+     cppc_cpufreq.auto_sel_mode=
+                     [CPU_FREQ] Enable ACPI CPPC autonomous performance
+                     selection. When enabled, hardware automatically adjusts
+                     CPU frequency on all CPUs based on workload demands.
+                     In Autonomous mode, Energy Performance Preference (EPP)
+                     hints guide hardware toward performance (0x0) or energy
+                     efficiency (0xff).
+                     Requires ACPI CPPC autonomous selection register +                     support.
+                     Accepts:
+                       performance, 1: enable auto_sel + set EPP to +                                       performance (0x0)
+                       default_epp, 2: enable auto_sel, preserve EPP

Quoted 8 lines
Quoted 4 lines

value
+                                       programmed by BIOS/firmware +                     Unset: cpufreq governors are used (auto_sel disabled).

Rather than unset doing nothing, have you considered having it take a midpoint like 128?  That's what we do in amd-pstate (default to balance_performance).  I think it turns into a reasonable balance.

Thanks for the suggestion.
I can add balance_performance that enables auto_sel with EPP=128 in v4.

Quoted 8 lines

On changing the driver default (no param behavior) to auto enable balance_performance, it would be good to keep the current behavior for now since cppc_cpufreq is generic across ARM64/RISC-V platforms where EPP and Autonomous Selection registers are optional.
A default change would affect existing users relying on governors.

Thank you,
Sumit Gupta

But couldn't you make the "no module parameter set" follow the behavior to only set the registers if they're available?

Quoted 7 lines
Quoted 3 lines

So the systems that support it start using it, the ones that don't it's a NOP.

Would it work to add balance_performance as a new mode in v4, and discuss changing the default separately as a follow-up?

Sure.

Quoted 5 lines

Runtime detection helps for unsupported platforms. But platforms which support the registers use OS governors today, and silently switching them to autonomous mode on a kernel update is a behavior change for existing users. They would also have no way to boot into sw governor.

But hopefully it should be better battery life/responsiveness for those scenarios too, right?

Quoted 188 lines
Quoted 188 lines
Quoted 187 lines
Quoted 187 lines
Quoted 186 lines

+
      cpu_init_udelay=N
                      [X86,EARLY] Delay for N microsec between assert and de-assert
                      of APIC INIT to start processors. This delay occurs

drivers/cpufreq/ renamed from drivers/cpufreq/cppc_cpufreq.c +0 -0

cppc_cpufreq.c
index 6b54427b52e1..5f4d735e7c7d 100644

drivers/cpufreq/cppc_cpufreq.c +37 -0
@@ -28,6 +28,43 @@
 
   static struct cpufreq_driver cppc_cpufreq_driver;
 
+/* Autonomous Selection boot parameter modes */
+enum {
+     AUTO_SEL_PERFORMANCE = 1,
+     AUTO_SEL_DEFAULT_EPP = 2,
+};
+
+static int auto_sel_mode;
+
+static int auto_sel_mode_set(const char *val, const struct
 kernel_param *kp)
+{
+     if (sysfs_streq(val, "performance") || sysfs_streq(val, "1"))
+             *(int *)kp->arg = AUTO_SEL_PERFORMANCE;
+     else if (sysfs_streq(val, "default_epp") || sysfs_streq(val, 
 "2"))
+             *(int *)kp->arg = AUTO_SEL_DEFAULT_EPP;
+     else
+             return -EINVAL;
+
+     return 0;
+}
+
+static int auto_sel_mode_get(char *buffer, const struct kernel_param
 *kp)
+{
+     switch (*(int *)kp->arg) {
+     case AUTO_SEL_PERFORMANCE:
+             return sysfs_emit(buffer, "performance\n");
+     case AUTO_SEL_DEFAULT_EPP:
+             return sysfs_emit(buffer, "default_epp\n");
+     default:
+             return sysfs_emit(buffer, "disabled\n");
+     }
+}
+
+static const struct kernel_param_ops auto_sel_mode_ops = {
+     .set = auto_sel_mode_set,
+     .get = auto_sel_mode_get,
+};
+

  #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE
  static enum {
      FIE_UNSET = -1,

drivers/cpufreq/cppc_cpufreq.c +8 -5
@@ -715,11 +752,75 @@ static int cppc_cpufreq_cpu_init(struct
 cpufreq_policy *policy)
       policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
       cpu_data->perf_ctrls.desired_perf = caps->highest_perf;
 
-     ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
-     if (ret) {
-             pr_debug("Err setting perf value:%d on CPU:%d. ret: 
 %d\n",
-                      caps->highest_perf, cpu, ret);
-             goto out;
+     /*
+      * Enable autonomous mode on first init if boot param is set.
+      * Check last_governor to detect first init and skip if auto_sel
+      * is already enabled.
+      */
+     if (auto_sel_mode && policy->last_governor[0] == '\0' &&
+         !cpu_data->perf_ctrls.auto_sel) {
+             /* Init min/max_perf from caps if not already set by

HW. */
+             if (!cpu_data->perf_ctrls.min_perf) +                     cpu_data->perf_ctrls.min_perf = caps-

Quoted 1 line

lowest_nonlinear_perf;

+             if (!cpu_data->perf_ctrls.max_perf)
+                     cpu_data->perf_ctrls.max_perf = policy-

Quoted 1 line

boost_enabled ?

+                             caps->highest_perf : caps->nominal_perf; +
+             /*
+              * In autonomous mode desired_perf is only a hint; EPP and
+              * the platform drive actual selection within [min, max].
+              * Initialize it to max_perf so HW starts at the upper bound.
+              */
+             cpu_data->perf_ctrls.desired_perf = cpu_data-

Quoted 1 line

perf_ctrls.max_perf;

drivers/cpufreq/cppc_cpufreq.c +6 -0
+
+             policy->cur = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.desired_perf);
+
+             /*
+              * Override EPP only in 'performance' mode;

'default_epp' mode
+              * preserves the BIOS/firmware programmed EPP value. +              * EPP is optional - some platforms may not support it. +              */
+             if (auto_sel_mode == AUTO_SEL_PERFORMANCE) { +                     ret = cppc_set_epp(cpu, CPPC_EPP_PERFORMANCE_PREF);
+                     if (ret && ret != -EOPNOTSUPP)
+                             pr_warn("Failed to set EPP for CPU%d (%d)\n", cpu, ret);
+                     else if (!ret)
+ cpu_data->perf_ctrls.energy_perf = CPPC_EPP_PERFORMANCE_PREF; +             }
+
+             /* Program min/max/desired into CPPC regs (non-fatal on failure). */
+             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret)
+                     pr_warn("set_perf failed CPU%d (%d); using HW values\n",
+                             cpu, ret);
+
+             ret = cppc_set_auto_sel(cpu, true);
+             if (ret && ret != -EOPNOTSUPP)
+                     pr_warn("auto_sel CPU%d failed (%d); using OS mode\n",
+                             cpu, ret);
+             else if (!ret)
+                     cpu_data->perf_ctrls.auto_sel = true; +     }
+
+     if (cpu_data->perf_ctrls.auto_sel) {
+             /* Sync policy limits from HW when autonomous mode is active */
+             policy->min = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.min_perf ?:
+ caps->lowest_nonlinear_perf);
+             policy->max = cppc_perf_to_khz(caps,
+ cpu_data->perf_ctrls.max_perf ?:
+ (policy->boost_enabled ?
+ caps->highest_perf :
+ caps->nominal_perf));
+     } else {
+             /* Normal mode: governors control frequency */ +             ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); +             if (ret) {
+                     pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
+                              caps->highest_perf, cpu, ret); +                     goto out;
+             }
      }

      cppc_cpufreq_cpu_fie_init(policy);

drivers/cpufreq/cppc_cpufreq.c +8 -0
@@ -1079,10 +1180,21 @@ static int __init cppc_cpufreq_init(void)
 
   static void __exit cppc_cpufreq_exit(void)
   {
+     unsigned int cpu;
+
+     for_each_present_cpu(cpu)
+             cppc_set_auto_sel(cpu, false);
+
       cpufreq_unregister_driver(&cppc_cpufreq_driver);
       cppc_freq_invariance_exit();
   }
 
+module_param_cb(auto_sel_mode, &auto_sel_mode_ops, &auto_sel_mode,
 0444);
+MODULE_PARM_DESC(auto_sel_mode,
+              "Enable CPPC autonomous performance selection at 

boot: "
+              "performance or 1 (EPP=performance), "
+              "default_epp or 2 (preserve BIOS/firmware EPP)"); +
  module_exit(cppc_cpufreq_exit);
  MODULE_AUTHOR("Ashwin Chaugule"); MODULE_DESCRIPTION("CPUFreq driver based on the ACPI CPPC v5.0+ spec");

author reviewer
#8 lore raw
Quoted 118 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 104 lines · Sumit Gupta
Quoted 102 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 86 lines · Sumit Gupta

Hi Mario,

Quoted 70 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 66 lines · Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
   - performance (or 1): override EPP to performance preference (0x0)
   - default_epp (or 2): preserve EPP value programmed by BIOS/ firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/20260511135538.522653-1-
[email protected]/
---
  .../admin-guide/kernel-parameters.txt         |  16 +++ drivers/cpufreq/cppc_cpufreq.c                | 122 +++++++++++++
++++-

  2 files changed, 133 insertions(+), 5 deletions(-)
(quoted diff) renamed from Documentation/admin-guide/kernel-parameters.txt +0 -0

Documentation/admin-guide/kernel-parameters.txt
index 0eb64aab3685..7e4b3a8fd76f 100644

Documentation/admin-guide/kernel-parameters.txt +0 -0
@@ -1048,6 +1048,22 @@ Kernel parameters

                      policy to use. This governor must be registered in the
                      kernel before the cpufreq driver probes.

+     cppc_cpufreq.auto_sel_mode=
+                     [CPU_FREQ] Enable ACPI CPPC autonomous performance
+                     selection. When enabled, hardware automatically
adjusts
+                     CPU frequency on all CPUs based on workload demands.
+                     In Autonomous mode, Energy Performance Preference (EPP)
+                     hints guide hardware toward performance (0x0) or energy
+                     efficiency (0xff).
+                     Requires ACPI CPPC autonomous selection register
+                     support.
+                     Accepts:
+                       performance, 1: enable auto_sel + set EPP to +                                       performance (0x0) +                       default_epp, 2: enable auto_sel, preserve EPP

Quoted 8 lines
Quoted 4 lines

value
+                                       programmed by BIOS/firmware +                     Unset: cpufreq governors are used (auto_sel disabled).

Rather than unset doing nothing, have you considered having it take a midpoint like 128?  That's what we do in amd-pstate (default to balance_performance).  I think it turns into a reasonable balance.

Thanks for the suggestion.
I can add balance_performance that enables auto_sel with EPP=128 in v4.

Quoted 8 lines

On changing the driver default (no param behavior) to auto enable balance_performance, it would be good to keep the current behavior for now since cppc_cpufreq is generic across ARM64/RISC-V platforms where EPP and Autonomous Selection registers are optional.
A default change would affect existing users relying on governors.

Thank you,
Sumit Gupta

But couldn't you make the "no module parameter set" follow the behavior to only set the registers if they're available?

Quoted 7 lines
Quoted 3 lines

So the systems that support it start using it, the ones that don't it's a NOP.

Would it work to add balance_performance as a new mode in v4, and discuss changing the default separately as a follow-up?

Sure.

Quoted 9 lines
Quoted 5 lines

Runtime detection helps for unsupported platforms. But platforms which support the registers use OS governors today, and silently switching them to autonomous mode on a kernel update is a behavior change for existing users. They would also have no way to boot into sw governor.

But hopefully it should be better battery life/responsiveness for those scenarios too, right?

Yes in many cases, but if some workloads rely on specific OS governor configurations, then that would get impacted.
I will send a separate change later to seek broader consensus on enabling auto_sel as default without any param.

Thank you,
Sumit Gupta

....

#9 lore raw
Quoted 126 lines · Sumit Gupta
Quoted 124 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 104 lines · Sumit Gupta
Quoted 102 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 86 lines · Sumit Gupta

Hi Mario,

Quoted 70 lines · Mario Limonciello

External email: Use caution opening links or attachments

Quoted 66 lines · Sumit Gupta

Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable CPPC autonomous performance selection on all CPUs at system startup. When autonomous mode is enabled, the hardware automatically adjusts CPU performance based on workload demands using Energy Performance Preference (EPP) hints.

When the parameter is set:
- Configure all CPUs for autonomous operation on first init
- Use HW min/max_perf when available; otherwise initialize from caps
- Initialize desired_perf to max_perf as a starting hint
- Hardware controls frequency instead of the OS governor
- EPP behavior depends on parameter value:
   - performance (or 1): override EPP to performance preference (0x0)
   - default_epp (or 2): preserve EPP value programmed by BIOS/ firmware

The boot parameter is applied only during first policy initialization. Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch series [1] ("cpufreq: Set policy->min and max as real QoS constraints") so that the policy->min/max set in cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy() during init.

---
[1] https://lore.kernel.org/lkml/20260511135538.522653-1-
[email protected]/
---
  .../admin-guide/kernel-parameters.txt         |  16 +++ drivers/cpufreq/cppc_cpufreq.c                | 122 +++++++++++++
++++-

  2 files changed, 133 insertions(+), 5 deletions(-)
(quoted diff) renamed from Documentation/admin-guide/kernel-parameters.txt +0 -0

Documentation/admin-guide/kernel-parameters.txt
index 0eb64aab3685..7e4b3a8fd76f 100644

Documentation/admin-guide/kernel-parameters.txt +0 -0
@@ -1048,6 +1048,22 @@ Kernel parameters

                      policy to use. This governor must be registered in the
                      kernel before the cpufreq driver probes.

+     cppc_cpufreq.auto_sel_mode=
+                     [CPU_FREQ] Enable ACPI CPPC autonomous performance
+                     selection. When enabled, hardware automatically
adjusts
+                     CPU frequency on all CPUs based on workload demands.
+                     In Autonomous mode, Energy Performance Preference (EPP)
+                     hints guide hardware toward performance (0x0) or energy
+                     efficiency (0xff).
+                     Requires ACPI CPPC autonomous selection register
+                     support.
+                     Accepts:
+                       performance, 1: enable auto_sel + set EPP to +                                       performance (0x0) +                       default_epp, 2: enable auto_sel, preserve EPP

Quoted 8 lines
Quoted 4 lines

value
+                                       programmed by BIOS/firmware +                     Unset: cpufreq governors are used (auto_sel disabled).

Rather than unset doing nothing, have you considered having it take a midpoint like 128?  That's what we do in amd-pstate (default to balance_performance).  I think it turns into a reasonable balance.

Thanks for the suggestion.
I can add balance_performance that enables auto_sel with EPP=128 in v4.

Quoted 8 lines

On changing the driver default (no param behavior) to auto enable balance_performance, it would be good to keep the current behavior for now since cppc_cpufreq is generic across ARM64/RISC-V platforms where EPP and Autonomous Selection registers are optional.
A default change would affect existing users relying on governors.

Thank you,
Sumit Gupta

But couldn't you make the "no module parameter set" follow the behavior to only set the registers if they're available?

Quoted 7 lines
Quoted 3 lines

So the systems that support it start using it, the ones that don't it's a NOP.

Would it work to add balance_performance as a new mode in v4, and discuss changing the default separately as a follow-up?

Sure.

Quoted 5 lines

Runtime detection helps for unsupported platforms. But platforms which support the registers use OS governors today, and silently switching them to autonomous mode on a kernel update is a behavior change for existing users. They would also have no way to boot into sw governor.

Quoted 9 lines
Quoted 3 lines

But hopefully it should be better battery life/responsiveness for those scenarios too, right?

Yes in many cases, but if some workloads rely on specific OS governor configurations, then that would get impacted.
I will send a separate change later to seek broader consensus on enabling auto_sel as default without any param.

I suppose another option is to have a Kconfig to decide at compile time whether to turn on autonomous mode by default, so systems can avoid moving to this if they don't want to.

reviewer
#10 lore raw
In reply to Sumit Gupta

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 1052

Quoted 10 lines · Sumit Gupta
Documentation/admin-guide/kernel-parameters.txt +2 -0
index 0eb64aab3685..7e4b3a8fd76f 100644
@@ -1048,6 +1048,22 @@ Kernel parameters
 			policy to use. This governor must be registered in the
 			kernel before the cpufreq driver probes.
 
+	cppc_cpufreq.auto_sel_mode=
+			[CPU_FREQ] Enable ACPI CPPC autonomous performance

I just noticed that we should have both CPU_FREQ and CPU_IDLE added to the legend (meanings) section at the very beginning of this file, but that doesn't have to be part of this patch.

Quoted 13 lines
Documentation/admin-guide/kernel-parameters.txt +13 -0
+			selection. When enabled, hardware automatically adjusts
+			CPU frequency on all CPUs based on workload demands.
+			In Autonomous mode, Energy Performance Preference (EPP)
+			hints guide hardware toward performance (0x0) or energy
+			efficiency (0xff).
+			Requires ACPI CPPC autonomous selection register
+			support.
+			Accepts:
+			  performance, 1: enable auto_sel + set EPP to
+					  performance (0x0)
+			  default_epp, 2: enable auto_sel, preserve EPP value
+					  programmed by BIOS/firmware
+			Unset: cpufreq governors are used (auto_sel disabled).
Signature · 1 line
~Randy
author reviewer
#11 lore raw

Hi Randy,

Quoted 10 lines · Randy Dunlap
Quoted 8 lines · Sumit Gupta
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 0eb64aab3685..7e4b3a8fd76f 100644
@@ -1048,6 +1048,22 @@ Kernel parameters
  			policy to use. This governor must be registered in the
  			kernel before the cpufreq driver probes.
 
Quoted 5 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 1052

Quoted 2 lines
Documentation/admin-guide/kernel-parameters.txt +2 -0
+	cppc_cpufreq.auto_sel_mode=
+			[CPU_FREQ] Enable ACPI CPPC autonomous performance

I just noticed that we should have both CPU_FREQ and CPU_IDLE added to the legend (meanings) section at the very beginning of this file, but that doesn't have to be part of this patch.

Thanks.
Will send a separate patch adding CPU_FREQ and CPU_IDLE to the legend.

Thank you,
Sumit Gupta

Quoted 14 lines
Quoted 14 lines
Documentation/admin-guide/kernel-parameters.txt +13 -0
+			selection. When enabled, hardware automatically adjusts
+			CPU frequency on all CPUs based on workload demands.
+			In Autonomous mode, Energy Performance Preference (EPP)
+			hints guide hardware toward performance (0x0) or energy
+			efficiency (0xff).
+			Requires ACPI CPPC autonomous selection register
+			support.
+			Accepts:
+			  performance, 1: enable auto_sel + set EPP to
+					  performance (0x0)
+			  default_epp, 2: enable auto_sel, preserve EPP value
+					  programmed by BIOS/firmware
+			Unset: cpufreq governors are used (auto_sel disabled).