From: Frank Li <Frank.li@oss.nxp.com>
To: sashiko-reviews@lists.linux.dev
Cc: Lee Jones <lee@kernel.org>, imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH 07/10] thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp()
Date: Thu, 3 Dec 2026 14:34:25 -0600 [thread overview]
Message-ID: <axHSUb70Icw4iIL5@SMW015318> (raw)
In-Reply-To: <sashiko-outbox-248596@kernel.org>
On Thu, Dec 03, 2026 at 08:11:17PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] thermal/imx91: imx91_tmu_get_temp() reads stale DATA0 when
> zone is disabled
> --
>
> commit 6c2200e167fb50e996061c6b352e037ffc580431
> Author: Lee Jones <lee@kernel.org>
>
> thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp()
>
> This commit wraps the IMX91_TMU_DATA0 register read in imx91_tmu_get_temp()
> with pm_runtime_resume_and_get() and pm_runtime_put() to avoid unclocked
> register access when the thermal zone is disabled.
>
> > diff --git a/drivers/thermal/imx91_thermal.c b/drivers/thermal/imx91_thermal.c
> > index 6d0aba992244b..c3a72df665a81 100644
> > --- a/drivers/thermal/imx91_thermal.c
> > +++ b/drivers/thermal/imx91_thermal.c
> > @@ -110,11 +110,18 @@ 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;
> > +
> > + ret = pm_runtime_resume_and_get(tmu->dev);
> > + if (ret < 0)
> > + return ret;
> >
> > /* DATA0 is 16bit signed number */
> > data = readw_relaxed(tmu->base + IMX91_TMU_DATA0);
> > *temp = imx91_tmu_to_mcelsius(data);
> >
> > + pm_runtime_put(tmu->dev);
> > +
> > return 0;
> > }
>
> [Severity: Medium]
> Can this return stale temperature data from IMX91_TMU_DATA0 when the thermal
> zone is disabled?
>
> Disabling the zone in imx91_tmu_change_mode() stops measurements via
> imx91_tmu_start(tmu, false) before calling pm_runtime_put().
> imx91_tmu_runtime_resume() only re-enables the clock and IMX91_TMU_CTRL1_EN,
> without starting a measurement or waiting for a conversion to complete.
>
> Reading sysfs temp while disabled then succeeds with whatever stale or zero
> value sits in IMX91_TMU_DATA0. Should imx91_tmu_get_temp() return -EAGAIN
> when the zone is disabled, or start a conversion and wait for data ready
> before reading?
Yes, this is problem. Ideally tmu framework should check status instead of
each driver do that.
In https://lore.kernel.org/all/b69fe059-5aff-4fbd-879e-166d67310563@linaro.org/
change to use change_mode callback.
Frank
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261203195529.3063246-1-lee@kernel.org?part=7
next prev parent reply other threads:[~2026-12-03 20:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 19:54 [PATCH 00/10] thermal: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03 19:54 ` [PATCH 01/10] thermal: intel: hfi: Pass byte size to alloc_pages_exact() and free_pages_exact() Lee Jones
2026-12-04 20:22 ` Rafael J. Wysocki (Intel)
2026-12-03 19:54 ` [PATCH 02/10] thermal: intel: hfi: Publish hfi_instance only after successful initialisation Lee Jones
2026-12-04 20:29 ` Rafael J. Wysocki (Intel)
2026-12-03 19:54 ` [PATCH 03/10] thermal: int3400: Clean up ODVP attributes after unregistering thermal zone Lee Jones
2026-12-04 20:24 ` Rafael J. Wysocki (Intel)
2026-12-03 19:54 ` [PATCH 04/10] thermal/drivers/qcom/tsens-v1: Validate sensor count before legacy calibration Lee Jones
2026-12-03 19:54 ` [PATCH 05/10] thermal/drivers/qcom/tsens: Bound sensor initialisation by num_sensors Lee Jones
2026-12-03 19:54 ` [PATCH 06/10] thermal/drivers/rcar: Free IRQs before cancelling delayed work on remove Lee Jones
2026-12-04 17:15 ` Niklas Söderlund
2026-12-05 5:38 ` Yaohan Li
2026-12-03 19:54 ` [PATCH 07/10] thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp() Lee Jones
2026-12-03 20:11 ` sashiko-bot
2026-12-03 20:34 ` Frank Li [this message]
2026-12-04 10:40 ` Peng Fan (OSS)
2026-12-03 19:54 ` [PATCH 08/10] tools/thermal/tmon: Open log file with O_NOFOLLOW before validating and truncating Lee Jones
2026-12-04 20:34 ` Rafael J. Wysocki (Intel)
2026-12-03 19:54 ` [PATCH 09/10] thermal/drivers/qcom/tsens: Drop __init from ops init callbacks Lee Jones
2026-12-03 19:54 ` [PATCH 10/10] thermal/drivers/imx91: Use pm_runtime_resume_and_get() in imx91_tmu_change_mode() Lee Jones
2026-12-03 20:21 ` Frank Li
2026-12-04 10:40 ` 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=axHSUb70Icw4iIL5@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=lee@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.