linux-stable/drivers/thermal
Yi Zeng ea40afb5c3 thermal: power_allocator: fix one race condition issue for thermal_instances list
[ Upstream commit a5de11d67d ]

When invoking allow_maximum_power and traverse tz->thermal_instances,
we should grab thermal_zone_device->lock to avoid race condition. For
example, during the system reboot, if the mali GPU device implements
device shutdown callback and unregister GPU devfreq cooling device,
the deleted list head may be accessed to cause panic, as the following
log shows:

[   33.551070] c3 25 (kworker/3:0) Unable to handle kernel paging request at virtual address dead000000000070
[   33.566708] c3 25 (kworker/3:0) pgd = ffffffc0ed290000
[   33.572071] c3 25 (kworker/3:0) [dead000000000070] *pgd=00000001ed292003, *pud=00000001ed292003, *pmd=0000000000000000
[   33.581515] c3 25 (kworker/3:0) Internal error: Oops: 96000004 [#1] PREEMPT SMP
[   33.599761] c3 25 (kworker/3:0) CPU: 3 PID: 25 Comm: kworker/3:0 Not tainted 4.4.35+ #912
[   33.614137] c3 25 (kworker/3:0) Workqueue: events_freezable thermal_zone_device_check
[   33.620245] c3 25 (kworker/3:0) task: ffffffc0f32e4200 ti: ffffffc0f32f0000 task.ti: ffffffc0f32f0000
[   33.629466] c3 25 (kworker/3:0) PC is at power_allocator_throttle+0x7c8/0x8a4
[   33.636609] c3 25 (kworker/3:0) LR is at power_allocator_throttle+0x808/0x8a4
[   33.643742] c3 25 (kworker/3:0) pc : [<ffffff8008683dd0>] lr : [<ffffff8008683e10>] pstate: 20000145
[   33.652874] c3 25 (kworker/3:0) sp : ffffffc0f32f3bb0
[   34.468519] c3 25 (kworker/3:0) Process kworker/3:0 (pid: 25, stack limit = 0xffffffc0f32f0020)
[   34.477220] c3 25 (kworker/3:0) Stack: (0xffffffc0f32f3bb0 to 0xffffffc0f32f4000)
[   34.819822] c3 25 (kworker/3:0) Call trace:
[   34.824021] c3 25 (kworker/3:0) Exception stack(0xffffffc0f32f39c0 to 0xffffffc0f32f3af0)
[   34.924993] c3 25 (kworker/3:0) [<ffffff8008683dd0>] power_allocator_throttle+0x7c8/0x8a4
[   34.933184] c3 25 (kworker/3:0) [<ffffff80086807f4>] handle_thermal_trip.part.25+0x70/0x224
[   34.941545] c3 25 (kworker/3:0) [<ffffff8008680a68>] thermal_zone_device_update+0xc0/0x20c
[   34.949818] c3 25 (kworker/3:0) [<ffffff8008680bd4>] thermal_zone_device_check+0x20/0x2c
[   34.957924] c3 25 (kworker/3:0) [<ffffff80080b93a4>] process_one_work+0x168/0x458
[   34.965414] c3 25 (kworker/3:0) [<ffffff80080ba068>] worker_thread+0x13c/0x4b4
[   34.972650] c3 25 (kworker/3:0) [<ffffff80080c0a4c>] kthread+0xe8/0xfc
[   34.979187] c3 25 (kworker/3:0) [<ffffff8008084e90>] ret_from_fork+0x10/0x40
[   34.986244] c3 25 (kworker/3:0) Code: f9405e73 eb1302bf d102e273 54ffc460 (b9402a61)
[   34.994339] c3 25 (kworker/3:0) ---[ end trace 32057901e3b7e1db ]---

Signed-off-by: Yi Zeng <yizeng@asrmicro.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-12 12:32:12 +02:00
..
broadcom thermal: bcm2835: constify thermal_zone_of_device_ops structures 2017-08-11 11:38:30 +08:00
int340x_thermal License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
qcom
samsung thermal: exynos: constify thermal_zone_of_device_ops structures 2017-08-11 11:38:30 +08:00
st
tegra License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ti-soc-thermal License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
armada_thermal.c
clock_cooling.c thermal: convert clock cooling to use an IDA 2017-01-04 12:47:28 +08:00
cpu_cooling.c thermal: cpu_cooling: Replace kmalloc with kmalloc_array 2017-05-27 17:33:04 -07:00
da9062-thermal.c thermal: da9062/61: Thermal junction temperature monitoring driver 2017-04-06 21:48:03 -07:00
db8500_thermal.c thermal: db8500: Fix module autoload 2016-11-23 10:07:35 +08:00
devfreq_cooling.c trace: thermal: add another parameter 'power' to the tracing function 2017-05-05 15:54:45 +08:00
dove_thermal.c
fair_share.c thermal: fix source code documentation for parameters 2017-06-29 10:46:31 +08:00
gov_bang_bang.c
hisi_thermal.c thermal/drivers/hisi: Fix multiple alarm interrupts firing 2017-12-25 14:26:31 +01:00
imx_thermal.c thermal: imx: Handle return value of clk_prepare_enable 2017-06-30 16:41:55 -07:00
intel_bxt_pmic_thermal.c mfd: intel_soc_pmic_bxtwc: Remove thermal second level IRQs 2017-06-19 15:44:29 +01:00
intel_pch_thermal.c thermal: intel_pch_thermal: Fix enable check on Broadwell-DE 2017-08-15 14:32:58 +08:00
intel_powerclamp.c sched/headers: Prepare for new header dependencies before moving code to <uapi/linux/sched/types.h> 2017-03-02 08:42:27 +01:00
intel_quark_dts_thermal.c
intel_soc_dts_iosf.c
intel_soc_dts_iosf.h
intel_soc_dts_thermal.c Thermal: Intel SoC DTS: Change interrupt request behavior 2017-05-05 16:00:10 +08:00
Kconfig Merge branches 'thermal-core', 'thermal-soc', 'thermal-intel' and 'const-thermal-zone-structure' into next 2017-09-08 11:20:04 +08:00
kirkwood_thermal.c
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
max77620_thermal.c thermal: max77620: fix pinmux conflict on reprobe 2017-06-13 11:07:32 +02:00
mtk_thermal.c thermal: mediatek: minor mtk_thermal.c cleanups 2017-08-31 21:13:53 +08:00
of-thermal.c
power_allocator.c thermal: power_allocator: fix one race condition issue for thermal_instances list 2018-04-12 12:32:12 +02:00
qcom-spmi-temp-alarm.c
qoriq_thermal.c thermal: qoriq: constify thermal_zone_of_device_ops structures 2017-08-11 11:38:29 +08:00
rcar_gen3_thermal.c thermal: rcar_gen3_thermal: constify thermal_zone_of_device_ops structures 2017-08-11 11:38:29 +08:00
rcar_thermal.c
rockchip_thermal.c thermal: rockchip: Support the RK3328 SOC in thermal driver 2017-08-11 16:21:38 +08:00
spear_thermal.c
step_wise.c thermal/drivers/step_wise: Fix temperature regulation misbehavior 2017-12-20 10:10:28 +01:00
tango_thermal.c
thermal-generic-adc.c
thermal_core.c thermal: core: Fix resources release in error paths in thermal_zone_device_register() 2017-08-11 11:34:07 +08:00
thermal_core.h thermal: core: Add some new helper functions to free resources 2017-08-11 11:33:49 +08:00
thermal_helpers.c
thermal_hwmon.c Revert "thermal: thermal_hwmon: Convert to hwmon_device_register_with_info()" 2017-01-25 09:51:08 +08:00
thermal_hwmon.h
thermal_sysfs.c thermal: core: Add some new helper functions to free resources 2017-08-11 11:33:49 +08:00
uniphier_thermal.c thermal: uniphier: add UniPhier thermal driver 2017-08-11 10:49:52 +08:00
user_space.c thermal: fix source code documentation for parameters 2017-06-29 10:46:31 +08:00
x86_pkg_temp_thermal.c thermal/x86 pkg temp: Convert to hotplug state machine 2016-11-30 10:25:47 +08:00
zx2967_thermal.c thermal: zx2967: constify thermal_zone_of_device_ops structures 2017-08-11 11:38:30 +08:00