Skip to content

Commit 45722e7

Browse files
committed
cpufreq: amd-pstate: Optimize amd_pstate_update_limits()
Don't take and release the mutex when prefcore isn't present and avoid initialization of variables that will be initially set in the function. Reviewed-by: Gautham R. Shenoy <[email protected]> Reviewed-by: Perry Yuan <[email protected]> Signed-off-by: Mario Limonciello <[email protected]>
1 parent ad4caad commit 45722e7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,17 +810,17 @@ static void amd_pstate_update_limits(unsigned int cpu)
810810

811811
cpudata = policy->driver_data;
812812

813-
mutex_lock(&amd_pstate_driver_lock);
814-
if ((!amd_pstate_prefcore) || (!cpudata->hw_prefcore))
815-
goto free_cpufreq_put;
813+
if (!amd_pstate_prefcore)
814+
return;
816815

816+
mutex_lock(&amd_pstate_driver_lock);
817817
ret = amd_get_highest_perf(cpu, &cur_high);
818818
if (ret)
819819
goto free_cpufreq_put;
820820

821821
prev_high = READ_ONCE(cpudata->prefcore_ranking);
822-
if (prev_high != cur_high) {
823-
highest_perf_changed = true;
822+
highest_perf_changed = (prev_high != cur_high);
823+
if (highest_perf_changed) {
824824
WRITE_ONCE(cpudata->prefcore_ranking, cur_high);
825825

826826
if (cur_high < CPPC_MAX_PERF)

0 commit comments

Comments
 (0)