Skip to contentSkip to conversation

thermal: imx: Correct run_measurement check method

PATCH New Anson Huang 1 participant 1 message Sep 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: imx: Correct run_measurement check method

It is incorrect to use irq_enabled flag for run_measurement check, as irq_enabled is NOT always equal to thermal mode, when temperature is higher than passive point, an alarm irq will be pending, and irq_enabled flag will be set to false while thermal mode is still enabled, then the following temperature read will power down thermal sensor, and next time irq_enabled flag will set to true when temperature drop to below than passive point, next temperature read will fail due to thermal sensor is NOT power up at all, the error log is as below:

  root@imx6qdlsolo:~# cat /sys/class/thermal/thermal_zone0/temp
  cat: /sys/class/thermal/thermal_zone0/temp: Resource temporarily unavailable

So, it should read the thermal sensor's power down bit to decide whether to run measurement.

Fixes d92ed2c9d3ff ("thermal: imx: Use driver's local data to decide whether to run a measurement")
---
 drivers/thermal/imx_thermal.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/imx_thermal.c +2 -1
index 2c7473d..9f00182 100644
@@ -255,7 +255,8 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
 	bool wait, run_measurement;
 	u32 val;
 
-	run_measurement = !data->irq_enabled;
+	regmap_read(map, soc_data->sensor_ctrl, &val);
+	run_measurement = val & soc_data->power_down_mask;
 	if (!run_measurement) {
 		/* Check if a measurement is currently in progress */
 		regmap_read(map, soc_data->temp_data, &val);
Signature · 1 line
2.7.4