[PATCH] cpufreq: intel_pstate: Directly use stored ratios for max frequencies

From: Srinivas Pandruvada
Date: Thu Jan 18 2024 - 07:05:26 EST


Avoid unnecessary calculation for converting frequency to performance
ratio by using a scaling factor for the maximum non turbo and turbo
frequency. Here the driver already stored performance ratios for max
non turbo and turbo frequency by reading from MSR_HWP_CAPABILITIES.
Directly use those ratios without any calculations.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>
---
drivers/cpufreq/intel_pstate.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 2ca70b0b5fdc..6bbc21ca96e0 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -2532,7 +2532,14 @@ static void intel_pstate_update_perf_limits(struct cpudata *cpu,
int freq;

freq = max_policy_perf * perf_ctl_scaling;
- max_policy_perf = DIV_ROUND_UP(freq, scaling);
+
+ if (freq == cpu->pstate.turbo_freq)
+ max_policy_perf = cpu->pstate.turbo_pstate;
+ else if (freq == cpu->pstate.max_freq)
+ max_policy_perf = cpu->pstate.max_pstate;
+ else
+ max_policy_perf = DIV_ROUND_UP(freq, scaling);
+
freq = min_policy_perf * perf_ctl_scaling;
min_policy_perf = DIV_ROUND_UP(freq, scaling);
}
--
2.40.1