linux-stable/drivers/thermal
Srinivas Pandruvada 6e2a347b30 thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash
[ Upstream commit 68b99e94a4 ]

When CPU 0 is offline and intel_powerclamp is used to inject
idle, it generates kernel BUG:

BUG: using smp_processor_id() in preemptible [00000000] code: bash/15687
caller is debug_smp_processor_id+0x17/0x20
CPU: 4 PID: 15687 Comm: bash Not tainted 5.19.0-rc7+ #57
Call Trace:
<TASK>
dump_stack_lvl+0x49/0x63
dump_stack+0x10/0x16
check_preemption_disabled+0xdd/0xe0
debug_smp_processor_id+0x17/0x20
powerclamp_set_cur_state+0x7f/0xf9 [intel_powerclamp]
...
...

Here CPU 0 is the control CPU by default and changed to the current CPU,
if CPU 0 offlined. This check has to be performed under cpus_read_lock(),
hence the above warning.

Use get_cpu() instead of smp_processor_id() to avoid this BUG.

Suggested-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Subject edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-10-24 09:58:09 +02:00
..
broadcom thermal/drivers/broadcom: Fix potential NULL dereference in sr_thermal_probe 2022-05-19 12:11:52 +02:00
intel thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash 2022-10-24 09:58:09 +02:00
qcom thermal/drivers/qcom/tsens-v0_1: Fix MSM8939 fourth sensor hw_id 2022-10-24 09:58:07 +02:00
samsung
st
tegra thermal: tegra-bpmp: Handle errors in BPMP response 2022-03-08 21:26:09 +01:00
ti-soc-thermal thermal/drivers/ti-soc-thermal: Remove unused function ti_thermal_get_temp() 2022-03-08 21:26:09 +01:00
Kconfig thermal/governor: Remove deprecated information 2022-04-22 16:47:40 +02:00
Makefile thermal: k3_j72xx_bandgap: Add the bandgap driver support 2022-05-19 12:11:53 +02:00
amlogic_thermal.c
armada_thermal.c
cpufreq_cooling.c thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register() 2022-10-24 09:57:01 +02:00
cpuidle_cooling.c
da9062-thermal.c
db8500_thermal.c
devfreq_cooling.c PM: EM: convert power field to micro-Watts precision and align drivers 2022-08-17 15:14:05 +02:00
dove_thermal.c
gov_bang_bang.c
gov_fair_share.c
gov_power_allocator.c
gov_step_wise.c
gov_user_space.c thermal/governor: Remove deprecated information 2022-04-22 16:47:40 +02:00
hisi_thermal.c thermal: hisi_termal: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() 2022-04-13 16:37:28 +02:00
imx8mm_thermal.c thermal/drivers/imx8mm: Enable ADC when enabling monitor 2021-12-02 11:12:24 +01:00
imx_sc_thermal.c thermal/drivers/imx_sc_thermal: Fix refcount leak in imx_sc_thermal_probe 2022-05-19 12:11:53 +02:00
imx_thermal.c thermal/drivers/imx: Implement runtime PM support 2021-11-30 15:42:28 +01:00
k3_bandgap.c thermal/drivers/k3: Add hwmon support 2022-05-19 12:11:51 +02:00
k3_j72xx_bandgap.c thermal: k3_j72xx_bandgap: Add the bandgap driver support 2022-05-19 12:11:53 +02:00
khadas_mcu_fan.c
kirkwood_thermal.c
max77620_thermal.c
mtk_thermal.c
qoriq_thermal.c
rcar_gen3_thermal.c thermal: rcar_gen3_thermal: Read calibration from hardware 2021-10-15 09:15:52 +02:00
rcar_thermal.c thermal/drivers/rcar_thermal: Use platform_get_irq_optional() to get the interrupt 2022-05-19 12:11:50 +02:00
rockchip_thermal.c thermal/drivers/rockchip_thermal: Allow more resets for tsadc node 2021-10-17 00:15:09 +02:00
rzg2l_thermal.c thermal/drivers/rz2gl: Fix OTP Calibration Register values 2022-05-19 12:11:52 +02:00
spear_thermal.c
sprd_thermal.c
sun8i_thermal.c
thermal-generic-adc.c
thermal_core.c thermal/core: Fix memory leak in __thermal_cooling_device_register() 2022-05-19 12:11:53 +02:00
thermal_core.h
thermal_helpers.c
thermal_hwmon.c thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal() 2022-05-22 11:32:31 -07:00
thermal_hwmon.h
thermal_mmio.c thermal/drivers/thermal_mmio: Constify static struct thermal_mmio_ops 2021-10-07 15:18:31 +02:00
thermal_netlink.c Merge branch 'thermal-hfi' 2022-03-18 19:00:26 +01:00
thermal_netlink.h thermal: netlink: Fix parameter type of thermal_genl_cpu_capability_event() stub 2022-02-07 20:45:42 +01:00
thermal_of.c thermal: thermal_of: fix typo on __thermal_bind_params 2022-05-19 12:11:52 +02:00
thermal_sysfs.c thermal: sysfs: Fix cooling_device_stats_setup() error code path 2022-08-17 15:13:47 +02:00
uniphier_thermal.c thermal/drivers/uniphier: Add compatible string for NX1 SoC 2021-10-18 14:00:13 +02:00