From: Frank Li <Frank.li@nxp.com>
To: Jacky Bai <ping.bai@nxp.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v5 3/4] thermal: qoriq: workaround unexpected temperature readings from tmu
Date: Tue, 21 Apr 2026 23:56:46 -0400 [thread overview]
Message-ID: <aehG_hBSostFyhNg@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <VI1PR04MB6861B0C33CF3030D6C9293B8872C2@VI1PR04MB6861.eurprd04.prod.outlook.com>
On Tue, Apr 21, 2026 at 09:56:18AM +0000, Jacky Bai wrote:
> > Subject: Re: [PATCH v5 3/4] thermal: qoriq: workaround unexpected
> > temperature readings from tmu
> >
>
> [...]
>
> > >
> > > + /* ERR052243: If a raising or falling edge happens, try later */
> > > + if (qoriq_tmu_has_errata(qdata->drvdata, TMU_ERR052243)) {
> > > + regmap_read(qdata->regmap, REGS_TIDR, &tidr);
> > > + if (tidr & TEMP_RATE_IRQ_MASK) {
> > > + regmap_write(qdata->regmap, REGS_TIDR,
> > TEMP_RATE_IRQ_MASK);
> > > + return -EAGAIN;
> > > + }
> > > + }
> > > +
> > > if (regmap_read_poll_timeout(qdata->regmap,
> > > REGS_TRITSR(qsensor->id),
> > > val,
> > > @@ -130,6 +159,15 @@ static int tmu_get_temp(struct
> > thermal_zone_device *tz, int *temp)
> > > 10 * USEC_PER_MSEC))
> > > return -ENODATA;
> > >
> > > + /*ERR052243: If a raising or falling edge happens, try later */
> > > + if (qoriq_tmu_has_errata(qdata->drvdata, TMU_ERR052243)) {
> > > + regmap_read(qdata->regmap, REGS_TIDR, &tidr);
> > > + if (tidr & TEMP_RATE_IRQ_MASK) {
> > > + regmap_write(qdata->regmap, REGS_TIDR,
> > TEMP_RATE_IRQ_MASK);
> > > + return -EAGAIN;
> > > + }
> > > + }
> > > +
> >
> > The above two code blocks are the same. Use helper function to avoid
> > duplicat code. And why need check twice?
> >
> > ret = qoriq_tmu_err052243()
> > if (ret)
> > return ret;
> >
>
> The first check is to make sure no error already happened. if any error, no need
> to polling read the sensor value from tmu, return early to save time. The secondary
> check is to make sure the sensor value just read out is still a valid one as the error may
> happen after the first check.
>
> It should be ok to remove the first check. As the error only happens in some rare
> corner case, the sensor read polling delay is acceptable.
>
> If only keep the secondary check, I think no need to wrap this code block into a helper function?
Yes
Frank
>
> BR
>
> > Frank
> >
> > > if (qdata->ver == TMU_VER1) {
> > > *temp = (val & GENMASK(7, 0)) * MILLIDEGREE_PER_DEGREE;
> > > } else {
> > > @@ -247,6 +285,14 @@ static void qoriq_tmu_init_device(struct
> > qoriq_tmu_data *data)
> > > regmap_write(data->regmap, REGS_V2_TEUMR(0), teumr0_val);
> > > }
> > >
> > > + /* ERR052243: Set the raising & falling edge monitor */
> > > + if (qoriq_tmu_has_errata(data->drvdata, TMU_ERR052243)) {
> > > + regmap_write(data->regmap, TMRTRCTR, TMRTRCTR_EN |
> > > + FIELD_PREP(TMRTRCTR_TEMP_MASK,
> > TEMP_RATE_THR_LVL));
> > > + regmap_write(data->regmap, TMFTRCTR, TMFTRCTR_EN |
> > > + FIELD_PREP(TMFTRCTR_TEMP_MASK,
> > TEMP_RATE_THR_LVL));
> > > +
> > > + }
> > > /* Disable monitoring */
> > > regmap_write(data->regmap, REGS_TMR, TMR_DISABLE); } @@
> > -400,6
> > > +446,7 @@ static const struct tmu_drvdata imx8mq_tmu_data = {
> > >
> > > static const struct tmu_drvdata imx93_data = {
> > > .teumr0 = TEUMR0_V21,
> > > + .tmu_errata = TMU_ERR052243,
> > > };
> > >
> > > static const struct of_device_id qoriq_tmu_match[] = {
> > >
> > > --
> > > 2.34.1
> > >
next prev parent reply other threads:[~2026-04-22 3:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 7:42 [PATCH v5 0/4] Update the thermal support for imx93 Jacky Bai
2026-04-21 7:42 ` [PATCH v5 1/4] dt-bindings: thermal: qoriq: Add compatible string " Jacky Bai
2026-04-21 7:42 ` [PATCH v5 2/4] thermal: qoriq: add i.MX93 tmu support Jacky Bai
2026-04-21 9:17 ` Daniel Baluta
2026-04-21 9:59 ` Jacky Bai
2026-04-21 7:42 ` [PATCH v5 3/4] thermal: qoriq: workaround unexpected temperature readings from tmu Jacky Bai
2026-04-21 9:11 ` Frank Li
2026-04-21 9:56 ` Jacky Bai
2026-04-22 3:56 ` Frank Li [this message]
2026-04-21 7:42 ` [PATCH v5 4/4] arm64: dts: imx93: update the tmu compatible string Jacky Bai
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=aehG_hBSostFyhNg@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=ping.bai@nxp.com \
--cc=rafael@kernel.org \
--cc=robh@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