Re: Trip points crossed not detected when no cooling device bound

Rafael J. Wysocki
2024-06-26T10:38:31Z

[-- Attachment #1: Type: text/plain, Size: 1720 bytes --]

Hi,

On Wed, Jun 26, 2024 at 8:50 AM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
>
> Hi,
>
> after experimenting different setup I noticed there is no longer trip
> crossed notifications sent to the userspace when there is no cooling
> device bound to a thermal zone.

I think I've seen those coming for zones without any cooling devices,
so it seems related to the setup.

> git bisecting leads me to this commit:
>
>
> 202aa0d4bb532338cd27bcc64c60abc2987a2be7 is the first bad commit
> commit 202aa0d4bb532338cd27bcc64c60abc2987a2be7
> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Date: Tue Apr 30 17:45:55 2024 +0200
>
> thermal: core: Do not call handle_thermal_trip() if zone
> temperature is invalid
>
> Make __thermal_zone_device_update() bail out if update_temperature()
> fails to update the zone temperature because __thermal_zone_get_temp()
> has returned an error and the current zone temperature is
> THERMAL_TEMP_INVALID (user space receiving netlink thermal messages,
> thermal debug code and thermal governors may get confused otherwise).
>
> Fixes: 9ad18043fb35 ("thermal: core: Send trip crossing
> notifications at init time if needed")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
> Tested-by: Lukasz Luba <lukasz.luba@arm.com>
>
> drivers/thermal/thermal_core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> -

Oh, I see where the problem can be. If the zone is polling only, it
will not rearm the timer when the current zone temperature is invalid
after the above commit, so does the attached patch help?

[-- Attachment #2: thermal-poll-if-temp-invalid.patch --]
[-- Type: text/x-patch, Size: 647 bytes --]

---
drivers/thermal/thermal_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -514,7 +514,7 @@ void __thermal_zone_device_update(struct
update_temperature(tz);

if (tz->temperature == THERMAL_TEMP_INVALID)
- return;
+ goto monitor;

tz->notify_event = event;

@@ -536,6 +536,7 @@ void __thermal_zone_device_update(struct

thermal_debug_update_trip_stats(tz);

+monitor:
monitor_thermal_zone(tz);
}