]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/thermal/thermal_core.c
thermal: core: skip update disabled thermal zones after suspend
[mirror_ubuntu-jammy-kernel.git] / drivers / thermal / thermal_core.c
index d6ebc1cf6aa9b197089a07ed074610e0124869e5..a2c0ce65bfa42ea3a680dadff6fcf6317a4e3337 100644 (file)
@@ -315,9 +315,7 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
        mutex_unlock(&tz->lock);
 }
 
-static void handle_non_critical_trips(struct thermal_zone_device *tz,
-                                     int trip,
-                                     enum thermal_trip_type trip_type)
+static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
 {
        tz->governor ? tz->governor->throttle(tz, trip) :
                       def_governor->throttle(tz, trip);
@@ -418,7 +416,7 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
        if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
                handle_critical_trips(tz, trip, type);
        else
-               handle_non_critical_trips(tz, trip, type);
+               handle_non_critical_trips(tz, trip);
        /*
         * Alright, we handled this trip successfully.
         * So, start monitoring again.
@@ -453,16 +451,20 @@ static void update_temperature(struct thermal_zone_device *tz)
                        tz->last_temperature, tz->temperature);
 }
 
-static void thermal_zone_device_reset(struct thermal_zone_device *tz)
+static void thermal_zone_device_init(struct thermal_zone_device *tz)
 {
        struct thermal_instance *pos;
-
        tz->temperature = THERMAL_TEMP_INVALID;
-       tz->passive = 0;
        list_for_each_entry(pos, &tz->thermal_instances, tz_node)
                pos->initialized = false;
 }
 
+static void thermal_zone_device_reset(struct thermal_zone_device *tz)
+{
+       tz->passive = 0;
+       thermal_zone_device_init(tz);
+}
+
 void thermal_zone_device_update(struct thermal_zone_device *tz,
                                enum thermal_notify_event event)
 {
@@ -939,7 +941,7 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
  */
 static struct thermal_cooling_device *
 __thermal_cooling_device_register(struct device_node *np,
-                                 char *type, void *devdata,
+                                 const char *type, void *devdata,
                                  const struct thermal_cooling_device_ops *ops)
 {
        struct thermal_cooling_device *cdev;
@@ -1013,7 +1015,7 @@ __thermal_cooling_device_register(struct device_node *np,
  * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
  */
 struct thermal_cooling_device *
-thermal_cooling_device_register(char *type, void *devdata,
+thermal_cooling_device_register(const char *type, void *devdata,
                                const struct thermal_cooling_device_ops *ops)
 {
        return __thermal_cooling_device_register(NULL, type, devdata, ops);
@@ -1037,7 +1039,7 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
  */
 struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
-                                  char *type, void *devdata,
+                                  const char *type, void *devdata,
                                   const struct thermal_cooling_device_ops *ops)
 {
        return __thermal_cooling_device_register(np, type, devdata, ops);
@@ -1492,6 +1494,7 @@ static int thermal_pm_notify(struct notifier_block *nb,
                             unsigned long mode, void *_unused)
 {
        struct thermal_zone_device *tz;
+       enum thermal_device_mode tz_mode;
 
        switch (mode) {
        case PM_HIBERNATION_PREPARE:
@@ -1504,7 +1507,14 @@ static int thermal_pm_notify(struct notifier_block *nb,
        case PM_POST_SUSPEND:
                atomic_set(&in_suspend, 0);
                list_for_each_entry(tz, &thermal_tz_list, node) {
-                       thermal_zone_device_reset(tz);
+                       tz_mode = THERMAL_DEVICE_ENABLED;
+                       if (tz->ops->get_mode)
+                               tz->ops->get_mode(tz, &tz_mode);
+
+                       if (tz_mode == THERMAL_DEVICE_DISABLED)
+                               continue;
+
+                       thermal_zone_device_init(tz);
                        thermal_zone_device_update(tz,
                                                   THERMAL_EVENT_UNSPECIFIED);
                }