cpufreq: amd-pstate: Optimize amd_pstate_update_limits()
authorMario Limonciello <mario.limonciello@amd.com>
Mon, 26 Aug 2024 21:13:57 +0000 (16:13 -0500)
committerMario Limonciello <mario.limonciello@amd.com>
Wed, 11 Sep 2024 15:23:23 +0000 (10:23 -0500)
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 <gautham.shenoy@amd.com>
Reviewed-by: Perry Yuan <perry.yuan@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
drivers/cpufreq/amd-pstate.c

index 89623203f9185c240d8233b866a456c984ccd80c..f550d31f80eb384ca5d841efdb341a88521f8828 100644 (file)
@@ -810,17 +810,17 @@ static void amd_pstate_update_limits(unsigned int cpu)
 
        cpudata = policy->driver_data;
 
-       mutex_lock(&amd_pstate_driver_lock);
-       if ((!amd_pstate_prefcore) || (!cpudata->hw_prefcore))
-               goto free_cpufreq_put;
+       if (!amd_pstate_prefcore)
+               return;
 
+       mutex_lock(&amd_pstate_driver_lock);
        ret = amd_get_highest_perf(cpu, &cur_high);
        if (ret)
                goto free_cpufreq_put;
 
        prev_high = READ_ONCE(cpudata->prefcore_ranking);
-       if (prev_high != cur_high) {
-               highest_perf_changed = true;
+       highest_perf_changed = (prev_high != cur_high);
+       if (highest_perf_changed) {
                WRITE_ONCE(cpudata->prefcore_ranking, cur_high);
 
                if (cur_high < CPPC_MAX_PERF)