summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-10-13 14:50:28 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-10-26 13:23:01 +0200
commitd9fdda5efe76311264c89a2abede084f183f8405 (patch)
tree1230c4d78e2fc824543fc3fd08e017c04b713393
parentc3bb4a7e8cbc984e1cdac0fe6af60e880214ed6e (diff)
downloadlinux-stable-d9fdda5efe76311264c89a2abede084f183f8405.tar.gz
linux-stable-d9fdda5efe76311264c89a2abede084f183f8405.tar.bz2
linux-stable-d9fdda5efe76311264c89a2abede084f183f8405.zip
thermal: intel_powerclamp: Use first online CPU as control_cpu
commit 4bb7f6c2781e46fc5bd00475a66df2ea30ef330d upstream. Commit 68b99e94a4a2 ("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: 68b99e94a4a2 ("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>
-rw-r--r--drivers/thermal/intel/intel_powerclamp.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index 5e4f32733caf..a717cce4aca4 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -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);