Skip to content

Commit 220abf7

Browse files
gautshensuperm1
authored andcommitted
cpufreq/amd-pstate: Fix setting of CPPC.min_perf in active mode for performance governor
In the "active" mode of the amd-pstate driver with performance governor, the CPPC.min_perf is expected to be the nominal_perf. However after commit a9b9b4c ("cpufreq/amd-pstate: Drop min and max cached frequencies"), this is not the case when the governor is switched from performance to powersave and back to performance, and the CPPC.min_perf will be equal to the scaling_min_freq that was set for the powersave governor. This is because prior to commit a9b9b4c ("cpufreq/amd-pstate: Drop min and max cached frequencies"), amd_pstate_epp_update_limit() would unconditionally call amd_pstate_update_min_max_limit() and the latter function would enforce the CPPC.min_perf constraint when the governor is performance. However, after the aforementioned commit, amd_pstate_update_min_max_limit() is called by amd_pstate_epp_update_limit() only when either the scaling_{min/max}_freq is different from the cached value of cpudata->{min/max}_limit_freq, which wouldn't have changed on a governor transition from powersave to performance, thus missing out on enforcing the CPPC.min_perf constraint for the performance governor. Fix this by invoking amd_pstate_epp_udpate_limit() not only when the {min/max} limits have changed from the cached values, but also when the policy itself has changed. Fixes: a9b9b4c ("cpufreq/amd-pstate: Drop min and max cached frequencies") Signed-off-by: Gautham R. Shenoy <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello (AMD) <[email protected]>
1 parent c17b750 commit 220abf7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,13 +1554,15 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy)
15541554
pr_debug("CPU %d exiting\n", policy->cpu);
15551555
}
15561556

1557-
static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
1557+
static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy, bool policy_change)
15581558
{
15591559
struct amd_cpudata *cpudata = policy->driver_data;
15601560
union perf_cached perf;
15611561
u8 epp;
15621562

1563-
if (policy->min != cpudata->min_limit_freq || policy->max != cpudata->max_limit_freq)
1563+
if (policy_change ||
1564+
policy->min != cpudata->min_limit_freq ||
1565+
policy->max != cpudata->max_limit_freq)
15641566
amd_pstate_update_min_max_limit(policy);
15651567

15661568
if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
@@ -1584,7 +1586,7 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy)
15841586

15851587
cpudata->policy = policy->policy;
15861588

1587-
ret = amd_pstate_epp_update_limit(policy);
1589+
ret = amd_pstate_epp_update_limit(policy, true);
15881590
if (ret)
15891591
return ret;
15901592

@@ -1658,7 +1660,7 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy)
16581660
int ret;
16591661

16601662
/* enable amd pstate from suspend state*/
1661-
ret = amd_pstate_epp_update_limit(policy);
1663+
ret = amd_pstate_epp_update_limit(policy, false);
16621664
if (ret)
16631665
return ret;
16641666

0 commit comments

Comments
 (0)