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

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

msm: thermal: Handle the case where low threshold is not set



There is a possibility when the emergency mitigation
is applied and the clear threshold is not set.
This could be due to thermal-engine requesting for
the same mitigation and the mitigation getting
honored after emergency threshold is triggered.

This will create a situation where the low threshold
for the emergency mitigation not being set and the
mitigation will never be cleared.

CRs-Fixed: 744790
Change-Id: I382662ab2e51174c5d4949df88b3cae47448a6ba
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent f1a9f6d4
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -66,6 +66,16 @@
		} \
	} while (0)

#define UPDATE_THRESHOLD_SET(_val, _trip) do {		\
	if (_trip == THERMAL_TRIP_CONFIGURABLE_HI)	\
		_val |= 1;				\
	else if (_trip == THERMAL_TRIP_CONFIGURABLE_LOW)\
		_val |= 2;				\
} while (0)

#define IS_HI_THRESHOLD_SET(_val) (_val & 1)
#define IS_LOW_THRESHOLD_SET(_val) (_val & 2)

static struct msm_thermal_data msm_thermal_info;
static struct delayed_work check_temp_work;
static bool core_control_enabled;
@@ -1692,7 +1702,7 @@ static int set_threshold(uint32_t zone_id,
			zone_id, ret);
		goto set_threshold_exit;
	}

	pr_debug("Sensor:[%d] temp:[%ld]\n", zone_id, temp);
	while (i < MAX_THRESHOLD) {
		switch (threshold[i].trip) {
		case THERMAL_TRIP_CONFIGURABLE_HI:
@@ -1701,6 +1711,8 @@ static int set_threshold(uint32_t zone_id,
					&threshold[i]);
				if (ret)
					goto set_threshold_exit;
				UPDATE_THRESHOLD_SET(ret,
					THERMAL_TRIP_CONFIGURABLE_HI);
			}
			break;
		case THERMAL_TRIP_CONFIGURABLE_LOW:
@@ -1709,6 +1721,8 @@ static int set_threshold(uint32_t zone_id,
					&threshold[i]);
				if (ret)
					goto set_threshold_exit;
				UPDATE_THRESHOLD_SET(ret,
					THERMAL_TRIP_CONFIGURABLE_LOW);
			}
			break;
		default:
@@ -2054,9 +2068,12 @@ static __ref int do_hotplug(void *data)
		for_each_possible_cpu(cpu) {
			if (hotplug_enabled &&
				cpus[cpu].hotplug_thresh_clear) {
				set_threshold(cpus[cpu].sensor_id,
				ret = set_threshold(cpus[cpu].sensor_id,
				&cpus[cpu].threshold[HOTPLUG_THRESHOLD_HIGH]);

				if (cpus[cpu].offline
					&& !IS_LOW_THRESHOLD_SET(ret))
					cpus[cpu].offline = 0;
				cpus[cpu].hotplug_thresh_clear = false;
			}
			if (cpus[cpu].offline || cpus[cpu].user_offline)
@@ -2645,9 +2662,14 @@ static __ref int do_freq_mitigation(void *data)
reset_threshold:
			if (freq_mitigation_enabled &&
				cpus[cpu].freq_thresh_clear) {
				set_threshold(cpus[cpu].sensor_id,
				ret = set_threshold(cpus[cpu].sensor_id,
				&cpus[cpu].threshold[FREQ_THRESHOLD_HIGH]);

				if (cpus[cpu].max_freq
					&& !IS_LOW_THRESHOLD_SET(ret)) {
					cpus[cpu].max_freq = false;
					complete(&freq_mitigation_complete);
				}
				cpus[cpu].freq_thresh_clear = false;
			}
		}
@@ -2912,7 +2934,7 @@ int therm_set_threshold(struct threshold_info *thresh_inp)
		thresh_ptr->trip_triggered = -1;
		err = set_threshold(thresh_ptr->sensor_id,
			thresh_ptr->threshold);
		if (err) {
		if (err < 0) {
			ret = err;
			err = 0;
		}