Enhanced autonomous selection and improvements
Subsystems (7)
Sumit Gupta
reviewerv8 cover Enhanced autonomous selection and improvements
This patch series improves the CPPC cpufreq driver with new ACPI APIs and enhancements for Autonomous Selection (auto_select).
CPPC auto_select enables hardware-driven CPU performance scaling using Energy Performance Preference (EPP) hints. Currently, there's limited runtime control and visibility into CPPC performance registers.
The series adds cppc_get_perf() API to read performance controls, updates MIN_PERF/MAX_PERF in target callbacks using existing scaling_min/max_freq interface similar to intel_cpufreq HWP handling, and exposes perf_limited register via sysfs to detect throttling events.
The patches are grouped as below:
- Patch 1: Add cppc_get_perf() API (independent).
- Patch 2: Warn on missing mandatory DESIRED_PERF (independent).
- Patch 3: Extend cppc_set_epp_perf for FFH/SystemMemory (independent).
- Patch 4: Update cached perf_ctrls on sysfs write (independent).
- Patch 5: Update MIN_PERF/MAX_PERF in target callbacks (depends on 4).
- Patch 6-7: APIs, sysfs and doc for perf_limited (independent).
---
v7[7] -> v8:
- patch 4 (v7): Dropped min/max_perf sysfs patch.
- patch 5 (v8): New patch to update MIN/MAX_PERF in target callbacks using scaling_min/max_freq interface similar to intel_cpufreq.
- patch 1-4, 6-7 (v8): Added Reviewed-by from Pierre and Lifeng on v7.
Sumit Gupta (7):
ACPI: CPPC: Add cppc_get_perf() API to read performance controls
ACPI: CPPC: Warn on missing mandatory DESIRED_PERF register
ACPI: CPPC: Extend cppc_set_epp_perf() for FFH/SystemMemory
cpufreq: CPPC: Update cached perf_ctrls on sysfs write
cpufreq: cppc: Update MIN_PERF/MAX_PERF in target callbacks
ACPI: CPPC: add APIs and sysfs interface for perf_limited
cpufreq: CPPC: Add sysfs documentation for perf_limited
.../ABI/testing/sysfs-devices-system-cpu | 18 ++ drivers/acpi/cppc_acpi.c | 170 +++++++++++++++++- drivers/cpufreq/cppc_cpufreq.c | 83 ++++++++- include/acpi/cppc_acpi.h | 20 +++ 4 files changed, 285 insertions(+), 6 deletions(-)
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
[4] https://lore.kernel.org/lkml/[email protected]/
[5] https://lore.kernel.org/lkml/[email protected]/
[6] https://lore.kernel.org/lkml/[email protected]/
[7] https://lore.kernel.org/lkml/[email protected]/
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v8 1/7 ACPI: CPPC: Add cppc_get_perf() API to read performance controls
Add cppc_get_perf() function to read values of performance control registers including desired_perf, min_perf, max_perf, energy_perf, and auto_sel.
This provides a read interface to complement the existing cppc_set_perf() write interface for performance control registers.
Note that auto_sel is read by cppc_get_perf() but not written by cppc_set_perf() to avoid unintended mode changes during performance updates. It can be updated with existing dedicated cppc_set_auto_sel() API.
Use cppc_get_perf() in cppc_cpufreq_get_cpu_data() to initialize perf_ctrls with current hardware register values during cpufreq policy initialization.
--- drivers/acpi/cppc_acpi.c | 80 ++++++++++++++++++++++++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 6 +++ include/acpi/cppc_acpi.h | 5 +++ 3 files changed, 91 insertions(+)
drivers/acpi/cppc_acpi.c +80 -0
@@ -1739,6 +1739,86 @@ int cppc_set_enable(int cpu, bool enable) }EXPORT_SYMBOL_GPL (cppc_set_enable); +/** +* cppc_get_perf - Get a CPU's performance controls. +* @cpu: CPU for which to get performance controls. +* @perf_ctrls: ptr to cppc_perf_ctrls. See cppc_acpi.h +* +* Return: 0 for success with perf_ctrls, -ERRNO otherwise. +*/ +int cppc_get_perf (int cpu,struct cppc_perf_ctrls *perf_ctrls) +{ +struct cpc_desc *cpc_desc =per_cpu (cpc_desc_ptr, cpu); +struct cpc_register_resource *desired_perf_reg, + *min_perf_reg, *max_perf_reg, + *energy_perf_reg, *auto_sel_reg; +u64 desired_perf =0 , min =0 , max =0 , energy_perf =0 , auto_sel =0 ; +int pcc_ss_id =per_cpu (cpu_pcc_subspace_idx, cpu); +struct cppc_pcc_data *pcc_ss_data =NULL ; +int ret =0 , regs_in_pcc =0 ; + +if (!cpc_desc) { +pr_debug ("No CPC descriptor for CPU:%d\n" , cpu); +return -ENODEV ; + } + +if (!perf_ctrls) { +pr_debug ("Invalid perf_ctrls pointer\n" ); +return -EINVAL ; + } + + desired_perf_reg = &cpc_desc->cpc_regs[DESIRED_PERF ]; + min_perf_reg = &cpc_desc->cpc_regs[MIN_PERF ]; + max_perf_reg = &cpc_desc->cpc_regs[MAX_PERF ]; + energy_perf_reg = &cpc_desc->cpc_regs[ENERGY_PERF ]; + auto_sel_reg = &cpc_desc->cpc_regs[AUTO_SEL_ENABLE ]; + +/* Are any of the regs PCC ?*/ +if (CPC_IN_PCC (desired_perf_reg) ||CPC_IN_PCC (min_perf_reg) || +CPC_IN_PCC (max_perf_reg) ||CPC_IN_PCC (energy_perf_reg) || +CPC_IN_PCC (auto_sel_reg)) { +if (pcc_ss_id <0 ) { +pr_debug ("Invalid pcc_ss_id for CPU:%d\n" , cpu); +return -ENODEV ; + } + pcc_ss_data = pcc_data[pcc_ss_id]; + regs_in_pcc =1 ; +down_write (&pcc_ss_data->pcc_lock); +/* Ring doorbell once to update PCC subspace */ +if (send_pcc_cmd (pcc_ss_id,CMD_READ ) <0 ) { + ret = -EIO ; + goto out_err; + } + } + +/* Read optional elements if present */ +if (CPC_SUPPORTED (max_perf_reg)) +cpc_read (cpu, max_perf_reg, &max); + perf_ctrls->max_perf = max; + +if (CPC_SUPPORTED (min_perf_reg)) +cpc_read (cpu, min_perf_reg, &min); + perf_ctrls->min_perf = min; + +if (CPC_SUPPORTED (desired_perf_reg)) +cpc_read (cpu, desired_perf_reg, &desired_perf); + perf_ctrls->desired_perf = desired_perf; + +if (CPC_SUPPORTED (energy_perf_reg)) +cpc_read (cpu, energy_perf_reg, &energy_perf); + perf_ctrls->energy_perf = energy_perf; + +if (CPC_SUPPORTED (auto_sel_reg)) +cpc_read (cpu, auto_sel_reg, &auto_sel); + perf_ctrls->auto_sel = (bool )auto_sel; + +out_err: +if (regs_in_pcc) +up_write (&pcc_ss_data->pcc_lock); +return ret; +} +EXPORT_SYMBOL_GPL (cppc_get_perf); +/** * cppc_set_perf - Set a CPU's performance controls. * @cpu: CPU for which to set performance controls.
drivers/cpufreq/cppc_cpufreq.c +6 -0
@@ -594,6 +594,12 @@ static struct cppc_cpudata *cppc_cpufreq_get_cpu_data(unsigned int cpu) goto free_mask; } + ret =cppc_get_perf (cpu, &cpu_data->perf_ctrls); +if (ret) { +pr_debug ("Err reading CPU%d perf ctrls: ret:%d\n" , cpu, ret); + goto free_mask; + } +return cpu_data; free_mask:
include/acpi/cppc_acpi.h +5 -0
@@ -151,6 +151,7 @@ extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);extern int cppc_get_nominal_perf (int cpunum,u64 *nominal_perf);extern int cppc_get_highest_perf (int cpunum,u64 *highest_perf);extern int cppc_get_perf_ctrs (int cpu,struct cppc_perf_fb_ctrs *perf_fb_ctrs); +extern int cppc_get_perf (int cpu,struct cppc_perf_ctrls *perf_ctrls);extern int cppc_set_perf (int cpu,struct cppc_perf_ctrls *perf_ctrls);extern int cppc_set_enable (int cpu,bool enable);extern int cppc_get_perf_caps (int cpu,struct cppc_perf_caps *caps);
@@ -193,6 +194,10 @@ static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ {return -EOPNOTSUPP ; } +static inline int cppc_get_perf (int cpu,struct cppc_perf_ctrls *perf_ctrls) +{ +return -EOPNOTSUPP ; +}static inline int cppc_set_perf (int cpu,struct cppc_perf_ctrls *perf_ctrls) {return -EOPNOTSUPP ;
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v8 2/7 ACPI: CPPC: Warn on missing mandatory DESIRED_PERF register
In reply to Sumit GuptaAdd a warning during CPPC processor probe if the Desired Performance register is not supported when it should be.
As per 8.4.6.1.2.3 section of ACPI 6.6 specification,
"The Desired Performance Register is optional only when OSPM indicates support for CPPC2 in the platform-wide _OSC capabilities and the Autonomous Selection Enable field is encoded as an Integer with a value of 1."
In other words:
- In CPPC v1, DESIRED_PERF is mandatory
- In CPPC v2, it becomes optional only when AUTO_SEL_ENABLE is supported
This helps detect firmware configuration issues early during boot.
--- drivers/acpi/cppc_acpi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/acpi/cppc_acpi.c +10 -0
@@ -854,6 +854,16 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) }per_cpu (cpu_pcc_subspace_idx, pr->id) = pcc_subspace_id; +/* +* In CPPC v1, DESIRED_PERF is mandatory. In CPPC v2, it is optional +* only when AUTO_SEL_ENABLE is supported. +*/ +if (!CPC_SUPPORTED (&cpc_ptr->cpc_regs[DESIRED_PERF ]) && + (!osc_sb_cppc2_support_acked || + !CPC_SUPPORTED (&cpc_ptr->cpc_regs[AUTO_SEL_ENABLE ]))) +pr_warn ("Desired perf. register is mandatory if CPPC v2 is not supported " +"or autonomous selection is disabled\n" ); +/* * Initialize the remaining cpc_regs as unsupported. * Example: In case FW exposes CPPC v2, the below loop will initialize
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v8 3/7 ACPI: CPPC: Extend cppc_set_epp_perf() for FFH/SystemMemory
In reply to Sumit GuptaExtend cppc_set_epp_perf() to write both auto_sel and energy_perf registers when they are in FFH or SystemMemory address space.
This keeps the behavior consistent with PCC case where both registers are already updated together, but was missing for FFH/SystemMemory.
--- drivers/acpi/cppc_acpi.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/acpi/cppc_acpi.c +21 -3
@@ -1572,6 +1572,8 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable)struct cpc_register_resource *auto_sel_reg;struct cpc_desc *cpc_desc =per_cpu (cpc_desc_ptr, cpu);struct cppc_pcc_data *pcc_ss_data =NULL ; +bool autosel_ffh_sysmem; +bool epp_ffh_sysmem;int ret;if (!cpc_desc) {
@@ -1582,6 +1584,11 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable) auto_sel_reg = &cpc_desc->cpc_regs[AUTO_SEL_ENABLE ]; epp_set_reg = &cpc_desc->cpc_regs[ENERGY_PERF ]; + epp_ffh_sysmem =CPC_SUPPORTED (epp_set_reg) && + (CPC_IN_FFH (epp_set_reg) ||CPC_IN_SYSTEM_MEMORY (epp_set_reg)); + autosel_ffh_sysmem =CPC_SUPPORTED (auto_sel_reg) && + (CPC_IN_FFH (auto_sel_reg) ||CPC_IN_SYSTEM_MEMORY (auto_sel_reg)); +if (CPC_IN_PCC (epp_set_reg) ||CPC_IN_PCC (auto_sel_reg)) {if (pcc_ss_id <0 ) {pr_debug ("Invalid pcc_ss_id for CPU:%d\n" , cpu);
@@ -1607,11 +1614,22 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable) ret =send_pcc_cmd (pcc_ss_id,CMD_WRITE );up_write (&pcc_ss_data->pcc_lock); }else if (osc_cpc_flexible_adr_space_confirmed && -CPC_SUPPORTED (epp_set_reg) &&CPC_IN_FFH (epp_set_reg)) { - ret =cpc_write (cpu, epp_set_reg, perf_ctrls->energy_perf); + (epp_ffh_sysmem || autosel_ffh_sysmem)) { +if (autosel_ffh_sysmem) { + ret =cpc_write (cpu, auto_sel_reg, enable); +if (ret) +return ret; + } + +if (epp_ffh_sysmem) { + ret =cpc_write (cpu, epp_set_reg, + perf_ctrls->energy_perf); +if (ret) +return ret; + } }else { ret = -ENOTSUPP ; -pr_debug ("_CPC in PCC and _CPC in FFH are not supported\n" ); +pr_debug ("_CPC in PCC/FFH/SystemMemory are not supported\n" ); }return ret;
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v8 4/7 cpufreq: CPPC: Update cached perf_ctrls on sysfs write
In reply to Sumit GuptaUpdate the cached perf_ctrls values when writing via sysfs to keep them in sync with hardware registers:
- store_auto_select(): update perf_ctrls.auto_sel
- store_energy_performance_preference_val(): update perf_ctrls.energy_perf
This ensures consistent cached values after sysfs writes, which complements the cppc_get_perf() initialization during policy setup.
--- drivers/cpufreq/cppc_cpufreq.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +29 -2
@@ -855,6 +855,7 @@ static ssize_t show_auto_select(struct cpufreq_policy *policy, char *buf)static ssize_t store_auto_select (struct cpufreq_policy *policy,const char *buf,size_t count) { +struct cppc_cpudata *cpu_data = policy->driver_data;bool val;int ret;
@@ -866,6 +867,8 @@ static ssize_t store_auto_select(struct cpufreq_policy *policy,if (ret)return ret; + cpu_data->perf_ctrls.auto_sel = val; +return count; }
@@ -916,8 +919,32 @@ static ssize_t store_##_name(struct cpufreq_policy *policy, \CPPC_CPUFREQ_ATTR_RW_U64 (auto_act_window, cppc_get_auto_act_window, cppc_set_auto_act_window) -CPPC_CPUFREQ_ATTR_RW_U64 (energy_performance_preference_val, - cppc_get_epp_perf, cppc_set_epp) +static ssize_t +show_energy_performance_preference_val (struct cpufreq_policy *policy,char *buf) +{ +return cppc_cpufreq_sysfs_show_u64 (policy->cpu, cppc_get_epp_perf, buf); +} + +static ssize_t +store_energy_performance_preference_val (struct cpufreq_policy *policy, +const char *buf,size_t count) +{ +struct cppc_cpudata *cpu_data = policy->driver_data; +u64 val; +int ret; + + ret =kstrtou64 (buf,0 , &val); +if (ret) +return ret; + + ret =cppc_set_epp (policy->cpu, val); +if (ret) +return ret; + + cpu_data->perf_ctrls.energy_perf = val; + +return count; +}cpufreq_freq_attr_ro (freqdomain_cpus);cpufreq_freq_attr_rw (auto_select);
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v8 5/7 cpufreq: cppc: Update MIN_PERF/MAX_PERF in target callbacks
In reply to Sumit GuptaUpdate MIN_PERF and MAX_PERF registers from policy->min and policy->max in the .target() and .fast_switch() callbacks. This allows controlling performance bounds via standard scaling_min_freq and scaling_max_freq sysfs interfaces.
Similar to intel_cpufreq which updates HWP min/max limits in .target(), cppc_cpufreq now programs MIN_PERF/MAX_PERF along with DESIRED_PERF. Since MIN_PERF/MAX_PERF can be updated even when auto_sel is disabled, they are updated unconditionally.
Also program MIN_PERF/MAX_PERF in store_auto_select() when enabling autonomous selection so the platform uses correct bounds immediately.
--- drivers/cpufreq/cppc_cpufreq.c | 41 +++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-)
drivers/cpufreq/cppc_cpufreq.c +40 -1
@@ -287,6 +287,21 @@ static inline void cppc_freq_invariance_exit(void) }#endif /* CONFIG_ACPI_CPPC_CPUFREQ_FIE */ +static void cppc_cpufreq_update_perf_limits (struct cppc_cpudata *cpu_data, +struct cpufreq_policy *policy) +{ +struct cppc_perf_caps *caps = &cpu_data->perf_caps; +u32 min_perf, max_perf; + + min_perf =cppc_khz_to_perf (caps, policy->min); + max_perf =cppc_khz_to_perf (caps, policy->max); + + cpu_data->perf_ctrls.min_perf = +clamp_t (u32, min_perf, caps->lowest_perf, caps->highest_perf); + cpu_data->perf_ctrls.max_perf = +clamp_t (u32, max_perf, caps->lowest_perf, caps->highest_perf); +} +static int cppc_cpufreq_set_target (struct cpufreq_policy *policy,unsigned int target_freq,unsigned int relation)
@@ -298,6 +313,8 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, cpu_data->perf_ctrls.desired_perf =cppc_khz_to_perf (&cpu_data->perf_caps, target_freq); +cppc_cpufreq_update_perf_limits (cpu_data, policy); + freqs.old = policy->cur; freqs.new = target_freq;
@@ -322,8 +339,9 @@ static unsigned int cppc_cpufreq_fast_switch(struct cpufreq_policy *policy, desired_perf =cppc_khz_to_perf (&cpu_data->perf_caps, target_freq); cpu_data->perf_ctrls.desired_perf = desired_perf; - ret =cppc_set_perf (cpu, &cpu_data->perf_ctrls); +cppc_cpufreq_update_perf_limits (cpu_data, policy); + ret =cppc_set_perf (cpu, &cpu_data->perf_ctrls);if (ret) {pr_debug ("Failed to set target on CPU:%d. ret:%d\n" , cpu, ret);
@@ -869,6 +887,27 @@ static ssize_t store_auto_select(struct cpufreq_policy *policy, cpu_data->perf_ctrls.auto_sel = val; +if (val) { +u32 old_min_perf = cpu_data->perf_ctrls.min_perf; +u32 old_max_perf = cpu_data->perf_ctrls.max_perf; + +/* +* When enabling autonomous selection, program MIN_PERF and +* MAX_PERF from current policy limits so that the platform +* uses the correct performance bounds immediately. +*/ +cppc_cpufreq_update_perf_limits (cpu_data, policy); + + ret =cppc_set_perf (policy->cpu, &cpu_data->perf_ctrls); +if (ret) { + cpu_data->perf_ctrls.min_perf = old_min_perf; + cpu_data->perf_ctrls.max_perf = old_max_perf; +cppc_set_auto_sel (policy->cpu, false); + cpu_data->perf_ctrls.auto_sel = false; +return ret; + } + } +return count; }
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v8 6/7 ACPI: CPPC: add APIs and sysfs interface for perf_limited
In reply to Sumit GuptaAdd sysfs interface to read/write the Performance Limited register.
The Performance Limited register indicates to the OS that an unpredictable event (like thermal throttling) has limited processor performance. It contains two sticky bits set by the platform:
- Bit 0 (Desired_Excursion): Set when delivered performance is constrained below desired performance. Not used when Autonomous Selection is enabled.
- Bit 1 (Minimum_Excursion): Set when delivered performance is constrained below minimum performance.
These bits remain set until OSPM explicitly clears them. The write operation accepts a bitmask of bits to clear:
- Write 0x1 to clear bit 0
- Write 0x2 to clear bit 1
- Write 0x3 to clear both bits
This enables users to detect if platform throttling impacted a workload. Users clear the register before execution, run the workload, then check afterward - if set, hardware throttling occurred during that time window.
The interface is exposed as:
/sys/devices/system/cpu/cpuX/cpufreq/perf_limited
--- drivers/acpi/cppc_acpi.c | 56 ++++++++++++++++++++++++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 5 +++ include/acpi/cppc_acpi.h | 15 +++++++++ 3 files changed, 76 insertions(+)
drivers/acpi/cppc_acpi.c +56 -0
@@ -1979,6 +1979,62 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) }EXPORT_SYMBOL_GPL (cppc_set_perf); +/** +* cppc_get_perf_limited - Get the Performance Limited register value. +* @cpu: CPU from which to get Performance Limited register. +* @perf_limited: Pointer to store the Performance Limited value. +* +* The returned value contains sticky status bits indicating platform-imposed +* performance limitations. +* +* Return: 0 for success, -EIO on failure, -EOPNOTSUPP if not supported. +*/ +int cppc_get_perf_limited (int cpu,u64 *perf_limited) +{ +return cppc_get_reg_val (cpu,PERF_LIMITED , perf_limited); +} +EXPORT_SYMBOL_GPL (cppc_get_perf_limited); + +/** +* cppc_set_perf_limited() - Clear bits in the Performance Limited register. +* @cpu: CPU on which to write register. +* @bits_to_clear: Bitmask of bits to clear in the perf_limited register. +* +* The Performance Limited register contains two sticky bits set by platform: +* - Bit 0 (Desired_Excursion): Set when delivered performance is constrained +* below desired performance. Not used when Autonomous Selection is enabled. +* - Bit 1 (Minimum_Excursion): Set when delivered performance is constrained +* below minimum performance. +* +* These bits are sticky and remain set until OSPM explicitly clears them. +* This function only allows clearing bits (the platform sets them). +* +* Return: 0 for success, -EINVAL for invalid bits, -EIO on register +* access failure, -EOPNOTSUPP if not supported. +*/ +int cppc_set_perf_limited (int cpu,u64 bits_to_clear) +{ +u64 current_val, new_val; +int ret; + +/* Only bits 0 and 1 are valid */ +if (bits_to_clear & ~CPPC_PERF_LIMITED_MASK ) +return -EINVAL ; + +if (!bits_to_clear) +return 0 ; + + ret =cppc_get_perf_limited (cpu, ¤t_val); +if (ret) +return ret; + +/* Clear the specified bits */ + new_val = current_val & ~bits_to_clear; + +return cppc_set_reg_val (cpu,PERF_LIMITED , new_val); +} +EXPORT_SYMBOL_GPL (cppc_set_perf_limited); +/** * cppc_get_transition_latency - returns frequency transition latency in ns * @cpu_num: CPU number for per_cpu().
drivers/cpufreq/cppc_cpufreq.c +5 -0
@@ -985,16 +985,21 @@ store_energy_performance_preference_val(struct cpufreq_policy *policy,return count; } +CPPC_CPUFREQ_ATTR_RW_U64 (perf_limited, cppc_get_perf_limited, + cppc_set_perf_limited) +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);static struct freq_attr *cppc_cpufreq_attr[] = { &freqdomain_cpus, &auto_select, &auto_act_window, &energy_performance_preference_val, + &perf_limited,NULL , };
include/acpi/cppc_acpi.h +15 -0
@@ -42,6 +42,11 @@#define CPPC_EPP_PERFORMANCE_PREF 0x00#define CPPC_EPP_ENERGY_EFFICIENCY_PREF 0xFF +#define CPPC_PERF_LIMITED_DESIRED_EXCURSION BIT(0) +#define CPPC_PERF_LIMITED_MINIMUM_EXCURSION BIT(1) +#define CPPC_PERF_LIMITED_MASK (CPPC_PERF_LIMITED_DESIRED_EXCURSION | \ + CPPC_PERF_LIMITED_MINIMUM_EXCURSION) +/* Each register has the folowing format. */ struct cpc_reg {u8 descriptor;
@@ -174,6 +179,8 @@ 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);extern int cppc_set_auto_sel (int cpu,bool enable); +extern int cppc_get_perf_limited (int cpu,u64 *perf_limited); +extern int cppc_set_perf_limited (int cpu,u64 bits_to_clear);extern int amd_get_highest_perf (unsigned int cpu,u32 *highest_perf);extern int amd_get_boost_ratio_numerator (unsigned int cpu,u64 *numerator);extern int amd_detect_prefcore (bool *detected);
@@ -270,6 +277,14 @@ static inline int cppc_set_auto_sel(int cpu, bool enable) {return -EOPNOTSUPP ; } +static inline int cppc_get_perf_limited (int cpu,u64 *perf_limited) +{ +return -EOPNOTSUPP ; +} +static inline int cppc_set_perf_limited (int cpu,u64 bits_to_clear) +{ +return -EOPNOTSUPP ; +}static inline int amd_get_highest_perf (unsigned int cpu,u32 *highest_perf) {return -ENODEV ;
Signature · 1 line
2.34.1
Sumit Gupta
reviewerPATCH v8 7/7 cpufreq: CPPC: Add sysfs documentation for perf_limited
In reply to Sumit GuptaAdd ABI documentation for the Performance Limited Register sysfs interface in the cppc_cpufreq driver.
--- .../ABI/testing/sysfs-devices-system-cpu | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +18 -0
@@ -327,6 +327,24 @@ Description: Energy performance preference This file is only present if the cppc-cpufreq driver is in use. +What: /sys/devices/system/cpu/cpuX/cpufreq/perf_limited +Date: February 2026 +Contact: [email protected] +Description: Performance Limited + + Read to check if platform throttling (thermal/power/current + limits) caused delivered performance to fall below the + requested level. A non-zero value indicates throttling occurred. + + Write the bitmask of bits to clear: + + - 0x1 = clear bit 0 (desired performance excursion) + - 0x2 = clear bit 1 (minimum performance excursion) + - 0x3 = clear both bits + + The platform sets these bits; OSPM can only clear them. + + 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
Signature · 1 line
2.34.1
Sumit Gupta
reviewerQuoted 13 lines
This patch series improves the CPPC cpufreq driver with new ACPI APIs and enhancements for Autonomous Selection (
auto_select).CPPC
auto_selectenables hardware-driven CPU performance scaling using Energy Performance Preference (EPP) hints. Currently, there's limited runtime control and visibility into CPPC performance registers.The series adds
cppc_get_perf()API to read performance controls, updates MIN_PERF/MAX_PERF in target callbacks using existing scaling_min/max_freq interface similar tointel_cpufreqHWP handling, and exposesperf_limitedregister via sysfs to detect throttling events.
Quoted 7 lines
The patches are grouped as below:
- Patch 1: Addcppc_get_perf()API (independent).
- Patch 2: Warn on missing mandatoryDESIRED_PERF(independent).
- Patch 3: Extendcppc_set_epp_perffor FFH/SystemMemory (independent).
- Patch 4: Update cachedperf_ctrlson sysfs write (independent).
- Patch 5: Update MIN_PERF/MAX_PERF in target callbacks (depends on 4).
- Patch 6-7: APIs, sysfs and doc forperf_limited(independent).
Gentle ping.
If there are no further comments, could this be considered for merging.
Thank you,
Sumit Gupta
Quoted 30 lines
---
v7[7] -> v8:
- patch 4 (v7): Dropped min/max_perf sysfs patch.
- patch 5 (v8): New patch to update MIN/MAX_PERF in target callbacks using scaling_min/max_freq interface similar tointel_cpufreq.
- patch 1-4, 6-7 (v8): Added Reviewed-by from Pierre and Lifeng on v7.Sumit Gupta (7):
ACPI: CPPC: Addcppc_get_perf()API to read performance controls
ACPI: CPPC: Warn on missing mandatoryDESIRED_PERFregister
ACPI: CPPC: Extendcppc_set_epp_perf()for FFH/SystemMemory
cpufreq: CPPC: Update cachedperf_ctrlson sysfs write
cpufreq: cppc: Update MIN_PERF/MAX_PERF in target callbacks
ACPI: CPPC: add APIs and sysfs interface forperf_limited
cpufreq: CPPC: Add sysfs documentation forperf_limited.../ABI/testing/sysfs-devices-system-cpu | 18 ++ drivers/acpi/cppc_acpi.c | 170 +++++++++++++++++- drivers/cpufreq/cppc_cpufreq.c | 83 ++++++++- include/acpi/cppc_acpi.h | 20 +++ 4 files changed, 285 insertions(+), 6 deletions(-)[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
[4] https://lore.kernel.org/lkml/[email protected]/
[5] https://lore.kernel.org/lkml/[email protected]/
[6] https://lore.kernel.org/lkml/[email protected]/
[7] https://lore.kernel.org/lkml/[email protected]/
Quoted 22 lines · Sumit Gupta
Quoted 14 lines
This patch series improves the CPPC cpufreq driver with new ACPI APIs and enhancements for Autonomous Selection (
auto_select).CPPC
auto_selectenables hardware-driven CPU performance scaling using Energy Performance Preference (EPP) hints. Currently, there's limited runtime control and visibility into CPPC performance registers.The series adds
cppc_get_perf()API to read performance controls, updates MIN_PERF/MAX_PERF in target callbacks using existing scaling_min/max_freq interface similar tointel_cpufreqHWP handling, and exposesperf_limitedregister via sysfs to detect throttling events.Quoted 7 lines
The patches are grouped as below:
- Patch 1: Addcppc_get_perf()API (independent).
- Patch 2: Warn on missing mandatoryDESIRED_PERF(independent).
- Patch 3: Extendcppc_set_epp_perffor FFH/SystemMemory (independent).
- Patch 4: Update cachedperf_ctrlson sysfs write (independent).
- Patch 5: Update MIN_PERF/MAX_PERF in target callbacks (depends on 4).
- Patch 6-7: APIs, sysfs and doc forperf_limited(independent).
Quoted 3 lines
Gentle ping.
If there are no further comments, could this be considered for merging.
Applied as 7.1 material, thanks!
That said, wouldn't it be prudent to check cpc_read() return values everywhere?
They are handled quite inconsistently and this series doesn't improve that.
Sumit Gupta
reviewerQuoted 24 lines · Rafael J. Wysocki
External email: Use caution opening links or attachments
Quoted 20 lines · Sumit Gupta
Quoted 20 lines
This patch series improves the CPPC cpufreq driver with new ACPI APIs and enhancements for Autonomous Selection (
auto_select).CPPC
auto_selectenables hardware-driven CPU performance scaling using Energy Performance Preference (EPP) hints. Currently, there's limited runtime control and visibility into CPPC performance registers.The series adds
cppc_get_perf()API to read performance controls, updates MIN_PERF/MAX_PERF in target callbacks using existing scaling_min/max_freq interface similar tointel_cpufreqHWP handling, and exposesperf_limitedregister via sysfs to detect throttling events.The patches are grouped as below:
- Patch 1: Addcppc_get_perf()API (independent).
- Patch 2: Warn on missing mandatoryDESIRED_PERF(independent).
- Patch 3: Extendcppc_set_epp_perffor FFH/SystemMemory (independent).
- Patch 4: Update cachedperf_ctrlson sysfs write (independent).
- Patch 5: Update MIN_PERF/MAX_PERF in target callbacks (depends on 4).
- Patch 6-7: APIs, sysfs and doc forperf_limited(independent).
Quoted 4 lines
Quoted 3 lines
Gentle ping.
If there are no further comments, could this be considered for merging.
Applied as 7.1 material, thanks!
Thank you for applying the series.
Quoted 2 lines
That said, wouldn't it be prudent to check
cpc_read()return values everywhere? They are handled quite inconsistently and this series doesn't improve that.
I will send a follow-up patch to address this.
Thank you
Sumit Gupta