]> git.baikalelectronics.ru Git - kernel.git/commitdiff
thermal: intel_powerclamp: Use first online CPU as control_cpu
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 13 Oct 2022 12:50:28 +0000 (14:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:23:01 +0000 (13:23 +0200)
commit 5a5b475e1d09c15287638d2ba8185b9501178208 upstream.

Commit a167c3ae55df ("thermal: intel_powerclamp: Use get_cpu() instead
of smp_processor_id() to avoid crash") fixed an issue related to using
smp_processor_id() in preemptible context by replacing it with a pair
of get_cpu()/put_cpu(), but what is needed there really is any online
CPU and not necessarily the one currently running the code.  Arguably,
getting the one that's running the code in there is confusing.

For this reason, simply give the control CPU role to the first online
one which automatically will be CPU0 if it is online, so one check
can be dropped from the code for an added benefit.

Link: https://lore.kernel.org/linux-pm/20221011113646.GA12080@duo.ucw.cz/
Fixes: a167c3ae55df ("thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/thermal/intel/intel_powerclamp.c

index 5e4f32733caf99c1f012b856bcf21448bd7b513f..a717cce4aca4ad891705915218741b23d6b6efc3 100644 (file)
@@ -534,11 +534,7 @@ static int start_power_clamp(void)
        get_online_cpus();
 
        /* prefer BSP */
-       control_cpu = 0;
-       if (!cpu_online(control_cpu)) {
-               control_cpu = get_cpu();
-               put_cpu();
-       }
+       control_cpu = cpumask_first(cpu_online_mask);
 
        clamping = true;
        schedule_delayed_work(&poll_pkg_cstate_work, 0);