1 From 05a13bbd7fbb76b4f690042173749a55d85de831 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 172/806] drivers: thermal: step_wise: add support for
7 From: Ram Chandrasekar <rkumbako@codeaurora.org>
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.c | 33 +++++++++++++++++++++++----------
24 1 file changed, 23 insertions(+), 10 deletions(-)
26 --- a/drivers/thermal/step_wise.c
27 +++ b/drivers/thermal/step_wise.c
30 * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit
32 - * If the temperature is lower than a trip point,
33 + * If the temperature is lower than a hysteresis temperature,
34 * a. if the trend is THERMAL_TREND_RAISING, do nothing
35 * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
36 * state for this trip point, if the cooling state already
37 @@ -127,7 +127,7 @@ static void update_passive_instance(stru
39 static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
42 + int trip_temp, hyst_temp;
43 enum thermal_trip_type trip_type;
44 enum thermal_trend trend;
45 struct thermal_instance *instance;
46 @@ -135,22 +135,23 @@ static void thermal_zone_trip_update(str
49 if (trip == THERMAL_TRIPS_NONE) {
50 - trip_temp = tz->forced_passive;
51 + hyst_temp = trip_temp = tz->forced_passive;
52 trip_type = THERMAL_TRIPS_NONE;
54 tz->ops->get_trip_temp(tz, trip, &trip_temp);
55 + hyst_temp = trip_temp;
56 + if (tz->ops->get_trip_hyst) {
57 + tz->ops->get_trip_hyst(tz, trip, &hyst_temp);
58 + hyst_temp = trip_temp - hyst_temp;
60 tz->ops->get_trip_type(tz, trip, &trip_type);
63 trend = get_tz_trend(tz, trip);
65 - if (tz->temperature >= trip_temp) {
67 - trace_thermal_zone_trip(tz, trip, trip_type);
70 - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
71 - trip, trip_type, trip_temp, trend, throttle);
72 + dev_dbg(&tz->device,
73 + "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
74 + trip, trip_type, trip_temp, hyst_temp, trend, throttle);
76 mutex_lock(&tz->lock);
78 @@ -159,6 +160,18 @@ static void thermal_zone_trip_update(str
81 old_target = instance->target;
84 + * Lower the mitigation only if the temperature
85 + * goes below the hysteresis temperature.
87 + if (tz->temperature >= trip_temp ||
88 + (tz->temperature >= hyst_temp &&
89 + old_target != THERMAL_NO_TARGET)) {
91 + trace_thermal_zone_trip(tz, trip, trip_type);
94 instance->target = get_target_state(instance, trend, throttle);
95 dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
96 old_target, (int)instance->target);