]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools/power x86_energy_perf_policy: Prefer driver HWP limits
authorLen Brown <len.brown@intel.com>
Fri, 19 Sep 2025 19:56:46 +0000 (15:56 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:36:54 +0000 (15:36 -0500)
[ Upstream commit 2734fdbc9bb8a3aeb309ba0d62212d7f53f30bc7 ]

When we are successful in using cpufreq min/max limits,
skip setting the raw MSR limits entirely.

This is necessary to avoid undoing any modification that
the cpufreq driver makes to our sysfs request.

eg. intel_pstate may take our request for a limit
that is valid according to HWP.CAP.MIN/MAX and clip
it to be within the range available in PLATFORM_INFO.

Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c

index 0bda8e3ae7f77aeb20f3b31ca38db89928c9799d..891738116c8b2973606457eaade563b14c60ce6c 100644 (file)
@@ -62,6 +62,7 @@ unsigned char turbo_update_value;
 unsigned char update_hwp_epp;
 unsigned char update_hwp_min;
 unsigned char update_hwp_max;
+unsigned char hwp_limits_done_via_sysfs;
 unsigned char update_hwp_desired;
 unsigned char update_hwp_window;
 unsigned char update_hwp_use_pkg;
@@ -951,8 +952,10 @@ int ratio_2_sysfs_khz(int ratio)
 }
 /*
  * If HWP is enabled and cpufreq sysfs attribtes are present,
- * then update sysfs, so that it will not become
- * stale when we write to MSRs.
+ * then update via sysfs. The intel_pstate driver may modify (clip)
+ * this request, say, when HWP_CAP is outside of PLATFORM_INFO limits,
+ * and the driver-chosen value takes precidence.
+ *
  * (intel_pstate's max_perf_pct and min_perf_pct will follow cpufreq,
  *  so we don't have to touch that.)
  */
@@ -1007,6 +1010,8 @@ int update_sysfs(int cpu)
        if (update_hwp_max)
                update_cpufreq_scaling_freq(1, cpu, req_update.hwp_max);
 
+       hwp_limits_done_via_sysfs = 1;
+
        return 0;
 }
 
@@ -1085,10 +1090,10 @@ int update_hwp_request(int cpu)
        if (debug)
                print_hwp_request(cpu, &req, "old: ");
 
-       if (update_hwp_min)
+       if (update_hwp_min && !hwp_limits_done_via_sysfs)
                req.hwp_min = req_update.hwp_min;
 
-       if (update_hwp_max)
+       if (update_hwp_max && !hwp_limits_done_via_sysfs)
                req.hwp_max = req_update.hwp_max;
 
        if (update_hwp_desired)