提交 c7ae2177 编写于 作者: R Ram Chandrasekar 提交者: Zheng Zengkai

drivers: thermal: step_wise: add support for hysteresis

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

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: NRam Chandrasekar <rkumbako@codeaurora.org>
Signed-off-by: NLina Iyer <ilina@codeaurora.org>
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 f543650a
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* for this trip point * for this trip point
* d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit
* for this trip point * for this trip point
* If the temperature is lower than a trip point, * If the temperature is lower than a hysteresis temperature,
* a. if the trend is THERMAL_TREND_RAISING, do nothing * a. if the trend is THERMAL_TREND_RAISING, do nothing
* b. if the trend is THERMAL_TREND_DROPPING, use lower cooling * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
* state for this trip point, if the cooling state already * state for this trip point, if the cooling state already
...@@ -115,7 +115,7 @@ static void update_passive_instance(struct thermal_zone_device *tz, ...@@ -115,7 +115,7 @@ static void update_passive_instance(struct thermal_zone_device *tz,
static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
{ {
int trip_temp; int trip_temp, hyst_temp;
enum thermal_trip_type trip_type; enum thermal_trip_type trip_type;
enum thermal_trend trend; enum thermal_trend trend;
struct thermal_instance *instance; struct thermal_instance *instance;
...@@ -123,22 +123,23 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) ...@@ -123,22 +123,23 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
int old_target; int old_target;
if (trip == THERMAL_TRIPS_NONE) { if (trip == THERMAL_TRIPS_NONE) {
trip_temp = tz->forced_passive; hyst_temp = trip_temp = tz->forced_passive;
trip_type = THERMAL_TRIPS_NONE; trip_type = THERMAL_TRIPS_NONE;
} else { } else {
tz->ops->get_trip_temp(tz, trip, &trip_temp); tz->ops->get_trip_temp(tz, trip, &trip_temp);
hyst_temp = trip_temp;
if (tz->ops->get_trip_hyst) {
tz->ops->get_trip_hyst(tz, trip, &hyst_temp);
hyst_temp = trip_temp - hyst_temp;
}
tz->ops->get_trip_type(tz, trip, &trip_type); tz->ops->get_trip_type(tz, trip, &trip_type);
} }
trend = get_tz_trend(tz, trip); trend = get_tz_trend(tz, trip);
if (tz->temperature >= trip_temp) { dev_dbg(&tz->device,
throttle = true; "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
trace_thermal_zone_trip(tz, trip, trip_type); trip, trip_type, trip_temp, hyst_temp, trend, throttle);
}
dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
trip, trip_type, trip_temp, trend, throttle);
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
...@@ -147,6 +148,18 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) ...@@ -147,6 +148,18 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
continue; continue;
old_target = instance->target; old_target = instance->target;
throttle = false;
/*
* Lower the mitigation only if the temperature
* goes below the hysteresis temperature.
*/
if (tz->temperature >= trip_temp ||
(tz->temperature >= hyst_temp &&
old_target != THERMAL_NO_TARGET)) {
throttle = true;
trace_thermal_zone_trip(tz, trip, trip_type);
}
instance->target = get_target_state(instance, trend, throttle); instance->target = get_target_state(instance, trend, throttle);
dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
old_target, (int)instance->target); old_target, (int)instance->target);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册