2c418a06b06bcca981b1d4f2557a7710c19426c8
[openwrt/staging/linusw.git] /
1 From c2e058716ec515ea8a36376de9791cfb18b3249b 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 0887/1085] drivers: thermal: step_wise: add support for
5 hysteresis
6
7 Step wise governor increases the mitigation level when the temperature
8 goes above a threshold and will decrease the mitigation when the
9 temperature falls below the threshold. If it were a case, where the
10 temperature hovers around a threshold, the mitigation will be applied
11 and removed at every iteration. This reaction to the temperature is
12 inefficient for performance.
13
14 The use of hysteresis temperature could avoid this ping-pong of
15 mitigation by relaxing the mitigation to happen only when the
16 temperature goes below this lower hysteresis value.
17
18 Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
19 Signed-off-by: Lina Iyer <ilina@codeaurora.org>
20
21 drivers: thermal: step_wise: avoid throttling at hysteresis temperature after dropping below it
22
23 Signed-off-by: Serge Schneider <serge@raspberrypi.com>
24 ---
25 drivers/thermal/gov_step_wise.c | 23 +++++++++++++++++------
26 1 file changed, 17 insertions(+), 6 deletions(-)
27
28 --- a/drivers/thermal/gov_step_wise.c
29 +++ b/drivers/thermal/gov_step_wise.c
30 @@ -86,22 +86,33 @@ static void thermal_zone_trip_update(str
31 struct thermal_instance *instance;
32 bool throttle = false;
33 int old_target;
34 + int hyst_temp;
35
36 trend = get_tz_trend(tz, trip_id);
37
38 - if (tz->temperature >= trip->temperature) {
39 - throttle = true;
40 - trace_thermal_zone_trip(tz, trip_id, trip->type);
41 - }
42 + hyst_temp = trip->temperature - trip->hysteresis;
43
44 - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
45 - trip_id, trip->type, trip->temperature, trend, throttle);
46 + dev_dbg(&tz->device,
47 + "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
48 + trip_id, trip->type, trip->temperature, hyst_temp, trend, throttle);
49
50 list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
51 if (instance->trip != trip)
52 continue;
53
54 old_target = instance->target;
55 + throttle = false;
56 + /*
57 + * Lower the mitigation only if the temperature
58 + * goes below the hysteresis temperature.
59 + */
60 + if (tz->temperature >= trip->temperature ||
61 + (tz->temperature >= hyst_temp &&
62 + old_target == instance->upper)) {
63 + throttle = true;
64 + trace_thermal_zone_trip(tz, trip_id, trip->type);
65 + }
66 +
67 instance->target = get_target_state(instance, trend, throttle);
68 dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
69 old_target, (int)instance->target);