]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq: cppc: mask Desired_Excursion when autonomous selection is enabled
authorXueqin Luo <luoxueqin@kylinos.cn>
Fri, 15 May 2026 02:42:42 +0000 (10:42 +0800)
committerViresh Kumar <viresh.kumar@linaro.org>
Wed, 20 May 2026 08:12:52 +0000 (13:42 +0530)
According to the ACPI 6.6 specification, the Desired_Excursion field is not
utilized when autonomous selection is enabled. In this mode, the bit is
architecturally ignored and does not carry meaningful information.

Currently, the kernel exposes the raw Performance Limited register
value to userspace through the cpufreq sysfs interface. This may lead to
misinterpretation, as userspace may assume Desired_Excursion is valid
even when autonomous selection is active.

To provide a stable and semantically correct ABI, mask out the
Desired_Excursion bit when autonomous selection is enabled, so that
userspace does not observe undefined or misleading values.

Writes are left unchanged, as the field is architecturally ignored in
this mode and write attempts are harmless.

Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sumit Gupta <sumitg@nvidia.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/cppc_cpufreq.c

index 7e7f9dfb7a24c3bcb865d6b60225d41e086cdd35..bf5175f7551c7191614059cf7600e986880c09d9 100644 (file)
@@ -982,7 +982,34 @@ store_energy_performance_preference_val(struct cpufreq_policy *policy,
        return count;
 }
 
-CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited,
+static int cppc_get_perf_limited_filtered(int cpu, u64 *perf_limited)
+{
+       struct cpufreq_policy *policy;
+       struct cppc_cpudata *cpu_data;
+       int ret;
+
+       ret = cppc_get_perf_limited(cpu, perf_limited);
+       if (ret)
+               return ret;
+
+       policy = cpufreq_cpu_get_raw(cpu);
+       if (!policy)
+               return -EINVAL;
+
+       cpu_data = policy->driver_data;
+
+       /*
+        * Desired Excursion is ignored when autonomous selection is
+        * enabled. Clear the bit to avoid exposing meaningless state
+        * to userspace.
+        */
+       if (cpu_data && cpu_data->perf_ctrls.auto_sel)
+               *perf_limited &= ~CPPC_PERF_LIMITED_DESIRED_EXCURSION;
+
+       return 0;
+}
+
+CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited_filtered,
                         cppc_set_perf_limited)
 
 cpufreq_freq_attr_ro(freqdomain_cpus);