ACPI / cpufreq: CPPC: Add ospm_nominal_perf support
Subsystems (6)
Sumit Gupta
reviewerv10 cover ACPI / cpufreq: CPPC: Add ospm_nominal_perf support
This series adds support for the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6) to the CPPC ACPI and cpufreq drivers.
Unlike the read-only Nominal Performance register, OSPM Nominal Performance is writable and lets OSPM request a nominal level below the platform-reported nominal. The platform treats performance above this level as boost and below as throttle.
- Patch 1: adds ACPI helpers to write the register and to check that the platform supports it.
- Patch 2: adds the per-policy ospm_nominal_freq attribute in kHz. The value is kept across CPU hotplug and suspend/resume. The register cannot be read back, so a read returns the last value written.
- Patch 3: uses the OSPM nominal as the maximum frequency while boost is off. Lowering the nominal creates a boost range on a platform that has none, and boost can then be enabled.
These are patches 6-8 of v9. Patches 1-5 of v9 are queued in for 7.5, and this series applies on top of them.
v9 -> v10:
- Drop v9 patches 1-5, as they are queued for 7.5.
- Patch 1: when the register shares an access unit with Performance Limited, keep it reserved in the SystemMemory overlap validation, as it is write-only. (Sashiko)
Sumit Gupta (3):
ACPI: CPPC: Add ospm_nominal_perf support
cpufreq: CPPC: Add ospm_nominal_freq attribute
cpufreq: CPPC: Reflect the OSPM nominal in boost and limits
.../ABI/testing/sysfs-devices-system-cpu | 31 ++++ drivers/acpi/cppc_acpi.c | 56 ++++++ drivers/cpufreq/cppc_cpufreq.c | 173 +++++++++++++++++- include/acpi/cppc_acpi.h | 10 + 4 files changed, 260 insertions(+), 10 deletions(-)
v8: https://lore.kernel.org/lkml/[email protected]/
v9: https://lore.kernel.org/lkml/[email protected]/
base-commit: 22f2a52b46d52df66cf0a5efe4d22296810cbcee
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v10 1/3 ACPI: CPPC: Add ospm_nominal_perf support
Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the nominal performance level at which the platform may run. Unlike the read-only Nominal Performance register, it is writable, so OSPM can ask for a nominal level below the platform-reported one, which then becomes the boundary between boosted and throttled operation.
Add cppc_set_ospm_nominal_perf() to write the register. Per the spec, the value must lie in [Lowest Performance, Nominal Performance], which the caller is responsible for validating.
Add cppc_ospm_nominal_perf_supported() to report whether the platform implements the register as writable, since a write-only register cannot be probed by reading it. It uses the same cpc_is_writable() test as the setter, so support is never reported for a register that a write would reject, and takes cpc_desc_lock while looking the descriptor up.
Add the register to the writable set that the SystemMemory overlap validation uses, as the driver now writes it and can compete with another control sharing an access unit.
If the register shares an access unit with Performance Limited, it is not used, since a write could overwrite the status bits. The register is write-only and its readback is undefined, so keep its range reserved rather than dropping it. The validation then still rejects another field that reads or rewrites these bits.
--- drivers/acpi/cppc_acpi.c | 56 ++++++++++++++++++++++++++++++++++++++++ include/acpi/cppc_acpi.h | 10 +++++++ 2 files changed, 66 insertions(+)
drivers/acpi/cppc_acpi.c +56 -0
@@ -463,6 +463,7 @@ static bool cpc_reg_is_writable(unsigned int reg_idx)case AUTO_SEL_ENABLE :case AUTO_ACT_WINDOW :case ENERGY_PERF : +case OSPM_NOMINAL_PERF :return true;default :return false;
@@ -1192,7 +1193,19 @@ static bool cpc_disable_new_sysmem_writer(struct cpc_desc *cpc_desc,pr_warn_once ("CPU%d: ignoring optional _CPC register %u sharing CPU%d Performance Limited access unit\n" , cpc_desc->cpu_id, reg_idx, status_cpu); + +/* +* Keep a write-only range reserved. Its readback is undefined, so the +* overlap checks must still reject another field that reads these bits +* or writes them back through read-modify-write. +*/ +if (cpc_reg_is_write_only (cpc_desc, reg_idx)) { + reg->cpc_entry.read_unsupported = true; + reg->cpc_entry.write_unsupported = true; +return false; + }cpc_disable_reg (cpc_desc, reg_idx); +return true; }
@@ -3229,6 +3242,49 @@ int cppc_set_epp(int cpu, u64 epp_val) }EXPORT_SYMBOL_GPL (cppc_set_epp); +/** +* cppc_set_ospm_nominal_perf() - Write OSPM Nominal Performance register. +* @cpu: CPU on which to write register. +* @ospm_nominal_perf: Value to write to the OSPM Nominal Performance register. +* +* OSPM Nominal Performance conveys the desired nominal performance level +* at which the platform may run. Per ACPI 6.6, s8.4.6.1.2.6, the value +* must lie within [Lowest Performance, Nominal Performance] and may be +* set independently of Minimum, Maximum and Desired performance. The +* caller is responsible for validating the range. +* +* Return: 0 on success, -EOPNOTSUPP if the platform does not implement the +* register as writable, or another negative error code. +*/ +int cppc_set_ospm_nominal_perf (int cpu,u64 ospm_nominal_perf) +{ +return cppc_set_reg_val (cpu,OSPM_NOMINAL_PERF , ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL (cppc_set_ospm_nominal_perf); + +/** +* cppc_ospm_nominal_perf_supported() - Check OSPM Nominal Performance support. +* @cpu: CPU to query. +* +* The OSPM Nominal Performance register is write-only, so its value +* cannot be read back. This only reports whether the platform implements +* it as a writable register. +* +* Context: Process context. +* Return: true if the register is supported, false otherwise. +*/ +bool cppc_ospm_nominal_perf_supported (int cpu) +{ +struct cpc_desc *cpc_desc; + +guard (mutex)(&cpc_desc_lock); + cpc_desc =per_cpu (cpc_desc_ptr, cpu); + +return cpc_desc && +cpc_is_writable (&cpc_desc->cpc_regs[OSPM_NOMINAL_PERF ]); +} +EXPORT_SYMBOL_GPL (cppc_ospm_nominal_perf_supported); +/** * cppc_get_auto_act_window() - Read autonomous activity window register. * @cpu: CPU from which to read register.
include/acpi/cppc_acpi.h +10 -0
@@ -195,6 +195,8 @@ extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val);extern int cppc_get_epp_perf (int cpunum,u64 *epp_perf);extern int cppc_set_epp_perf (int cpu,struct cppc_perf_ctrls *perf_ctrls,bool enable);extern int cppc_set_epp (int cpu,u64 epp_val); +extern int cppc_set_ospm_nominal_perf (int cpu,u64 ospm_nominal_perf); +extern bool cppc_ospm_nominal_perf_supported (int cpu);extern int cppc_get_auto_act_window (int cpu,u64 *auto_act_window);extern int cppc_set_auto_act_window (int cpu,u64 auto_act_window);extern int cppc_get_auto_sel (int cpu,u64 *enable);
@@ -290,6 +292,14 @@ static inline int cppc_set_epp(int cpu, u64 epp_val) {return -EOPNOTSUPP ; } +static inline int cppc_set_ospm_nominal_perf (int cpu,u64 ospm_nominal_perf) +{ +return -EOPNOTSUPP ; +} +static inline bool cppc_ospm_nominal_perf_supported (int cpu) +{ +return false; +}static inline int cppc_get_auto_act_window (int cpu,u64 *auto_act_window) {return -EOPNOTSUPP ;
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v10 2/3 cpufreq: CPPC: Add ospm_nominal_freq attribute
In reply to Sumit GuptaOSPM Nominal Performance (ACPI 6.6, Section 8.4.6.1.2.6) lets the OS request a nominal performance level below the platform-reported one. The platform treats performance above that level as boosted and below it as throttled. A lower value moves that boundary down, so more levels count as boost.
Expose it as a per-policy cpufreq attribute in kHz, matching the unit convention of the other frequency attributes:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freq
Writes are converted with cppc_khz_to_perf() and rejected unless they fall in [Lowest Performance, Nominal Performance]. The register cannot be read back, so a read returns the last value written, or "<unset>" before the first write.
Also track the register in the OSPM-set save/restore table, so a requested value survives CPU hotplug and suspend/resume. The store handler records the request rather than init() capturing a firmware value, so the driver writes the register only once the OS has set it. CPU offline and driver unload write the platform-reported Nominal Performance to the register.
--- .../ABI/testing/sysfs-devices-system-cpu | 27 +++++ drivers/cpufreq/cppc_cpufreq.c | 101 ++++++++++++++++-- 2 files changed, 121 insertions(+), 7 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +27 -0
@@ -350,6 +350,33 @@ Description: Performance Limited This file is only present if the cppc-cpufreq driver is in use. +What: /sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freq +Date: October 2026 +Contact: [email protected] +Description: OSPM Nominal Performance (kHz) + + OSPM uses this attribute to request a nominal performance level + lower than the platform-reported nominal. The platform treats + performance above this level as boost and below as throttle. + + Write a value in kHz, between the frequencies corresponding to + Lowest Performance and Nominal Performance. + + The register cannot be read back, so a read returns the last + value written, rounded to a performance level. It returns + "<unset>" before the first write. Reads and writes fail with + -EOPNOTSUPP if the platform does not implement the register. + + Note that tasks may be migrated from one CPU to another by the + scheduler's load-balancing algorithm, and if different OSPM + Nominal Performance values are set for those CPUs (through + different cpufreq policies), that may lead to undesirable + outcomes. To avoid such issues it is better to set the same + value across all policies, or to pin every task potentially + sensitive to it to a specific CPU. + + This file is only present if the cppc-cpufreq driver is in use. + What: /sys/devices/system/cpu/cpu*/cache/index3/cache_disable_{0,1} Date: August 2008 KernelVersion: 2.6.27
drivers/cpufreq/cppc_cpufreq.c +94 -7
151 lines not on this page · raw message
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v10 3/3 cpufreq: CPPC: Reflect the OSPM nominal in boost and limits
In reply to Sumit GuptaBoost is the performance range above nominal, so lowering the OSPM Nominal Performance enlarges the boost range and drops the non-boost ceiling. Keep the policy limits consistent with the register.
Add cppc_cpufreq_effective_nominal(), which returns the OSPM Nominal Performance when set and the platform nominal otherwise. Use it for the non-boost ceiling in set_boost(), and to update the policy limits when ospm_nominal_freq is written.
The cpufreq core caps scaling_max_freq with a per-policy QoS request, boost_freq_req, that it sets to cpuinfo.max_freq and refreshes only when boost is toggled. A write to ospm_nominal_freq changes cpuinfo.max_freq without toggling boost, so cppc_cpufreq_update_nominal_limits() updates the request itself, rather than leaving scaling_max_freq at the old nominal.
When boost is enabled the ceiling is highest_perf, not the nominal, so the update is skipped. set_boost() applies the new nominal when boost is turned off.
A platform with highest_perf == nominal_perf has no boost range at boot. Lowering the OSPM nominal from sysfs can create one. The core, however, adds its boost FREQ_QOS_MAX request only at policy setup, and only if boost_supported is already set. Set boost_supported in init() when the OSPM register is supported and highest_perf > lowest_perf. Boost can then be enabled after the nominal is lowered.
--- .../ABI/testing/sysfs-devices-system-cpu | 4 ++ drivers/cpufreq/cppc_cpufreq.c | 72 ++++++++++++++++++- 2 files changed, 73 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +4 -0
@@ -362,6 +362,10 @@ Description: OSPM Nominal Performance (kHz) Write a value in kHz, between the frequencies corresponding to Lowest Performance and Nominal Performance. + While boost is disabled, cpuinfo_max_freq is set to this value + and scaling_max_freq cannot go above it. While boost is + enabled, cpuinfo_max_freq is the Highest Performance frequency. + The register cannot be read back, so a read returns the last value written, rounded to a performance level. It returns "<unset>" before the first write. Reads and writes fail with
drivers/cpufreq/cppc_cpufreq.c +69 -3
107 lines not on this page · raw message
Signature · 1 line
2.34.1