]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: core: Call monitor_thermal_zone() if zone temperature is invalid
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 28 Jun 2024 12:10:03 +0000 (14:10 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 4 Jul 2024 17:01:59 +0000 (19:01 +0200)
Commit 202aa0d4bb53 ("thermal: core: Do not call handle_thermal_trip()
if zone temperature is invalid") caused __thermal_zone_device_update()
to return early if the current thermal zone temperature was invalid.

This was done to avoid running handle_thermal_trip() and governor
callbacks in that case which led to confusion.  However, it went too
far because monitor_thermal_zone() still needs to be called even when
the zone temperature is invalid to ensure that it will be updated
eventually in case thermal polling is enabled and the driver has no
other means to notify the core of zone temperature changes (for example,
it does not register an interrupt handler or ACPI notifier).

Also if the .set_trips() zone callback is expected to set up monitoring
interrupts for a thermal zone, it has to be provided with valid
boundaries and that can only happen if the zone temperature is known.

Accordingly, to ensure that __thermal_zone_device_update() will
run again after a failing zone temperature check, make it call
monitor_thermal_zone() regardless of whether or not the zone
temperature is valid and make the latter schedule a thermal zone
temperature update if the zone temperature is invalid even if
polling is not enabled for the thermal zone.

Fixes: 202aa0d4bb53 ("thermal: core: Do not call handle_thermal_trip() if zone temperature is invalid")
Reported-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2764814.mvXUDI8C0e@rjwysocki.net
[ rjw: Changed THERMAL_RECHECK_DELAY_MS to 250 ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h

index 1b0ab2790860411605399ed8874583494393a9eb..46418e30b4a6002a661cf9956a1f1a97ea72ed43 100644 (file)
@@ -300,6 +300,8 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
                thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
        else if (tz->polling_delay_jiffies)
                thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
+       else if (tz->temperature == THERMAL_TEMP_INVALID)
+               thermal_zone_device_set_polling(tz, msecs_to_jiffies(THERMAL_RECHECK_DELAY_MS));
 }
 
 static struct thermal_governor *thermal_get_tz_governor(struct thermal_zone_device *tz)
@@ -511,7 +513,7 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
        update_temperature(tz);
 
        if (tz->temperature == THERMAL_TEMP_INVALID)
-               return;
+               goto monitor;
 
        __thermal_zone_set_trips(tz);
 
@@ -533,6 +535,7 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
 
        thermal_debug_update_trip_stats(tz);
 
+monitor:
        monitor_thermal_zone(tz);
 }
 
index 66f67e54e0c8dc7701c463b1a8ef994eaeeca154..94eeb4011a48138a26d31b38f8bb1c07b363f73f 100644 (file)
@@ -133,6 +133,12 @@ struct thermal_zone_device {
        struct thermal_trip_desc trips[] __counted_by(num_trips);
 };
 
+/*
+ * Default delay after a failing thermal zone temperature check before
+ * attempting to check it again.
+ */
+#define THERMAL_RECHECK_DELAY_MS       250
+
 /* Default Thermal Governor */
 #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)
 #define DEFAULT_THERMAL_GOVERNOR       "step_wise"