[PATCH v4 3/3] cpufreq/amd-pstate: Get Highest Freq for a CPU

From: Mario Limonciello

Date: Thu Oct 01 2026 - 10:30:56 EST


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@xxxxxxx>
---
v4:
* update amd_pstate_update_min_max_limit too (Christian)
---
drivers/cpufreq/amd-pstate.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 9e8ef5548894c..d8e2eec6e7250 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -778,7 +778,10 @@ static void amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)
struct amd_cpudata *cpudata = policy->driver_data;
union perf_cached perf = READ_ONCE(cpudata->perf);

- perf.max_limit_perf = freq_to_perf(perf, cpudata->nominal_freq, policy->max);
+ if (policy->max >= READ_ONCE(cpudata->max_freq))
+ perf.max_limit_perf = perf.highest_perf;
+ else
+ perf.max_limit_perf = freq_to_perf(perf, cpudata->nominal_freq, policy->max);
WRITE_ONCE(cpudata->max_limit_freq, policy->max);

if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) {
@@ -1104,8 +1107,10 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)

WRITE_ONCE(cpudata->nominal_freq, nominal_freq);

- /* max_freq is calculated according to (nominal_freq * highest_perf)/nominal_perf */
- max_freq = perf_to_freq(perf, nominal_freq, perf.highest_perf);
+ /* try to look up from BIOS/quirk first, fall back to (nominal_freq * highest_perf)/nominal_perf */
+ max_freq = amd_get_max_frequency(cpudata->cpu) * 1000;
+ if (!max_freq)
+ 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.55.0