Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6b140d9 authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

drivers: step_wise: Add support for hysteresis temperature



Step wise governor will increase the mitigation when the temperature
goes above a threshold and will decrease the mitigation when the
temperature goes below the threshold. If there is a case where the
temperature is wavering around the threshold, the mitigation will be
applied and removed every iteration, which may not be efficient.
Introduction of hysteresis temperature could avoid this by relaxing
the mitigation only when the temperature goes below this lower
hysteresis value.

Add support for hysteresis temperature in the step wise governor. With
this support, step wise governor will relax the mitigation only
if the temperature goes below the hysteresis temperature.

Change-Id: I6367edaf83e558b2919826342c59346399f53d9b
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent caafe206
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@
 *       for this trip point
 *    d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit
 *       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
 *    b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
 *       state for this trip point, if the cooling state already
@@ -126,7 +126,7 @@ static void update_passive_instance(struct thermal_zone_device *tz,

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_trend trend;
	struct thermal_instance *instance;
@@ -134,22 +134,24 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
	int old_target;

	if (trip == THERMAL_TRIPS_NONE) {
		trip_temp = tz->forced_passive;
		hyst_temp = trip_temp = tz->forced_passive;
		trip_type = THERMAL_TRIPS_NONE;
	} else {
		tz->ops->get_trip_temp(tz, trip, &trip_temp);
		if (tz->ops->get_trip_hyst) {
			tz->ops->get_trip_hyst(tz, trip, &hyst_temp);
			hyst_temp = trip_temp - hyst_temp;
		} else {
			hyst_temp = trip_temp;
		}
		tz->ops->get_trip_type(tz, trip, &trip_type);
	}

	trend = get_tz_trend(tz, trip);

	if (tz->temperature >= trip_temp) {
		throttle = true;
		trace_thermal_zone_trip(tz, trip, trip_type);
	}

	dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
				trip, trip_type, trip_temp, trend, throttle);
	dev_dbg(&tz->device,
		"Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
		trip, trip_type, trip_temp, hyst_temp, trend, throttle);

	mutex_lock(&tz->lock);

@@ -158,6 +160,22 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
			continue;

		old_target = instance->target;
		/*
		 * Step wise has to lower the mitigation only if the
		 * temperature goes below the hysteresis temperature.
		 * Atleast, it has to hold on to mitigation device lower
		 * limit if the temperature is above 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);
		} else {
			throttle = false;
		}

		instance->target = get_target_state(instance, trend, throttle);
		dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
					old_target, (int)instance->target);