From 0e71a944b9fba8ecc49932da91f236aa058bee11 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Sat, 15 Mar 2025 21:06:45 +0800 Subject: [PATCH] drivers/thermal: Update state when temp is stable Fix cooling state not decreasing error when the temperature is kept at low trip(stable, not dropping). Test on "sim:thermal", log is from /proc/thermal/cpu-thermal and see thermal/thermal_dummy.c for trip point details. e.g. The temperature decreasing from 71 to 65 and then kept. z:cpu-thermal t:71 t:1 h:16 l:0 c:fan0 s:16|16 a. Without this patch, the cooling state of "fan0" will be kept at 15, even if the temperature is at a lower trip: z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:15|15 ... ... z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:15|15 b. With this patch, the cooling state of "fan0" was continually decreasing to zero according to current trip point: z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:15|15 ... ... z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:0|0 Signed-off-by: wangjianyu3 --- drivers/thermal/thermal_step_wise.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/thermal/thermal_step_wise.c b/drivers/thermal/thermal_step_wise.c index 979e0dc4e4..b01b057fe1 100644 --- a/drivers/thermal/thermal_step_wise.c +++ b/drivers/thermal/thermal_step_wise.c @@ -134,6 +134,10 @@ static unsigned int get_target_state(FAR struct thermal_instance_s *instance, return validate_state(instance, throttle, cur_state, 1); } } + else + { + return validate_state(instance, throttle, cur_state, -1); + } break; default: