Skip to content

Commit 8164f74

Browse files
Meng Lirafaeljw
authored andcommitted
cpufreq: amd-pstate: adjust min/max limit perf
The min/max limit perf values calculated based on frequency may exceed the reasonable range of perf(highest perf, lowest perf). Signed-off-by: Meng Li <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 88debc6 commit 8164f74

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,19 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy)
484484

485485
static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)
486486
{
487-
u32 max_limit_perf, min_limit_perf;
487+
u32 max_limit_perf, min_limit_perf, lowest_perf;
488488
struct amd_cpudata *cpudata = policy->driver_data;
489489

490490
max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
491491
min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
492492

493+
lowest_perf = READ_ONCE(cpudata->lowest_perf);
494+
if (min_limit_perf < lowest_perf)
495+
min_limit_perf = lowest_perf;
496+
497+
if (max_limit_perf < min_limit_perf)
498+
max_limit_perf = min_limit_perf;
499+
493500
WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
494501
WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
495502
WRITE_ONCE(cpudata->max_limit_freq, policy->max);
@@ -1387,6 +1394,12 @@ static void amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
13871394
max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
13881395
min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
13891396

1397+
if (min_limit_perf < min_perf)
1398+
min_limit_perf = min_perf;
1399+
1400+
if (max_limit_perf < min_limit_perf)
1401+
max_limit_perf = min_limit_perf;
1402+
13901403
WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
13911404
WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
13921405

0 commit comments

Comments
 (0)