]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: core: Mark thermal zones as exiting before unregistration
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 4 Oct 2024 19:26:12 +0000 (21:26 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 22 Oct 2024 10:07:33 +0000 (12:07 +0200)
In analogy with a previous change in the thermal zone registration code
path, to ensure that __thermal_zone_device_update() will return early
for thermal zones that are going away, introduce a thermal zone state
flag representing the "exit" state and set it while deleting the thermal
zone from thermal_tz_list.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/4394176.ejJDZkT8p0@rjwysocki.net
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h

index 5ae20a740a50592f5420ec3a1ce73da54cb036e3..841d072bbe9379760ce0463fa8a909e097eb5ddd 100644 (file)
@@ -1621,7 +1621,10 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
        }
 
        mutex_lock(&tz->lock);
+
+       tz->state |= TZ_STATE_FLAG_EXIT;
        list_del(&tz->node);
+
        mutex_unlock(&tz->lock);
 
        /* Unbind all cdevs associated with 'this' thermal zone */
index 95d920e8403ac53c226f49ef5c47bef5e1758227..f8d2e85d24081735bd324b12db80390cfde04d5e 100644 (file)
@@ -65,6 +65,7 @@ struct thermal_governor {
 #define        TZ_STATE_FLAG_SUSPENDED BIT(0)
 #define        TZ_STATE_FLAG_RESUMING  BIT(1)
 #define        TZ_STATE_FLAG_INIT      BIT(2)
+#define        TZ_STATE_FLAG_EXIT      BIT(3)
 
 #define TZ_STATE_READY         0