mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
drivers: thermal: step_wise: add support for hysteresis
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: Ram Chandrasekar <rkumbako@codeaurora.org> Signed-off-by: Lina Iyer <ilina@codeaurora.org> drivers: thermal: step_wise: avoid throttling at hysteresis temperature after dropping below it Signed-off-by: Serge Schneider <serge@raspberrypi.org> Fix hysteresis support in gov_step_wise.c Directly get hyst value instead of going through an optional and, now, unimplemented function. Signed-off-by: Jürgen Kreileder <jk@blackdown.de>
This commit is contained in:
committed by
Dom Cobley
parent
9615c59d94
commit
ecac91286b
@@ -17,16 +17,16 @@
|
||||
#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
|
||||
* for this trip point, but keep the cooling state above the applicable
|
||||
* minimum
|
||||
* 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
|
||||
* b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
|
||||
* state for this trip point, if the cooling state already
|
||||
* b. if the trend is THERMAL_TREND_DROPPING, use the minimum applicable
|
||||
* cooling state for this trip point, or if the cooling state already
|
||||
* equals lower limit, deactivate the thermal instance
|
||||
*/
|
||||
static unsigned long get_target_state(struct thermal_instance *instance,
|
||||
@@ -83,23 +83,36 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz,
|
||||
int trip_threshold)
|
||||
{
|
||||
const struct thermal_trip *trip = &td->trip;
|
||||
int hyst_temp = trip->temperature - trip->hysteresis;
|
||||
bool throttle = tz->temperature >= hyst_temp;
|
||||
enum thermal_trend trend = get_tz_trend(tz, trip);
|
||||
int trip_id = thermal_zone_trip_id(tz, trip);
|
||||
struct thermal_instance *instance;
|
||||
bool throttle = false;
|
||||
|
||||
if (tz->temperature >= trip_threshold) {
|
||||
throttle = true;
|
||||
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);
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user