Skip to contentSkip to conversation

thermal: core: fix blocking in unregistering zone

PATCH New Jiajia Liu 1 participant 1 message Apr 2 Thermal

lore
Share & tools
lore

Jiajia Liu

author
#0 lore raw

PATCH 1/1 thermal: core: fix blocking in unregistering zone

From: Jiajia Liu <[email protected]>

When hwmon->tz_list has more than one member, thermal_remove_hwmon_sysfs does not unregister hwmon->device. Unregistering the zone which is parent of hwmon->device blocks at wait_for_completion(&tz->removal). Add check and move hwmon to other zone in thermal_remove_hwmon_sysfs.

One method of reproducing hung task is to unbind the first acpitz zone on systems with two acpitz zones.

 $ cd /sys/bus/platform/drivers/acpi-thermal/
 $ ls
 bind  LNXTHERM:00  LNXTHERM:01  uevent  unbind
 $ echo 'LNXTHERM:00' | sudo tee unbind > /dev/null
---
 drivers/thermal/thermal_hwmon.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/thermal/thermal_hwmon.c +9 -0
index b624892bc6d6..43cde079fef0 100644
@@ -242,6 +242,15 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
 	list_del(&temp->hwmon_node);
 	kfree(temp);
 	if (!list_empty(&hwmon->tz_list)) {
+		if (hwmon->device->parent == &tz->device) {
+			struct thermal_hwmon_temp *first;
+
+			first = list_first_entry(&hwmon->tz_list,
+						 struct thermal_hwmon_temp,
+						 hwmon_node);
+			device_move(hwmon->device, &first->tz->device,
+				    DPM_ORDER_DEV_AFTER_PARENT);
+		}
 		mutex_unlock(&thermal_hwmon_list_lock);
 		return;
 	}
Signature · 1 line
2.53.0