public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: intel_pstate: Directly use stored ratios for max frequencies
@ 2024-01-18 12:05 Srinivas Pandruvada
  2024-01-22 10:53 ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: Srinivas Pandruvada @ 2024-01-18 12:05 UTC (permalink / raw)
  To: rafael, viresh.kumar; +Cc: linux-pm, linux-kernel, Srinivas Pandruvada

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@linux.intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-22 12:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18 12:05 [PATCH] cpufreq: intel_pstate: Directly use stored ratios for max frequencies Srinivas Pandruvada
2024-01-22 10:53 ` Rafael J. Wysocki
2024-01-22 11:35   ` srinivas pandruvada
2024-01-22 11:46     ` Rafael J. Wysocki
2024-01-22 12:45       ` Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox