linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anson Huang <Anson.Huang@nxp.com>
To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org,
	s.hauer@pengutronix.de, shawnguo@kernel.org,
	kernel@pengutronix.de, festevam@gmail.com,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: Linux-imx@nxp.com
Subject: [PATCH] thermal: imx: Correct run_measurement check method
Date: Mon, 28 Sep 2020 13:01:43 +0800	[thread overview]
Message-ID: <1601269303-12167-1-git-send-email-Anson.Huang@nxp.com> (raw)

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")
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/thermal/imx_thermal.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 2c7473d..9f00182 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -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);
-- 
2.7.4


                 reply	other threads:[~2020-09-28  5:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1601269303-12167-1-git-send-email-Anson.Huang@nxp.com \
    --to=anson.huang@nxp.com \
    --cc=Linux-imx@nxp.com \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).