Skip to content

Commit 2e82368

Browse files
committed
thermal: gov_step_wise: Allow cooling level to be reduced earlier
The current behavior of the Step-wise thermal governor is to increase the cooling level one step at a time after trip point threshold passing by thermal zone temperature until the temperature stops to rise. Then, nothing is done until the temperature decreases below the (possibly updated) trip point threshold, at which point the cooling level is reduced straight to the applicable minimum. While this generally works, it is not in agreement with the throttling logic description comment in step_wise_manage() any more after some relatively recent changes, and in the case of passive cooling, it may lead to undesirable performance oscillations between high and low levels. For this reason, modify the governor's cooling device state selection function, get_target_state(), to reduce cooling by one level even if the temperature is still above the thermal zone threshold, but the temperature has started to fall down. However, ensure that the cooling level will remain above the applicable minimum in that case to pull the zone temperature further down, possibly until it falls below the trip threshold (which may now be equal to the low temperature of the trip). Doing so should help higher performance to be restored earlier in some cases which is desirable especially for passive trip points with relatively high hysteresis values. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/1947735.tdWV9SEqCh@rafael.j.wysocki [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 6b4dece commit 2e82368

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

drivers/thermal/gov_step_wise.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
* If the temperature is higher than a trip point,
2121
* a. if the trend is THERMAL_TREND_RAISING, use higher cooling
2222
* state for this trip point
23-
* b. if the trend is THERMAL_TREND_DROPPING, do nothing
23+
* b. if the trend is THERMAL_TREND_DROPPING, use a lower cooling state
24+
* for this trip point, but keep the cooling state above the applicable
25+
* minimum
2426
* If the temperature is lower than a trip point,
2527
* a. if the trend is THERMAL_TREND_RAISING, do nothing
2628
* b. if the trend is THERMAL_TREND_DROPPING, use the minimum applicable
@@ -51,6 +53,17 @@ static unsigned long get_target_state(struct thermal_instance *instance,
5153
if (throttle) {
5254
if (trend == THERMAL_TREND_RAISING)
5355
return clamp(cur_state + 1, instance->lower, instance->upper);
56+
57+
/*
58+
* If the zone temperature is falling, the cooling level can
59+
* be reduced, but it should still be above the lower state of
60+
* the given thermal instance to pull the temperature further
61+
* down.
62+
*/
63+
if (trend == THERMAL_TREND_DROPPING)
64+
return clamp(cur_state - 1,
65+
min(instance->lower + 1, instance->upper),
66+
instance->upper);
5467
} else if (trend == THERMAL_TREND_DROPPING) {
5568
if (cur_state <= instance->lower)
5669
return THERMAL_NO_TARGET;

0 commit comments

Comments
 (0)