Skip to contentSkip to conversation

cpufreq: CPPC: add autonomous mode boot parameter support

PATCH Superseded Sumit Gupta 3 participants 8 messages May 27 – Jun 23

Subsystems (7)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Sumit Gupta

author reviewer
#0 lore raw

v4 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 three modes:
- performance (or 1): override EPP to performance (0x0)
- balance_performance (or 2): override EPP to balance_performance (0x80)
- default_epp (or 3): preserve EPP value programmed by
BIOS/firmware

Patch 2 depends on Pierre's series [4] ("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().

v3[3] -> v4:
- Add 'balance_performance' mode which sets EPP to 0x80.
- Add CPPC_EPP_BALANCE_PERFORMANCE_PREF (0x80) constant in cppc_acpi.h.
- Clean up EPP mode selection with switch + boolean flag in cpu_init.
- Use local variable for kp->arg in auto_sel_mode_set/get to avoid repeated casts.

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         |  20 +++
 drivers/cpufreq/cppc_cpufreq.c                | 154 +++++++++++++++++-
 include/acpi/cppc_acpi.h                      |   1 +
 3 files changed, 170 insertions(+), 5 deletions(-)

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

Signature · 1 line
2.34.1
author reviewer
#1 lore raw

PATCH v4 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 64387b6587cc..7db33761e899 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 v4 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 (0x0)
- balance_performance (or 2): override EPP to balance_performance

                                (0x80)

- default_epp (or 3): 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         |  20 +++
 drivers/cpufreq/cppc_cpufreq.c                | 146 +++++++++++++++++-
 include/acpi/cppc_acpi.h                      |   1 +
 3 files changed, 162 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +20 -0
index 6f0910abdd25..5182905719ed 100644
@@ -1047,6 +1047,26 @@ 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)
+			  balance_performance, 2:
+				  enable auto_sel + set EPP to
+				  balance_performance (0x80)
+			  default_epp, 3:
+				  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 +141 -5

175 lines not on this page · raw message

include/acpi/cppc_acpi.h +1 -0
index dc70a8215a3e..14c6d5d0ac12 100644
@@ -42,6 +42,7 @@
 #define CPPC_AUTO_ACT_WINDOW_SIG_CARRY_THRESH 129
 
 #define CPPC_EPP_PERFORMANCE_PREF		0x00
+#define CPPC_EPP_BALANCE_PERFORMANCE_PREF	0x80
 #define CPPC_EPP_ENERGY_EFFICIENCY_PREF		0xFF
 
 #define CPPC_PERF_LIMITED_DESIRED_EXCURSION	BIT(0)
Signature · 1 line
2.34.1
author reviewer
#3 lore raw
In reply to Sumit Gupta
Quoted 37 lines · Sumit Gupta

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 three modes:
- performance (or 1): override EPP to performance (0x0)
- balance_performance (or 2): override EPP to balance_performance (0x80)
- default_epp (or 3): preserve EPP value programmed by
BIOS/firmware

Patch 2 depends on Pierre's series [4] ("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().

v3[3] -> v4:
- Add 'balance_performance' mode which sets EPP to 0x80.
- Add CPPC_EPP_BALANCE_PERFORMANCE_PREF (0x80) constant in cppc_acpi.h.
- Clean up EPP mode selection with switch + boolean flag in cpu_init.
- Use local variable for kp->arg in auto_sel_mode_set/get to avoid repeated casts.

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         |  20 +++
  drivers/cpufreq/cppc_cpufreq.c                | 154 +++++++++++++++++-
  include/acpi/cppc_acpi.h                      |   1 +
  3 files changed, 170 insertions(+), 5 deletions(-)
Quoted 5 lines

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

Gentle ping on this series.

The dependency it was waiting on, the "cpufreq: Set policy->min and max as real QoS constraints" series, is now in linux-pm (linux-next). I rebased on top and verified autonomous mode works as expected, and it applies cleanly on the current linux-next.

The [1] reference in patch 2/2 points to v2 of that series; the merged version is v3 [2].

If there are no further comments, please consider acking and queuing this for the next cycle.

Thanks for your time.

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

Regards,
Sumit

maintainer
#4 lore raw
Quoted 10 lines · Sumit Gupta

The dependency it was waiting on, the "cpufreq: Set policy->min and max as real QoS constraints" series, is now in linux-pm (linux-next). I rebased on top and verified autonomous mode works as expected, and it applies cleanly on the current linux-next.

The [1] reference in patch 2/2 points to v2 of that series; the merged version is v3 [2].

If there are no further comments, please consider acking and queuing this for the next cycle.

I was waiting for CPPC reviewers to provide some feedback.i

Jie / Lifeng / Pierre ?

Signature · 1 line
viresh
#5 lore raw
Quoted 6 lines · Viresh Kumar
Quoted 5 lines · Sumit Gupta

The dependency it was waiting on, the "cpufreq: Set policy->min and max as real QoS constraints" series, is now in linux-pm (linux-next). I rebased on top and verified autonomous mode works as expected, and it applies cleanly on the current linux-next.

Quoted 9 lines
Quoted 5 lines

The [1] reference in patch 2/2 points to v2 of that series; the merged version is v3 [2].

If there are no further comments, please consider acking and queuing this for the next cycle.

I was waiting for CPPC reviewers to provide some feedback.i

Jie / Lifeng / Pierre ?

I think the patchset has the same issue described at:

https://lore.kernel.org/all/[email protected]/

I don't know if this is important to other persons,
but IMO it would be preferable to have a solution to this issue before adding more functionalities relying on registers that are left in an unknown state.

If there are any other opinion ?

author reviewer
#6 lore raw
Quoted 21 lines · Pierre Gondois

External email: Use caution opening links or attachments

Quoted 6 lines · Viresh Kumar
Quoted 5 lines · Sumit Gupta

The dependency it was waiting on, the "cpufreq: Set policy->min and max as real QoS constraints" series, is now in linux-pm (linux-next). I rebased on top and verified autonomous mode works as expected, and it applies cleanly on the current linux-next.

Quoted 9 lines
Quoted 5 lines

The [1] reference in patch 2/2 points to v2 of that series; the merged version is v3 [2].

If there are no further comments, please consider acking and queuing this for the next cycle.

I was waiting for CPPC reviewers to provide some feedback.i

Jie / Lifeng / Pierre ?

I think the patchset has the same issue described at:

Quoted 9 lines

https://lore.kernel.org/all/[email protected]/

I don't know if this is important to other persons,
but IMO it would be preferable to have a solution to this issue before adding more functionalities relying on registers that are left in an unknown state.

If there are any other opinion ?

The concern is valid, but this isn't a new gap. The registers the boot parameter programs are already writable via existing sysfs:
 - auto_sel via auto_select
 - EPP via energy_performance_preference_val
So userspace can already leave these in a non-default state across unload / CPU hotplug in mainline. The boot parameter just sets the same registers at boot via the same paths.

I am already working on the save/restore change we discussed on the ospm_nominal_perf thread, as a dedicated follow-up grouping all OSPM-set registers (ospm_nominal_perf, auto_sel, EPP) together. I think doing it once uniformly is cleaner.

Both features are already under review, so my preference is to take them first and add the save/restore on top, rather than merging it first and respinning both features under it. Either order works for me if you and the maintainers prefer infra-first.

Thanks,
Sumit

author reviewer
#7 lore raw
Quoted 47 lines · Sumit Gupta
Quoted 24 lines · Pierre Gondois

External email: Use caution opening links or attachments

Quoted 6 lines · Viresh Kumar
Quoted 5 lines · Sumit Gupta

The dependency it was waiting on, the "cpufreq: Set policy->min and max as real QoS constraints" series, is now in linux-pm (linux-next). I rebased on top and verified autonomous mode works as expected, and it applies cleanly on the current linux-next.

Quoted 9 lines
Quoted 5 lines

The [1] reference in patch 2/2 points to v2 of that series; the merged version is v3 [2].

If there are no further comments, please consider acking and queuing this for the next cycle.

I was waiting for CPPC reviewers to provide some feedback.i

Jie / Lifeng / Pierre ?

I think the patchset has the same issue described at:

https://lore.kernel.org/all/[email protected]/

Quoted 7 lines

I don't know if this is important to other persons,
but IMO it would be preferable to have a solution to this issue before adding more functionalities relying on registers that are left in an unknown state.

If there are any other opinion ?

The concern is valid, but this isn't a new gap. The registers the boot parameter programs are already writable via existing sysfs:
 - auto_sel via auto_select
 - EPP via energy_performance_preference_val
So userspace can already leave these in a non-default state across unload / CPU hotplug in mainline. The boot parameter just sets the same registers at boot via the same paths.

I am already working on the save/restore change we discussed on the ospm_nominal_perf thread, as a dedicated follow-up grouping all OSPM-set registers (ospm_nominal_perf, auto_sel, EPP) together. I think doing it once uniformly is cleaner.

Quoted 9 lines

Both features are already under review, so my preference is to take them first and add the save/restore on top, rather than merging it first and respinning both features under it. Either order works for me if you and the maintainers prefer infra-first.

Thanks,
Sumit

I have sent v5 of the autonomous mode series [1] with a small fix.

Also posted patch [3] to preserve OSPM set regs across hotplug/unload. It applies on top of [1] & [2] (both not yet merged).

[1]
  [PATCH v5 0/2] cpufreq: CPPC: add autonomous mode boot parameter support
https://lore.kernel.org/lkml/[email protected]/

[2]
  [PATCH v5] ACPI: CPPC: Add ospm_nominal_perf support
https://lore.kernel.org/lkml/[email protected]/

[3]
  [PATCH] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload
https://lore.kernel.org/lkml/[email protected]/

Thanks,
Sumit