Skip to content

Commit a8a2617

Browse files
committed
thermal: core: Call monitor_thermal_zone() if zone temperature is invalid
Commit 202aa0d ("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: 202aa0d ("thermal: core: Do not call handle_thermal_trip() if zone temperature is invalid") Reported-by: Daniel Lezcano <[email protected]> Tested-by: Daniel Lezcano <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected] [ rjw: Changed THERMAL_RECHECK_DELAY_MS to 250 ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent aaa18ff commit a8a2617

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
300300
thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
301301
else if (tz->polling_delay_jiffies)
302302
thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
303+
else if (tz->temperature == THERMAL_TEMP_INVALID)
304+
thermal_zone_device_set_polling(tz, msecs_to_jiffies(THERMAL_RECHECK_DELAY_MS));
303305
}
304306

305307
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,
511513
update_temperature(tz);
512514

513515
if (tz->temperature == THERMAL_TEMP_INVALID)
514-
return;
516+
goto monitor;
515517

516518
__thermal_zone_set_trips(tz);
517519

@@ -533,6 +535,7 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
533535

534536
thermal_debug_update_trip_stats(tz);
535537

538+
monitor:
536539
monitor_thermal_zone(tz);
537540
}
538541

drivers/thermal/thermal_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ struct thermal_zone_device {
133133
struct thermal_trip_desc trips[] __counted_by(num_trips);
134134
};
135135

136+
/*
137+
* Default delay after a failing thermal zone temperature check before
138+
* attempting to check it again.
139+
*/
140+
#define THERMAL_RECHECK_DELAY_MS 250
141+
136142
/* Default Thermal Governor */
137143
#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)
138144
#define DEFAULT_THERMAL_GOVERNOR "step_wise"

0 commit comments

Comments
 (0)