ACPI / cpufreq: CPPC: Add ospm_nominal_perf support
Subsystems (6)
Sumit Gupta
reviewerPATCH v6 1/2 ACPI: CPPC: Add ospm_nominal_perf support
In reply to Sumit GuptaExpose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions.
It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freq
The attribute is documented in Documentation/ABI/testing/sysfs-devices-system-cpu.
Writes are converted to perf via cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to the policy->cpu. The register is assumed shared across the policy->cpus.
On read, the current register value is returned, or "<unsupported>" if the platform does not implement the register.
Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table.
--- .../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++ 4 files changed, 115 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +26 -0
@@ -346,6 +346,32 @@ 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: May 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 for power and thermal decisions. + + Read returns the current value in kHz, or "<unsupported>" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + 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/acpi/cppc_acpi.c +32 -0
@@ -1685,6 +1685,38 @@ 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 or 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_get_ospm_nominal_perf() - Read OSPM Nominal Performance register. +* @cpu: CPU from which to read register. +* @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value. +* +* Return: 0 on success or negative error code. +*/ +int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return cppc_get_reg_val (cpu,OSPM_NOMINAL_PERF , ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL (cppc_get_ospm_nominal_perf); +/** * cppc_get_auto_act_window() - Read autonomous activity window register. * @cpu: CPU from which to read register.
drivers/cpufreq/cppc_cpufreq.c +47 -0
76 lines not on this page · raw message
include/acpi/cppc_acpi.h +10 -0
@@ -180,6 +180,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf);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,bool *enable);
@@ -268,6 +270,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return -EOPNOTSUPP ; +}static inline int cppc_get_auto_act_window (int cpu,u64 *auto_act_window) {return -EOPNOTSUPP ;
Signature · 1 line
2.34.1
Sumit Gupta
reviewerv6 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 for its power and thermal decisions.
Patch 1: adds the cppc_{get,set}_ospm_nominal_perf() helpers, a per-policy cpufreq sysfs attribute (ospm_nominal_freq, in kHz), and hooks the register into the OSPM-set save/restore table.
Patch 2: reflects the OSPM nominal in the cpufreq policy so that boost and the frequency limits stay consistent with the register.
This series applies on top of the series
"cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload", which provides the save/restore table that patch 1 hooks into:
https://lore.kernel.org/lkml/[email protected]/
v5[5] -> v6:
- New patch 2: reflect the OSPM nominal in the policy's boost state and frequency limits.
- Patch 1:
- write only policy->cpu instead of looping over policy->cpus with rollback. the register is treated as shared across a policy's CPUs.
- add the register to the OSPM-set save/restore table.
Sumit Gupta (2):
ACPI: CPPC: Add ospm_nominal_perf support
cpufreq: CPPC: Reflect ospm_nominal_perf in boost and limits
.../ABI/testing/sysfs-devices-system-cpu | 26 +++ drivers/acpi/cppc_acpi.c | 32 ++++ drivers/cpufreq/cppc_cpufreq.c | 166 +++++++++++++++++- include/acpi/cppc_acpi.h | 10 ++ 4 files changed, 226 insertions(+), 8 deletions(-)
v5: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/
v3: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/
v1: https://lore.kernel.org/lkml/[email protected]/
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v6 2/2 cpufreq: CPPC: Reflect ospm_nominal_perf in boost and limits
OSPM Nominal Performance lets OSPM request a nominal level below the platform-reported nominal. Since boost is the range above nominal, lowering the nominal enlarges the boost range and drops the non-boost ceiling.
cppc_cpufreq currently uses the platform nominal as the non-boost ceiling. Changing the OSPM nominal then leaves the policy limits unchanged, so the boost and non-boost ranges no longer match the register.
Reflect the OSPM nominal in the cpufreq policy so that boost and the frequency limits stay consistent with the register:
- Add cppc_cpufreq_get_effective_nominal(), which yields the OSPM Nominal Performance when set and the platform nominal otherwise.
- Use it to derive cpuinfo.max_freq for the non-boost ceiling in init() and in set_boost() while boost is disabled.
The cpufreq core includes a per-policy boost QoS request among the constraints that cap scaling_max_freq. It updates that request to match cpuinfo.max_freq, but only when boost is toggled. Writing ospm_nominal_freq changes cpuinfo.max_freq without toggling boost, so the request (boost_freq_req) is left stale and keeps scaling_max_freq at the old nominal. cppc_cpufreq_reflect_nominal() therefore updates the request directly when the nominal changes while boost is disabled.
At boot, when highest_perf == nominal_perf there is no boost range, but lowering the OSPM nominal later from sysfs can create one if highest_perf > lowest_perf. Since the core registers its boost FREQ_QOS_MAX request at policy setup only when boost_supported is already set, set boost_supported in init() when the OSPM register is supported and such a range is possible. Boost can then be enabled once the nominal is lowered.
--- drivers/cpufreq/cppc_cpufreq.c | 119 ++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 8 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +111 -8
@@ -761,11 +761,63 @@ static void cppc_cpufreq_put_cpu_data(struct cpufreq_policy *policy) policy->driver_data =NULL ; } +/** +* cppc_cpufreq_get_effective_nominal() - Get the effective nominal performance +* @policy: cpufreq policy associated with the CPU +* @nominal: Updated with the effective nominal performance +* @supported: Updated with whether OSPM Nominal Performance is supported. +* Pass NULL if not needed +* +* Use the OSPM Nominal Performance value when the register is supported and +* contains a nonzero value. Otherwise, use the platform-reported Nominal +* Performance. The resulting value is the non-boost performance ceiling. +* +* Return: 0 on success, or a negative error code if the register cannot be +* read or contains a value outside the supported performance range. +*/ +static int cppc_cpufreq_get_effective_nominal (struct cpufreq_policy *policy, +u32 *nominal,bool *supported) +{ +struct cppc_cpudata *cpu_data = policy->driver_data; +struct cppc_perf_caps *caps = &cpu_data->perf_caps; +u32 effective_nominal = caps->nominal_perf; +bool ospm_supported = false; +u64 ospm_nominal; +int ret; + + ret =cppc_get_ospm_nominal_perf (policy->cpu, &ospm_nominal); +if (ret == -EOPNOTSUPP ) + goto out; +if (ret) +return ret; + + ospm_supported = true; + +/* A zero value means OSPM has not selected a nominal level. */ +if (!ospm_nominal) + goto out; + +if (ospm_nominal < caps->lowest_perf || + ospm_nominal > caps->nominal_perf) +return -EINVAL ; + + effective_nominal = (u32 )ospm_nominal; + +out: + *nominal = effective_nominal; +if (supported) + *supported = ospm_supported; + +return 0 ; +} +static int cppc_cpufreq_cpu_init (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu;struct cppc_cpudata *cpu_data;struct cppc_perf_caps *caps; +bool ospm_supported; +u32 nominal, perf;int ret; cpu_data =cppc_cpufreq_get_cpu_data (cpu);
@@ -788,8 +840,17 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)* nonlinear perf */ policy->cpuinfo.min_freq =cppc_perf_to_khz (caps, caps->lowest_perf); - policy->cpuinfo.max_freq =cppc_perf_to_khz (caps, policy->boost_enabled ? - caps->highest_perf : caps->nominal_perf); + + ret =cppc_cpufreq_get_effective_nominal (policy, &nominal, + &ospm_supported); +if (ret) { +pr_debug ("CPU%u: failed to get effective nominal: %d\n" , + cpu, ret); + goto out; + } + + perf = policy->boost_enabled ? caps->highest_perf : nominal; + policy->cpuinfo.max_freq =cppc_perf_to_khz (caps, perf); policy->transition_delay_us =cppc_cpufreq_get_transition_delay_us (cpu); policy->shared_type = cpu_data->shared_type;
@@ -819,9 +880,13 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)/* * If 'highest_perf' is greater than 'nominal_perf', we assume CPU Boost -* is supported. +* is supported. A writable OSPM Nominal Performance register can also +* open a boost range at runtime by lowering the nominal, so assume +* boost is supported in that case too, letting the core register its +* QoS request up front. */ -if (caps->highest_perf > caps->nominal_perf) +if (caps->highest_perf > caps->nominal_perf || + (ospm_supported && caps->highest_perf > caps->lowest_perf)) policy->boost_supported = true;/* Set policy->cur to max now. The governors will adjust later. */
@@ -992,11 +1057,16 @@ static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state) {struct cppc_cpudata *cpu_data = policy->driver_data;struct cppc_perf_caps *caps = &cpu_data->perf_caps; +u32 perf = caps->highest_perf; +int ret; -if (state) - policy->cpuinfo.max_freq =cppc_perf_to_khz (caps, caps->highest_perf); -else - policy->cpuinfo.max_freq =cppc_perf_to_khz (caps, caps->nominal_perf); +if (!state) { + ret =cppc_cpufreq_get_effective_nominal (policy, &perf,NULL ); +if (ret) +return ret; + } + + policy->cpuinfo.max_freq =cppc_perf_to_khz (caps, perf);return 0 ; }
@@ -1025,6 +1095,35 @@ static ssize_t show_auto_select(struct cpufreq_policy *policy, char *buf)return sysfs_emit (buf,"%d\n" , val); } +static int cppc_cpufreq_reflect_nominal (struct cpufreq_policy *policy, +u32 nominal) +{ +struct cppc_cpudata *cpu_data = policy->driver_data; +int ret; + +/* +* While boost is disabled, the nominal is the ceiling. Set +* cpuinfo.max_freq to it and update the core's boost_freq_req to +* match. The core only syncs boost_freq_req when boost is enabled or +* disabled, so a plain nominal change must update it here. +*/ +if (!policy->boost_enabled) { + policy->cpuinfo.max_freq = +cppc_perf_to_khz (&cpu_data->perf_caps, nominal); + +if (freq_qos_request_active (&policy->boost_freq_req)) { + ret =freq_qos_update_request (&policy->boost_freq_req, + policy->cpuinfo.max_freq); +if (ret <0 ) +return ret; + } + } + +refresh_frequency_limits (policy); + +return 0 ; +} +static ssize_t store_auto_select (struct cpufreq_policy *policy,const char *buf,size_t count) {
@@ -1208,6 +1307,10 @@ static ssize_t store_ospm_nominal_freq(struct cpufreq_policy *policy,if (ret)return ret; + ret =cppc_cpufreq_reflect_nominal (policy, perf); +if (ret) +return ret; +return count; }
Signature · 1 line
2.34.1
Rafael J. Wysocki (Intel)
maintainerQuoted 22 lines · Sumit Gupta
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 for its power and thermal decisions.
Patch 1: adds the cppc_{get,set}_ospm_nominal_perf() helpers, a per-policy cpufreq sysfs attribute (
ospm_nominal_freq, in kHz), and hooks the register into the OSPM-set save/restore table.Patch 2: reflects the OSPM nominal in the cpufreq policy so that boost and the frequency limits stay consistent with the register.
This series applies on top of the series
"cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload", which provides the save/restore table that patch 1 hooks into:
https://lore.kernel.org/lkml/[email protected]/
Quoted 7 lines
v5[5] -> v6:
- New patch 2: reflect the OSPM nominal in the policy's boost state and frequency limits.
- Patch 1:
- write onlypolicy->cpuinstead of looping overpolicy->cpuswith rollback. the register is treated as shared across a policy's CPUs.
- add the register to the OSPM-set save/restore table.
Christian, Pierre, any chance to have a look at this, please?
Quoted 15 lines
Sumit Gupta (2):
ACPI: CPPC: Addospm_nominal_perfsupport
cpufreq: CPPC: Reflectospm_nominal_perfin boost and limits.../ABI/testing/sysfs-devices-system-cpu | 26 +++ drivers/acpi/cppc_acpi.c | 32 ++++ drivers/cpufreq/cppc_cpufreq.c | 166 +++++++++++++++++- include/acpi/cppc_acpi.h | 10 ++ 4 files changed, 226 insertions(+), 8 deletions(-)v5: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/
v3: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/
v1: https://lore.kernel.org/lkml/[email protected]/
Christian Loehle
maintainerRe: [PATCH v6 1/2] ACPI: CPPC: Add ospm_nominal_perf support
In reply to Sumit GuptaQuoted 103 lines · Sumit Gupta
Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions.
It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freqThe attribute is documented in
Documentation/ABI/testing/sysfs-devices-system-cpu.Writes are converted to perf via
cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to thepolicy->cpu. The register is assumed shared across thepolicy->cpus.On read, the current register value is returned, or "<unsupported>" if the platform does not implement the register.
Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table.
Signed-off-by Sumit Gupta <[email protected]>--- .../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++ 4 files changed, 115 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +26
-0@@ -346,6 +346,32 @@ 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: May 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 for power and thermal decisions. + + Read returns the current value in kHz, or "<unsupported>" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + 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.27drivers/acpi/cppc_acpi.c +21
-0@@ -1685,6 +1685,38 @@ 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 or 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_get_ospm_nominal_perf() - Read OSPM Nominal Performance register.
drivers/acpi/cppc_acpi.c int cppc_set_epp(int cpu, u64 epp_val) · line 1718
Quoted 10 lines
drivers/acpi/cppc_acpi.c +10
-0+* @cpu: CPU from which to read register. +* @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value. +* +* Return: 0 on success or negative error code. +*/ +int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return cppc_get_reg_val (cpu,OSPM_NOMINAL_PERF , ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL (cppc_get_ospm_nominal_perf);
It's a write-only register, we need to track everything in the driver.
Quoted 116 lines
drivers/acpi/cppc_acpi.c +1
-0+/** * cppc_get_auto_act_window() - Read autonomous activity window register. * @cpu: CPU from which to read register. drivers/cpufreq/cppc_cpufreq.c +47
-0@@ -37,6 +37,7 @@ enum cppc_saved_reg_id {CPPC_SAVED_AUTO_SEL ,CPPC_SAVED_EPP ,CPPC_SAVED_AUTO_ACT_WINDOW , +CPPC_SAVED_OSPM_NOMINAL_PERF , CPPC_NR_SAVED_REGS, };@@ -55,6 +56,9 @@ static const struct cppc_saved_reg cppc_saved_regs[CPPC_NR_SAVED_REGS] = { [CPPC_SAVED_AUTO_ACT_WINDOW ] = { cppc_get_auto_act_window, cppc_set_auto_act_window, }, + [CPPC_SAVED_OSPM_NOMINAL_PERF ] = { + cppc_get_ospm_nominal_perf, cppc_set_ospm_nominal_perf, + }, };/* @@ -1166,11 +1170,53 @@ static int cppc_get_perf_limited_filtered(int cpu, u64 *perf_limited)CPPC_CPUFREQ_ATTR_RW_U64 (perf_limited, cppc_get_perf_limited_filtered, cppc_set_perf_limited) +static ssize_t show_ospm_nominal_freq (struct cpufreq_policy *policy,char *buf) +{ +struct cppc_cpudata *cpu_data = policy->driver_data; +u64 perf; +int ret; + + ret =cppc_get_ospm_nominal_perf (policy->cpu, &perf); +if (ret == -EOPNOTSUPP ) +return sysfs_emit (buf,"<unsupported>\n" ); +if (ret) +return ret; + +return sysfs_emit (buf,"%u\n" , +cppc_perf_to_khz (&cpu_data->perf_caps, perf)); +} + +static ssize_t store_ospm_nominal_freq (struct cpufreq_policy *policy, +const char *buf,size_t count) +{ +struct cppc_cpudata *cpu_data = policy->driver_data; +unsigned int freq_khz; +u32 perf; +int ret; + + ret =kstrtouint (buf,0 , &freq_khz); +if (ret) +return ret; + + perf =cppc_khz_to_perf (&cpu_data->perf_caps, freq_khz); +if (perf < cpu_data->perf_caps.lowest_perf || + perf > cpu_data->perf_caps.nominal_perf) +return -EINVAL ; + +/* The register is assumed shared across the policy's CPUs. */ + ret =cppc_set_ospm_nominal_perf (policy->cpu, perf); +if (ret) +return ret; + +return count; +} +cpufreq_freq_attr_ro (freqdomain_cpus);cpufreq_freq_attr_rw (auto_select);cpufreq_freq_attr_rw (auto_act_window);cpufreq_freq_attr_rw (energy_performance_preference_val);cpufreq_freq_attr_rw (perf_limited); +cpufreq_freq_attr_rw (ospm_nominal_freq);static struct freq_attr *cppc_cpufreq_attr[] = { &freqdomain_cpus,@@ -1178,6 +1224,7 @@ static struct freq_attr *cppc_cpufreq_attr[] = { &auto_act_window, &energy_performance_preference_val, &perf_limited, + &ospm_nominal_freq, NULL, };include/acpi/cppc_acpi.h +10
-0@@ -180,6 +180,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf);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,bool *enable);@@ -268,6 +270,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return -EOPNOTSUPP ; +}static inline int cppc_get_auto_act_window (int cpu,u64 *auto_act_window) {return -EOPNOTSUPP ;
Christian Loehle
maintainerRe: [PATCH v6 1/2] ACPI: CPPC: Add ospm_nominal_perf support
Quoted 108 lines · Christian Loehle
Quoted 107 lines · Sumit Gupta
Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions.
It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freqThe attribute is documented in
Documentation/ABI/testing/sysfs-devices-system-cpu.Writes are converted to perf via
cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to thepolicy->cpu. The register is assumed shared across thepolicy->cpus.On read, the current register value is returned, or "<unsupported>" if the platform does not implement the register.
Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table.
Signed-off-by Sumit Gupta <[email protected]>--- .../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++ 4 files changed, 115 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +26
-0@@ -346,6 +346,32 @@ 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: May 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 for power and thermal decisions. + + Read returns the current value in kHz, or "<unsupported>" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + 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.27drivers/acpi/cppc_acpi.c +25
-0@@ -1685,6 +1685,38 @@ 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 or 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_get_ospm_nominal_perf() - Read OSPM Nominal Performance register. +* @cpu: CPU from which to read register. +* @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value. +* +* Return: 0 on success or negative error code.
Quoted 9 lines
drivers/acpi/cppc_acpi.c int cppc_set_epp(int cpu, u64 epp_val) · line 1718
Quoted 6 lines
drivers/acpi/cppc_acpi.c +6
-0+*/ +int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return cppc_get_reg_val (cpu,OSPM_NOMINAL_PERF , ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL (cppc_get_ospm_nominal_perf);It's a write-only register, we need to track everything in the driver.
So just reread Pierre's comments, TBH I don't see the point of ever reading it, even for sysfs reads, but I don't think reading it for cppc_cpufreq_get_effective_nominal() would be valid in any case?
Christian Loehle
maintainerRe: [PATCH v6 1/2] ACPI: CPPC: Add ospm_nominal_perf support
Quoted 119 lines · Christian Loehle
Quoted 108 lines · Christian Loehle
Quoted 107 lines · Sumit Gupta
Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions.
It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freqThe attribute is documented in
Documentation/ABI/testing/sysfs-devices-system-cpu.Writes are converted to perf via
cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to thepolicy->cpu. The register is assumed shared across thepolicy->cpus.On read, the current register value is returned, or "<unsupported>" if the platform does not implement the register.
Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table.
Signed-off-by Sumit Gupta <[email protected]>--- .../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++ 4 files changed, 115 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +26
-0@@ -346,6 +346,32 @@ 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: May 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 for power and thermal decisions. + + Read returns the current value in kHz, or "<unsupported>" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + 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.27drivers/acpi/cppc_acpi.c +25
-0@@ -1685,6 +1685,38 @@ 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 or 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_get_ospm_nominal_perf() - Read OSPM Nominal Performance register. +* @cpu: CPU from which to read register. +* @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value. +* +* Return: 0 on success or negative error code. Quoted 9 lines
drivers/acpi/cppc_acpi.c int cppc_set_epp(int cpu, u64 epp_val) · line 1718
Quoted 6 lines
drivers/acpi/cppc_acpi.c +6
-0+*/ +int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return cppc_get_reg_val (cpu,OSPM_NOMINAL_PERF , ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL (cppc_get_ospm_nominal_perf);It's a write-only register, we need to track everything in the driver.
Quoted 4 lines
So just reread Pierre's comments, TBH I don't see the point of ever reading it, even for sysfs reads, but I don't think reading it for
cppc_cpufreq_get_effective_nominal()would be valid in any case?
FWIW desired_perf was read/write up until ACPI 6.5 and only 6.6 marked it as write-only. I don't think we should be reading it either on platforms advertising 6.6.
I will clarify and send a patch.
Re: [PATCH v6 1/2] ACPI: CPPC: Add ospm_nominal_perf support
In reply to Sumit GuptaHello Sumit,
Quoted 147 lines · Sumit Gupta
Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions.
It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freqThe attribute is documented in
Documentation/ABI/testing/sysfs-devices-system-cpu.Writes are converted to perf via
cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to thepolicy->cpu. The register is assumed shared across thepolicy->cpus.On read, the current register value is returned, or "<unsupported>" if the platform does not implement the register.
Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table.
Signed-off-by Sumit Gupta <[email protected]>--- .../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++ 4 files changed, 115 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +26
-0@@ -346,6 +346,32 @@ 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: May 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 for power and thermal decisions. + + Read returns the current value in kHz, or "<unsupported>" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + 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.27drivers/acpi/cppc_acpi.c +32
-0@@ -1685,6 +1685,38 @@ 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 or 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_get_ospm_nominal_perf() - Read OSPM Nominal Performance register. +* @cpu: CPU from which to read register. +* @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value. +* +* Return: 0 on success or negative error code. +*/ +int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return cppc_get_reg_val (cpu,OSPM_NOMINAL_PERF , ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL (cppc_get_ospm_nominal_perf); +/** * cppc_get_auto_act_window() - Read autonomous activity window register. * @cpu: CPU from which to read register. drivers/cpufreq/cppc_cpufreq.c +8
-0@@ -37,6 +37,7 @@ enum cppc_saved_reg_id {CPPC_SAVED_AUTO_SEL ,CPPC_SAVED_EPP ,CPPC_SAVED_AUTO_ACT_WINDOW , +CPPC_SAVED_OSPM_NOMINAL_PERF , CPPC_NR_SAVED_REGS, };@@ -55,6 +56,9 @@ static const struct cppc_saved_reg cppc_saved_regs[CPPC_NR_SAVED_REGS] = { [CPPC_SAVED_AUTO_ACT_WINDOW ] = { cppc_get_auto_act_window, cppc_set_auto_act_window, }, + [CPPC_SAVED_OSPM_NOMINAL_PERF ] = { + cppc_get_ospm_nominal_perf, cppc_set_ospm_nominal_perf, + }, };/* @@ -1166,11 +1170,53 @@ static int cppc_get_perf_limited_filtered(int cpu, u64 *perf_limited)CPPC_CPUFREQ_ATTR_RW_U64 (perf_limited, cppc_get_perf_limited_filtered, cppc_set_perf_limited) +static ssize_t show_ospm_nominal_freq (struct cpufreq_policy *policy,char *buf) +{ +struct cppc_cpudata *cpu_data = policy->driver_data; +u64 perf;
drivers/cpufreq/cppc_cpufreq.c static int cppc_get_perf_limited_filtered(int cpu, u64 *perf_limited) · line 1186
Quoted 10 lines
drivers/cpufreq/cppc_cpufreq.c +10
-0+int ret; + + ret =cppc_get_ospm_nominal_perf (policy->cpu, &perf); +if (ret == -EOPNOTSUPP ) +return sysfs_emit (buf,"<unsupported>\n" ); +if (ret) +return ret; + +return sysfs_emit (buf,"%u\n" , +cppc_perf_to_khz (&cpu_data->perf_caps, perf));
In patch 2/2, cppc_cpufreq_get_effective_nominal() reads the OSPM Nominal into ospm_nominal via the output pointer of cppc_get_ospm_nominal_perf(policy->cpu, &ospm_nominal), then checks ospm_nominal for zero ("A zero value means OSPM has not selected a nominal level") and substitutes the platform Nominal in that case.
However, show_ospm_nominal_freq() passes the value read through the same output pointer straight into cppc_perf_to_khz() without the equivalent zero check. This looks a bit inconsistent — is it intentional, or should show() apply the same "zero means not selected" handling?
Quoted 72 lines
drivers/cpufreq/cppc_cpufreq.c +29
-0+} + +static ssize_t store_ospm_nominal_freq (struct cpufreq_policy *policy, +const char *buf,size_t count) +{ +struct cppc_cpudata *cpu_data = policy->driver_data; +unsigned int freq_khz; +u32 perf; +int ret; + + ret =kstrtouint (buf,0 , &freq_khz); +if (ret) +return ret; + + perf =cppc_khz_to_perf (&cpu_data->perf_caps, freq_khz); +if (perf < cpu_data->perf_caps.lowest_perf || + perf > cpu_data->perf_caps.nominal_perf) +return -EINVAL ; + +/* The register is assumed shared across the policy's CPUs. */ + ret =cppc_set_ospm_nominal_perf (policy->cpu, perf); +if (ret) +return ret; + +return count; +} +cpufreq_freq_attr_ro (freqdomain_cpus);cpufreq_freq_attr_rw (auto_select);cpufreq_freq_attr_rw (auto_act_window);cpufreq_freq_attr_rw (energy_performance_preference_val);cpufreq_freq_attr_rw (perf_limited); +cpufreq_freq_attr_rw (ospm_nominal_freq);static struct freq_attr *cppc_cpufreq_attr[] = { &freqdomain_cpus,@@ -1178,6 +1224,7 @@ static struct freq_attr *cppc_cpufreq_attr[] = { &auto_act_window, &energy_performance_preference_val, &perf_limited, + &ospm_nominal_freq, NULL, };include/acpi/cppc_acpi.h +10
-0@@ -180,6 +180,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf);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,bool *enable);@@ -268,6 +270,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return -EOPNOTSUPP ; +}static inline int cppc_get_auto_act_window (int cpu,u64 *auto_act_window) {return -EOPNOTSUPP ;
Signature · 2 lines
Thx and BRs, Zhongqiu Han
Sumit Gupta
reviewerRe: [PATCH v6 1/2] ACPI: CPPC: Add ospm_nominal_perf support
In reply to Christian LoehleQuoted 121 lines · Christian Loehle
External email: Use caution opening links or attachments
Quoted 117 lines · Christian Loehle
Quoted 116 lines · Christian Loehle
Quoted 103 lines · Sumit Gupta
Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions.
It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freqThe attribute is documented in
Documentation/ABI/testing/sysfs-devices-system-cpu.Writes are converted to perf via
cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to thepolicy->cpu. The register is assumed shared across thepolicy->cpus.On read, the current register value is returned, or "<unsupported>" if the platform does not implement the register.
Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table.
Signed-off-by Sumit Gupta <[email protected]>--- .../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++ 4 files changed, 115 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +26
-0@@ -346,6 +346,32 @@ 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: May 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 for power and thermal decisions. + + Read returns the current value in kHz, or "<unsupported>" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + 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.27drivers/acpi/cppc_acpi.c +21
-0@@ -1685,6 +1685,38 @@ 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 or 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_get_ospm_nominal_perf() - Read OSPM Nominal Performance register. drivers/acpi/cppc_acpi.c int cppc_set_epp(int cpu, u64 epp_val) · line 1718
Quoted 10 lines
drivers/acpi/cppc_acpi.c +10
-0+* @cpu: CPU from which to read register. +* @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value. +* +* Return: 0 on success or negative error code. +*/ +int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ +return cppc_get_reg_val (cpu,OSPM_NOMINAL_PERF , ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL (cppc_get_ospm_nominal_perf);It's a write-only register, we need to track everything in the driver.
Quoted 8 lines
Quoted 4 lines
So just reread Pierre's comments, TBH I don't see the point of ever reading it, even for sysfs reads, but I don't think reading it for
cppc_cpufreq_get_effective_nominal()would be valid in any case?FWIW
desired_perfwas read/write up until ACPI 6.5 and only 6.6 marked it as write-only. I don't think we should be reading it either on platforms advertising 6.6.
I will clarify and send a patch.
Good catch that ACPI 6.6 makes Desired Performance write-only, and thanks for the patches preventing those reads.
The same reasoning applies to OSPM Nominal Performance, so I will treat it as write-only: make ospm_nominal_freq write-only, remove show(), and drop cppc_get_ospm_nominal_perf().
Boost and policy limits will use the last value the driver successfully wrote, falling back to the platform reported Nominal Performance when nothing has been set.
On unload, I will reset it to the platform Nominal Performance only if the driver wrote it during its lifetime. Otherwise the register is left untouched, since the pre-driver value cannot be read back.
Thanks,
Sumit
Sumit Gupta
reviewerRe: [PATCH v6 1/2] ACPI: CPPC: Add ospm_nominal_perf support
In reply to Zhongqiu HanHi Zhongqiu,
Quoted 180 lines · Zhongqiu Han
External email: Use caution opening links or attachments
Hello Sumit,
Quoted 157 lines · Sumit Gupta
Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions.
It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention:
/sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freqThe attribute is documented in
Documentation/ABI/testing/sysfs-devices-system-cpu.Writes are converted to perf via
cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to thepolicy->cpu. The register is assumed shared across thepolicy->cpus.On read, the current register value is returned, or "<unsupported>" if the platform does not implement the register.
Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table.
Signed-off-by Sumit Gupta <[email protected]>---
.../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++4 files changed, 115 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +0
-0@@ -346,6 +346,32 @@ Description: Performance LimitedThis file is only present if the cppc-cpufreq driver is in use.
Documentation/ABI/testing/sysfs-devices-system-cpu +26
-0+What: /sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freq +Date: May 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 for power and thermal decisions. + + Read returns the current value in kHz, or "<unsupported>" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + 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.27drivers/acpi/cppc_acpi.c +2
-0@@ -1685,6 +1685,38 @@ 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 or negative error code.
+ */drivers/acpi/cppc_acpi.c +3
-0+int cppc_set_ospm_nominal_perf (int cpu,u64 ospm_nominal_perf) +{ + return cppc_set_reg_val(cpu, OSPM_NOMINAL_PERF,
ospm_nominal_perf);drivers/acpi/cppc_acpi.c +5
-0+} +EXPORT_SYMBOL_GPL (cppc_set_ospm_nominal_perf); + +/** +* cppc_get_ospm_nominal_perf() - Read OSPM Nominal Performance register.
+ * @cpu: CPU from which to read register.
+ * @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value.
+ *
+ * Return: 0 on success or negative error code.
+ */drivers/acpi/cppc_acpi.c +3
-0+int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ + return cppc_get_reg_val(cpu, OSPM_NOMINAL_PERF,
ospm_nominal_perf);drivers/acpi/cppc_acpi.c +3
-0+} +EXPORT_SYMBOL_GPL (cppc_get_ospm_nominal_perf); +/**
*cppc_get_auto_act_window()- Read autonomous activity window register.
* @cpu: CPU from which to read register.drivers/cpufreq/cppc_cpufreq.c +4
-0@@ -37,6 +37,7 @@ enum cppc_saved_reg_id { CPPC_SAVED_AUTO_SEL, CPPC_SAVED_EPP, CPPC_SAVED_AUTO_ACT_WINDOW, + CPPC_SAVED_OSPM_NOMINAL_PERF, CPPC_NR_SAVED_REGS, };@@ -55,6 +56,9 @@ static const struct cppc_saved_reg cppc_saved_regs[CPPC_NR_SAVED_REGS] = { [CPPC_SAVED_AUTO_ACT_WINDOW] = { cppc_get_auto_act_window, cppc_set_auto_act_window, }, + [CPPC_SAVED_OSPM_NOMINAL_PERF] = { + cppc_get_ospm_nominal_perf, cppc_set_ospm_nominal_perf, + }, };/*
drivers/cpufreq/cppc_cpufreq.c +4
-0@@ -1166,11 +1170,53 @@ static int cppc_get_perf_limited_filtered(int cpu, u64 *perf_limited) CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited_filtered, cppc_set_perf_limited) +static ssize_t show_ospm_nominal_freq (struct cpufreq_policy *policy,char *buf) +{ + struct cppc_cpudata *cpu_data = policy->driver_data; + u64 perf;drivers/cpufreq/cppc_cpufreq.c static int cppc_get_perf_limited_filtered(int · line 1188
Quoted 10 lines
drivers/cpufreq/cppc_cpufreq.c +10
-0+ int ret; + + ret = cppc_get_ospm_nominal_perf(policy->cpu, &perf); + if (ret == -EOPNOTSUPP) + return sysfs_emit(buf, "<unsupported>\n"); + if (ret) + return ret; + + return sysfs_emit(buf, "%u\n", +cppc_perf_to_khz (&cpu_data->perf_caps, perf));In patch 2/2,
cppc_cpufreq_get_effective_nominal()reads the OSPM Nominal intoospm_nominalvia the output pointer ofcppc_get_ospm_nominal_perf(policy->cpu, &ospm_nominal), then checksospm_nominalfor zero ("A zero value means OSPM has not selected a nominal level") and substitutes the platform Nominal in that case.
Quoted 5 lines
However,
show_ospm_nominal_freq()passes the value read through the same output pointer straight intocppc_perf_to_khz()without the equivalent zero check. This looks a bit inconsistent — is it intentional, or shouldshow()apply the same "zero means not selected" handling?
Thanks for pointing this out.
In v7, I will make ospm_nominal_freq as write-only and remove sysfs show() and cppc_get_ospm_nominal_perf(), eliminating this inconsistency. The effective nominal calculation will use the last successfully written value, falling back to the platform Nominal Performance if none has been written.
Thanks,
Sumit
Quoted 82 lines
Quoted 77 lines
drivers/cpufreq/cppc_cpufreq.c +28
-0+} + +static ssize_t store_ospm_nominal_freq (struct cpufreq_policy *policy, + const char *buf, size_t count) +{ + struct cppc_cpudata *cpu_data = policy->driver_data; + unsigned int freq_khz; + u32 perf; + int ret; + + ret = kstrtouint(buf, 0, &freq_khz); + if (ret) + return ret; + + perf = cppc_khz_to_perf(&cpu_data->perf_caps, freq_khz); + if (perf < cpu_data->perf_caps.lowest_perf || + perf > cpu_data->perf_caps.nominal_perf) + return -EINVAL; + + /* The register is assumed shared across the policy's CPUs. */ + ret = cppc_set_ospm_nominal_perf(policy->cpu, perf); + if (ret) + return ret; + + return count; +} + cpufreq_freq_attr_ro(freqdomain_cpus); cpufreq_freq_attr_rw(auto_select); cpufreq_freq_attr_rw(auto_act_window); cpufreq_freq_attr_rw(energy_performance_preference_val); cpufreq_freq_attr_rw(perf_limited); +cpufreq_freq_attr_rw (ospm_nominal_freq);static struct
freq_attr*cppc_cpufreq_attr[] = {&freqdomain_cpus,drivers/cpufreq/cppc_cpufreq.c +1
-0@@ -1178,6 +1224,7 @@ static struct freq_attr *cppc_cpufreq_attr[] = { &auto_act_window, &energy_performance_preference_val, &perf_limited, + &ospm_nominal_freq, NULL, };include/acpi/cppc_acpi.h +2
-0@@ -180,6 +180,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf); 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, bool *enable);include/acpi/cppc_acpi.h +8
-0@@ -268,6 +270,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 int cppc_get_ospm_nominal_perf (int cpu,u64 *ospm_nominal_perf) +{ + return -EOPNOTSUPP; +}static inline int
cppc_get_auto_act_window(int cpu, u64 *auto_act_window){
return-EOPNOTSUPP;Signature · 2 lines
Thx and BRs, Zhongqiu Han