Skip to content

Commit c6c89ac

Browse files
JianyuWang0623xiaoxiang781216
authored andcommitted
Thermal/step_wise: Fix that hysteresis takes no effect
Test command nsh> cat /proc/thermal/cpu-thermal Trips /* Copy from drivers/thermal/thermal_dummy.c */ {.name = "cpu_crit", .temp = 90, .hyst = 5, .type = THERMAL_CRITICAL}, {.name = "cpu_alert1", .temp = 70, .hyst = 5, .type = THERMAL_HOT}, {.name = "cpu_alert0", .temp = 60, .hyst = 5, .type = THERMAL_NORMAL}, Without this patch # Error occured when temperature jump to 69. z:cpu-thermal t:67 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:72 t:1 h:16 l:0 c:fan0 s:1|1 z:cpu-thermal t:69 t:1 h:16 l:0 c:fan0 s:0|0 z:cpu-thermal t:74 t:1 h:16 l:0 c:fan0 s:1|1 With this patch z:cpu-thermal t:67 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:72 t:1 h:16 l:0 c:fan0 s:1|1 z:cpu-thermal t:69 t:1 h:16 l:0 c:fan0 s:1|1 z:cpu-thermal t:74 t:1 h:16 l:0 c:fan0 s:2|2 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
1 parent 9899acf commit c6c89ac

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/thermal/thermal_step_wise.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ static int step_wise_throttle(FAR struct thermal_zone_device_s *zdev,
152152
enum thermal_trend_e trend;
153153
unsigned int next_state;
154154
bool throttle = false;
155+
int hyst_temp;
155156
int trip_temp;
156157

158+
thermal_zone_get_trip_hyst(zdev, trip, &hyst_temp);
157159
thermal_zone_get_trip_temp(zdev, trip, &trip_temp);
158160

159161
trend = thermal_zone_get_trend(zdev);
@@ -162,6 +164,10 @@ static int step_wise_throttle(FAR struct thermal_zone_device_s *zdev,
162164
{
163165
throttle = true;
164166
}
167+
else if (zdev->temperature > trip_temp - hyst_temp)
168+
{
169+
return OK;
170+
}
165171

166172
list_for_every_entry(&zdev->instance_list, instance,
167173
struct thermal_instance_s, zdev_node)

0 commit comments

Comments
 (0)