Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] thermal: core: Check correct temperature for thermal trip notification
@ 2023-09-22 19:27 Nícolas F. R. A. Prado
  2023-09-25  9:53 ` AngeloGioacchino Del Regno
  2023-09-25 10:19 ` Daniel Lezcano
  0 siblings, 2 replies; 4+ messages in thread
From: Nícolas F. R. A. Prado @ 2023-09-22 19:27 UTC (permalink / raw)
  To: Rafael J . Wysocki, Daniel Lezcano
  Cc: kernel, AngeloGioacchino Del Regno, Nícolas F. R. A. Prado,
	Amit Kucheria, Zhang Rui, linux-kernel, linux-pm

The thermal trip down notification should be triggered when the
temperature goes below the trip temperature minus the hysteresis. But
while the temperature is correctly checked against that, the last
temperature is instead compared against the trip point temperature. The
end result is that the notification won't always be triggered, only when
the temperature happens to drop quick enough so that the last
temperature was still above the trip point temperature.

Fix the incorrect check.

Fixes: 55cdf0a283b8 ("thermal: core: Add notifications call in the framework")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

---

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

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 58533ea75cd9..120fcf23b8e5 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -361,7 +361,7 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip_id)
 		    tz->temperature >= trip.temperature)
 			thermal_notify_tz_trip_up(tz->id, trip_id,
 						  tz->temperature);
-		if (tz->last_temperature >= trip.temperature &&
+		if (tz->last_temperature >= (trip.temperature - trip.hysteresis) &&
 		    tz->temperature < (trip.temperature - trip.hysteresis))
 			thermal_notify_tz_trip_down(tz->id, trip_id,
 						    tz->temperature);
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-25 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-22 19:27 [PATCH] thermal: core: Check correct temperature for thermal trip notification Nícolas F. R. A. Prado
2023-09-25  9:53 ` AngeloGioacchino Del Regno
2023-09-25 10:19 ` Daniel Lezcano
2023-09-25 16:20   ` Nícolas F. R. A. Prado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox