Linux Power Management development
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>
Cc: <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-pm@vger.kernel.org>,
	K Prateek Nayak <kprateek.nayak@amd.com>, <x86@kernel.org>,
	Vishal Badole <Vishal.Badole@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH 3/3] cpufreq/amd-pstate: Get Highest Freq for a CPU
Date: Mon, 31 Aug 2026 14:44:28 -0500	[thread overview]
Message-ID: <20260831194428.2287055-4-mario.limonciello@amd.com> (raw)
In-Reply-To: <20260831194428.2287055-1-mario.limonciello@amd.com>

If the highest frequency is known for a CPU, use this instead of
trying to calculate by linear interpolation.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 9fb1d7150c356..a71f82c93c345 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1107,6 +1107,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
 	u32 min_freq, max_freq, nominal_freq, lowest_nonlinear_freq;
 	struct cppc_perf_caps cppc_perf;
 	union perf_cached perf;
+	int max_frequency;
 	int ret;
 
 	ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
@@ -1131,8 +1132,13 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
 
 	WRITE_ONCE(cpudata->nominal_freq, nominal_freq);
 
+	/* max freq came from BIOS or quirk */
+	max_frequency = amd_get_max_frequency(cpudata->cpu);
+	if (max_frequency > 0)
+		max_freq = max_frequency * 1000;
 	/* max_freq is calculated according to (nominal_freq * highest_perf)/nominal_perf */
-	max_freq = perf_to_freq(perf, nominal_freq, perf.highest_perf);
+	else
+		max_freq = perf_to_freq(perf, nominal_freq, perf.highest_perf);
 	WRITE_ONCE(cpudata->max_freq, max_freq);
 
 	lowest_nonlinear_freq = perf_to_freq(perf, nominal_freq, perf.lowest_nonlinear_perf);
-- 
2.43.0


  parent reply	other threads:[~2026-08-31 19:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 19:44 [PATCH 0/3] Zen6 client CPPC Mario Limonciello
2026-08-31 19:44 ` [PATCH 1/3] ACPI: CPPC: Refactor boost ratio handling Mario Limonciello
2026-09-01  4:41   ` K Prateek Nayak
2026-09-01 15:26     ` Mario Limonciello
2026-09-01  9:31   ` K Prateek Nayak
2026-09-01 15:28     ` Mario Limonciello
2026-09-01 16:34       ` Rafael J. Wysocki (Intel)
2026-09-01 16:44         ` Mario Limonciello
2026-08-31 19:44 ` [PATCH 2/3] cpufreq/acpi-cpufreq: Use amd_get_boost_ratio() Mario Limonciello
2026-08-31 19:44 ` Mario Limonciello [this message]
2026-09-01  9:36 ` [PATCH 0/3] Zen6 client CPPC K Prateek Nayak

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=20260831194428.2287055-4-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Vishal.Badole@amd.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=x86@kernel.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