aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/gov_step_wise.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/gov_step_wise.c')
-rw-r--r--drivers/thermal/gov_step_wise.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c
index ea277c466d8d..d4baae3ff5b6 100644
--- a/drivers/thermal/gov_step_wise.c
+++ b/drivers/thermal/gov_step_wise.c
@@ -17,7 +17,7 @@
#include "thermal_core.h"
/*
- * If the temperature is higher than a trip point,
+ * If the temperature is higher than a hysteresis temperature,
* a. if the trend is THERMAL_TREND_RAISING, use higher cooling
* state for this trip point
* b. if the trend is THERMAL_TREND_DROPPING, use a lower cooling state
@@ -30,7 +30,7 @@
* equals lower limit, deactivate the thermal instance
*/
static unsigned long get_target_state(struct thermal_instance *instance,
- enum thermal_trend trend, bool throttle)
+ enum thermal_trend trend, bool throttle)
{
struct thermal_cooling_device *cdev = instance->cdev;
unsigned long cur_state;
@@ -45,14 +45,16 @@ static unsigned long get_target_state(struct thermal_instance *instance,
if (!instance->initialized) {
if (throttle)
- return clamp(cur_state + 1, instance->lower, instance->upper);
+ return clamp(cur_state + 1, instance->lower,
+ instance->upper);
return THERMAL_NO_TARGET;
}
if (throttle) {
if (trend == THERMAL_TREND_RAISING)
- return clamp(cur_state + 1, instance->lower, instance->upper);
+ return clamp(cur_state + 1, instance->lower,
+ instance->upper);
/*
* If the zone temperature is falling, the cooling level can
@@ -87,17 +89,34 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz,
enum thermal_trend trend = get_tz_trend(tz, trip);
int trip_id = thermal_zone_trip_id(tz, trip);
struct thermal_instance *instance;
+ int hyst_temp;
if (throttle)
trace_thermal_zone_trip(tz, trip_id, trip->type);
- dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
- trip_id, trip->type, trip_threshold, trend, throttle);
+ hyst_temp = trip->temperature - trip->hysteresis;
+
+ dev_dbg(&tz->device,
+ "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
+ trip_id, trip->type, trip->temperature, hyst_temp, trend,
+ throttle);
list_for_each_entry(instance, &td->thermal_instances, trip_node) {
int old_target;
old_target = instance->target;
+ throttle = false;
+ /*
+ * Lower the mitigation only if the temperature
+ * goes below the hysteresis temperature.
+ */
+ if (tz->temperature >= trip->temperature ||
+ (tz->temperature >= hyst_temp &&
+ old_target == instance->upper)) {
+ throttle = true;
+ trace_thermal_zone_trip(tz, trip_id, trip->type);
+ }
+
instance->target = get_target_state(instance, trend, throttle);
dev_dbg(&instance->cdev->device, "old_target=%d, target=%ld\n",
@@ -108,7 +127,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz,
instance->initialized = true;
- scoped_guard(cooling_dev, instance->cdev) {
+ scoped_guard(cooling_dev, instance->cdev)
+ {
instance->cdev->updated = false; /* cdev needs update */
}
}
@@ -128,7 +148,8 @@ static void step_wise_manage(struct thermal_zone_device *tz)
* is 'cooling down', it brings back the performance of the devices
* by one step.
*/
- for_each_trip_desc(tz, td) {
+ for_each_trip_desc(tz, td)
+ {
const struct thermal_trip *trip = &td->trip;
if (trip->temperature == THERMAL_TEMP_INVALID ||
@@ -139,14 +160,15 @@ static void step_wise_manage(struct thermal_zone_device *tz)
thermal_zone_trip_update(tz, td, td->threshold);
}
- for_each_trip_desc(tz, td) {
+ for_each_trip_desc(tz, td)
+ {
list_for_each_entry(instance, &td->thermal_instances, trip_node)
thermal_cdev_update(instance->cdev);
}
}
static struct thermal_governor thermal_gov_step_wise = {
- .name = "step_wise",
- .manage = step_wise_manage,
+ .name = "step_wise",
+ .manage = step_wise_manage,
};
THERMAL_GOVERNOR_DECLARE(thermal_gov_step_wise);