Skip to content

Commit 18d9b52

Browse files
committed
cpufreq/amd-pstate: Use nominal perf for limits when boost is disabled
When boost has been disabled the limit for perf should be nominal perf not the highest perf. Using the latter to do calculations will lead to incorrect values that are still above nominal. Fixes: ad4caad ("cpufreq: amd-pstate: Merge amd_pstate_highest_perf_set() into amd_get_boost_ratio_numerator()") Reported-by: Peter Jung <[email protected]> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219348 Reviewed-by: Perry Yuan <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Tested-by: Dhananjay Ugwekar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello <[email protected]>
1 parent c10e50a commit 18d9b52

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,16 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy)
536536

537537
static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)
538538
{
539-
u32 max_limit_perf, min_limit_perf, lowest_perf;
539+
u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf;
540540
struct amd_cpudata *cpudata = policy->driver_data;
541541

542-
max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
543-
min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
542+
if (cpudata->boost_supported && !policy->boost_enabled)
543+
max_perf = READ_ONCE(cpudata->nominal_perf);
544+
else
545+
max_perf = READ_ONCE(cpudata->highest_perf);
546+
547+
max_limit_perf = div_u64(policy->max * max_perf, policy->cpuinfo.max_freq);
548+
min_limit_perf = div_u64(policy->min * max_perf, policy->cpuinfo.max_freq);
544549

545550
lowest_perf = READ_ONCE(cpudata->lowest_perf);
546551
if (min_limit_perf < lowest_perf)
@@ -1506,10 +1511,13 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
15061511
u64 value;
15071512
s16 epp;
15081513

1509-
max_perf = READ_ONCE(cpudata->highest_perf);
1514+
if (cpudata->boost_supported && !policy->boost_enabled)
1515+
max_perf = READ_ONCE(cpudata->nominal_perf);
1516+
else
1517+
max_perf = READ_ONCE(cpudata->highest_perf);
15101518
min_perf = READ_ONCE(cpudata->lowest_perf);
1511-
max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
1512-
min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
1519+
max_limit_perf = div_u64(policy->max * max_perf, policy->cpuinfo.max_freq);
1520+
min_limit_perf = div_u64(policy->min * max_perf, policy->cpuinfo.max_freq);
15131521

15141522
if (min_limit_perf < min_perf)
15151523
min_limit_perf = min_perf;

0 commit comments

Comments
 (0)