]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
cpufreq: Use locking guard and __free() in cpufreq_update_policy()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 28 Mar 2025 20:44:50 +0000 (21:44 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 9 Apr 2025 19:22:10 +0000 (21:22 +0200)
Instead of using cpufreq_cpu_acquire() and cpufreq_cpu_release() in
cpufreq_update_policy(), which is the last user of these functions,
make it use __free() for policy reference counting cleanup and the
"write" locking guard for policy locking.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Link: https://patch.msgid.link/22654186.EfDdHjke4D@rjwysocki.net
drivers/cpufreq/cpufreq.c

index a3abd9c0440d0c2156482b25e2c01e211ef62d1f..40244ff620b62b612e16ddeb67e720a2270df5e8 100644 (file)
@@ -2780,23 +2780,23 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
  */
 void cpufreq_update_policy(unsigned int cpu)
 {
-       struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
+       struct cpufreq_policy *policy __free(put_cpufreq_policy);
 
+       policy = cpufreq_cpu_get(cpu);
        if (!policy)
                return;
 
+       guard(cpufreq_policy_write)(policy);
+
        /*
         * BIOS might change freq behind our back
         * -> ask driver for current freq and notify governors about a change
         */
        if (cpufreq_driver->get && has_target() &&
            (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false))))
-               goto unlock;
+               return;
 
        refresh_frequency_limits(policy);
-
-unlock:
-       cpufreq_cpu_release(policy);
 }
 EXPORT_SYMBOL(cpufreq_update_policy);