Skip to content

Commit 33eab80

Browse files
committed
thermal: core: Call thermal_governor_update_tz() outside of cdev lock
Holding a cooling device lock under thermal_governor_update_tz() is not necessary and it may cause lockdep to complain if any governor's .update_tz() callback attempts to lock a cdev. For this reason, move the thermal_governor_update_tz() calls in thermal_bind_cdev_to_trip() and thermal_unbind_cdev_from_trip() from under the cdev lock. Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Lukasz Luba <[email protected]>
1 parent d1c8aa2 commit 33eab80

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/thermal/thermal_core.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -834,13 +834,13 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
834834
if (!result) {
835835
list_add_tail(&dev->trip_node, &td->thermal_instances);
836836
list_add_tail(&dev->cdev_node, &cdev->thermal_instances);
837-
838-
thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV);
839837
}
840838
mutex_unlock(&cdev->lock);
841839

842-
if (!result)
840+
if (!result) {
841+
thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV);
843842
return 0;
843+
}
844844

845845
device_remove_file(&tz->device, &dev->weight_attr);
846846
remove_trip_file:
@@ -875,9 +875,6 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
875875
if (pos->cdev == cdev) {
876876
list_del(&pos->trip_node);
877877
list_del(&pos->cdev_node);
878-
879-
thermal_governor_update_tz(tz, THERMAL_TZ_UNBIND_CDEV);
880-
881878
mutex_unlock(&cdev->lock);
882879
goto unbind;
883880
}
@@ -887,6 +884,8 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
887884
return;
888885

889886
unbind:
887+
thermal_governor_update_tz(tz, THERMAL_TZ_UNBIND_CDEV);
888+
890889
device_remove_file(&tz->device, &pos->weight_attr);
891890
device_remove_file(&tz->device, &pos->attr);
892891
sysfs_remove_link(&tz->device.kobj, pos->name);

0 commit comments

Comments
 (0)