1 From cef4ba037209392aa6437357c27ba7c450936e36 Mon Sep 17 00:00:00 2001
2 From: Ram Chandrasekar <rkumbako@codeaurora.org>
3 Date: Mon, 7 May 2018 11:54:08 -0600
4 Subject: [PATCH] drivers: thermal: step_wise: add support for hysteresis
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Step wise governor increases the mitigation level when the temperature
10 goes above a threshold and will decrease the mitigation when the
11 temperature falls below the threshold. If it were a case, where the
12 temperature hovers around a threshold, the mitigation will be applied
13 and removed at every iteration. This reaction to the temperature is
14 inefficient for performance.
16 The use of hysteresis temperature could avoid this ping-pong of
17 mitigation by relaxing the mitigation to happen only when the
18 temperature goes below this lower hysteresis value.
20 Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
21 Signed-off-by: Lina Iyer <ilina@codeaurora.org>
23 drivers: thermal: step_wise: avoid throttling at hysteresis temperature after dropping below it
25 Signed-off-by: Serge Schneider <serge@raspberrypi.org>
27 Fix hysteresis support in gov_step_wise.c
29 Directly get hyst value instead of going through an
30 optional and, now, unimplemented function.
32 Signed-off-by: Jürgen Kreileder <jk@blackdown.de>
34 drivers/thermal/gov_step_wise.c | 24 ++++++++++++++++++++----
35 1 file changed, 20 insertions(+), 4 deletions(-)
37 --- a/drivers/thermal/gov_step_wise.c
38 +++ b/drivers/thermal/gov_step_wise.c
40 #include "thermal_core.h"
43 - * If the temperature is higher than a trip point,
44 + * If the temperature is higher than a hysteresis temperature,
45 * a. if the trend is THERMAL_TREND_RAISING, use higher cooling
46 * state for this trip point
47 * b. if the trend is THERMAL_TREND_DROPPING, do nothing
48 - * If the temperature is lower than a trip point,
49 + * If the temperature is lower than a hysteresis temperature,
50 * a. if the trend is THERMAL_TREND_RAISING, do nothing
51 * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
52 * state for this trip point, if the cooling state already
53 @@ -74,19 +74,35 @@ static void thermal_zone_trip_update(str
54 int trip_id = thermal_zone_trip_id(tz, trip);
55 struct thermal_instance *instance;
56 bool throttle = false;
59 if (tz->temperature >= trip_threshold) {
61 trace_thermal_zone_trip(tz, trip_id, trip->type);
64 - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
65 - trip_id, trip->type, trip_threshold, trend, throttle);
66 + hyst_temp = trip->temperature - trip->hysteresis;
68 + dev_dbg(&tz->device,
69 + "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
70 + trip_id, trip->type, trip->temperature, hyst_temp, trend, throttle);
72 list_for_each_entry(instance, &td->thermal_instances, trip_node) {
75 old_target = instance->target;
78 + * Lower the mitigation only if the temperature
79 + * goes below the hysteresis temperature.
81 + if (tz->temperature >= trip->temperature ||
82 + (tz->temperature >= hyst_temp &&
83 + old_target == instance->upper)) {
85 + trace_thermal_zone_trip(tz, trip_id, trip->type);
88 instance->target = get_target_state(instance, trend, throttle);
90 dev_dbg(&instance->cdev->device, "old_target=%d, target=%ld\n",