All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: Frank Li <Frank.li@nxp.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-pm@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 1/3] thermal/drivers/imx91: Check status before reading data
Date: Mon, 15 Dec 2025 09:36:19 +0800	[thread overview]
Message-ID: <aT9mE63WtVqCxIPC@shlinux89> (raw)
In-Reply-To: <aTxQHLh0OD89oc/g@lizhi-Precision-Tower-5810>

On Fri, Dec 12, 2025 at 12:25:48PM -0500, Frank Li wrote:
>On Fri, Dec 12, 2025 at 03:51:14PM +0800, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> Per periodic mode from reference mannual:
>> Write 1b to CTRL1[START]. Wait until STATm[DRDYn] becomes 1.
>> Read DATAn[DATA_VAL]. It clears the corresponding STATm[DRDYn].
>> DATAn[DATA_VAL] and STATm[DRDYn_IF] keep refreshing at a periodic interval
>> of time, corresponding to PERIOD_CTRL[MEAS_FREQ].
>
>It should get last time sample value without check DRDYn_IF bit. it should
>only be a PERIOD_CTRL[MEAS_FREQ] delay.
>
>worst case get value at previous's PERIOD_CTRL[MEAS_FREQ] sample.
>
>PERIOD_CTRL[MEAS_FREQ] is quite short compare to call get_temp frequency.
>
>Do you get invalidate data?

No, this is just to align what we tested in LTS tree.
It should be fine to use last value, so drop this patch.

Thanks,
Peng

>
>>
>> Need to check STAT[DRDY] before reading the DATA register.
>>
>> And check the returned temperature to make sure it fits into the supported
>> range (-40°C to +125°C).
>
>https://lore.kernel.org/imx/aAIkAF_AHta8_vuS@mai.linaro.org/
>
>Do you answer Daniel Lezcano's question
>  ""When the measured temperature can be out of limits ?"  at v6 resend
>patch.
>
>Frank
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>  drivers/thermal/imx91_thermal.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/thermal/imx91_thermal.c b/drivers/thermal/imx91_thermal.c
>> index 9b20be03d6dec18553967548d0ca31d1c1fb387c..77e8e6a921c6af308b830c36721293c007256ca6 100644
>> --- a/drivers/thermal/imx91_thermal.c
>> +++ b/drivers/thermal/imx91_thermal.c
>> @@ -108,10 +108,20 @@ static int imx91_tmu_get_temp(struct thermal_zone_device *tz, int *temp)
>>  {
>>  	struct imx91_tmu *tmu = thermal_zone_device_priv(tz);
>>  	s16 data;
>> +	int ret;
>> +	u32 val;
>> +
>> +	ret = readl_relaxed_poll_timeout(tmu->base + IMX91_TMU_STAT0, val,
>> +					 val & IMX91_TMU_STAT0_DRDY0_IF_MASK, 1000,
>> +					 40000);
>> +	if (ret)
>> +		return -EAGAIN;
>>
>>  	/* DATA0 is 16bit signed number */
>>  	data = readw_relaxed(tmu->base + IMX91_TMU_DATA0);
>>  	*temp = imx91_tmu_to_mcelsius(data);
>> +	if (*temp < IMX91_TMU_TEMP_LOW_LIMIT || *temp > IMX91_TMU_TEMP_HIGH_LIMIT)
>> +		return -EAGAIN;
>>
>>  	return 0;
>>  }
>>
>> --
>> 2.37.1
>>

  reply	other threads:[~2025-12-15  1:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12  7:51 [PATCH 0/3] thermal/drivers/imx91: minor updates Peng Fan (OSS)
2025-12-12  7:51 ` [PATCH 1/3] thermal/drivers/imx91: Check status before reading data Peng Fan (OSS)
2025-12-12 17:25   ` Frank Li
2025-12-15  1:36     ` Peng Fan [this message]
2025-12-12  7:51 ` [PATCH 2/3] thermal/drivers/imx91: Drop extra spaces Peng Fan (OSS)
2025-12-12 17:29   ` Frank Li
2025-12-12  7:51 ` [PATCH 3/3] thermal/drivers/imx91: Drop macro for continues mode Peng Fan (OSS)

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=aT9mE63WtVqCxIPC@shlinux89 \
    --to=peng.fan@oss.nxp.com \
    --cc=Frank.li@nxp.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=peng.fan@nxp.com \
    --cc=rafael@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.