mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: rafael@kernel.org, viresh.kumar@linaro.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH] cpufreq: intel_pstate: Directly use stored ratios for max frequencies
Date: Thu, 18 Jan 2024 04:05:13 -0800	[thread overview]
Message-ID: <20240118120513.1018808-1-srinivas.pandruvada@linux.intel.com> (raw)

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


             reply	other threads:[~2024-01-18 12:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18 12:05 Srinivas Pandruvada [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240118120513.1018808-1-srinivas.pandruvada@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®