diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2024-10-11 00:12:11 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2024-10-23 11:56:49 +0200 |
commit | 33eab804d695dc2be1491890143a64ea4d99cd42 (patch) | |
tree | 941b13663c208c21902e87f6fe20abce93cc874e /drivers/thermal | |
parent | d1c8aa2a5c5c624f25efc78000ea9801948aea15 (diff) | |
download | lwn-33eab804d695dc2be1491890143a64ea4d99cd42.tar.gz lwn-33eab804d695dc2be1491890143a64ea4d99cd42.zip |
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 <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/7749552.EvYhyI6sBW@rjwysocki.net
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/thermal_core.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index a78f9a81595f..cc1fd230b100 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -834,13 +834,13 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz, if (!result) { list_add_tail(&dev->trip_node, &td->thermal_instances); list_add_tail(&dev->cdev_node, &cdev->thermal_instances); - - thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV); } mutex_unlock(&cdev->lock); - if (!result) + if (!result) { + thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV); return 0; + } device_remove_file(&tz->device, &dev->weight_attr); remove_trip_file: @@ -875,9 +875,6 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz, if (pos->cdev == cdev) { list_del(&pos->trip_node); list_del(&pos->cdev_node); - - thermal_governor_update_tz(tz, THERMAL_TZ_UNBIND_CDEV); - mutex_unlock(&cdev->lock); goto unbind; } @@ -887,6 +884,8 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz, return; unbind: + thermal_governor_update_tz(tz, THERMAL_TZ_UNBIND_CDEV); + device_remove_file(&tz->device, &pos->weight_attr); device_remove_file(&tz->device, &pos->attr); sysfs_remove_link(&tz->device.kobj, pos->name); |