Skip to content

Commit 79148c9

Browse files
Ram Chandrasekarpelwell
Ram Chandrasekar
authored andcommitted
drivers: thermal: step_wise: add support for hysteresis
Step wise governor increases the mitigation level when the temperature goes above a threshold and will decrease the mitigation when the temperature falls below the threshold. If it were a case, where the temperature hovers around a threshold, the mitigation will be applied and removed at every iteration. This reaction to the temperature is inefficient for performance. The use of hysteresis temperature could avoid this ping-pong of mitigation by relaxing the mitigation to happen only when the temperature goes below this lower hysteresis value. Signed-off-by: Ram Chandrasekar <[email protected]> Signed-off-by: Lina Iyer <[email protected]> drivers: thermal: step_wise: avoid throttling at hysteresis temperature after dropping below it Signed-off-by: Serge Schneider <[email protected]>
1 parent 266837b commit 79148c9

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

drivers/thermal/gov_step_wise.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,33 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id
8686
struct thermal_instance *instance;
8787
bool throttle = false;
8888
int old_target;
89+
int hyst_temp;
8990

9091
trend = get_tz_trend(tz, trip_id);
9192

92-
if (tz->temperature >= trip->temperature) {
93-
throttle = true;
94-
trace_thermal_zone_trip(tz, trip_id, trip->type);
95-
}
93+
hyst_temp = trip->temperature - trip->hysteresis;
9694

97-
dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
98-
trip_id, trip->type, trip->temperature, trend, throttle);
95+
dev_dbg(&tz->device,
96+
"Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
97+
trip_id, trip->type, trip->temperature, hyst_temp, trend, throttle);
9998

10099
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
101100
if (instance->trip != trip)
102101
continue;
103102

104103
old_target = instance->target;
104+
throttle = false;
105+
/*
106+
* Lower the mitigation only if the temperature
107+
* goes below the hysteresis temperature.
108+
*/
109+
if (tz->temperature >= trip->temperature ||
110+
(tz->temperature >= hyst_temp &&
111+
old_target == instance->upper)) {
112+
throttle = true;
113+
trace_thermal_zone_trip(tz, trip_id, trip->type);
114+
}
115+
105116
instance->target = get_target_state(instance, trend, throttle);
106117
dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
107118
old_target, (int)instance->target);

0 commit comments

Comments
 (0)