* [PATCH 00/10] thermal: Fix Critical and High issues reported by Sashiko
@ 2026-12-03 19:54 Lee Jones
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 19:54 ` [PATCH 10/10] thermal/drivers/imx91: Use pm_runtime_resume_and_get() in imx91_tmu_change_mode() Lee Jones
0 siblings, 2 replies; 6+ messages in thread
From: Lee Jones @ 2026-12-03 19:54 UTC (permalink / raw)
To: lee
Cc: linux-kernel, Niklas Söderlund, Rafael J. Wysocki,
Amit Kucheria, Aubrey Li, Bjorn Andersson, Daniel Lezcano,
Eduardo Valentin, Fabio Estevam, Frank Li, Geert Uytterhoeven,
imx, Jacob Pan, Jez Ng, Kuninori Morimoto, Len Brown, Lina Iyer,
linux-arm-kernel, linux-arm-msm, linux-pm, linux-renesas-soc,
Lukasz Luba, Magnus Damm, Matthew Garrett, Neil Horman, Peng Fan,
Pengfei Li, Pengutronix Kernel Team, Priyansh Jain,
Rajendra Nayak, Ricardo Neri, Rob Herring, Sascha Hauer,
Thara Gopinath, Zhang Rui
These issues were reported by Sashiko.
Cc: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Aubrey Li <aubrey.li@linux.intel.com>
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@kernel.org>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Frank Li <Frank.Li@nxp.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: imx@lists.linux.dev
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Jez Ng <jez@sfcompute.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Lina Iyer <lina.iyer@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: Lukasz Luba <lukasz.luba@arm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Matthew Garrett <mjg59@google.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Pengfei Li <pengfei.li_1@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Priyansh Jain <priyansh.jain@oss.qualcomm.com>
Cc: Rajendra Nayak <quic_rjendra@quicinc.com>
Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thara Gopinath <thara.gopinath@gmail.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Lee Jones (10):
thermal: intel: hfi: Pass byte size to alloc_pages_exact() and
free_pages_exact()
thermal: intel: hfi: Publish hfi_instance only after successful
initialisation
thermal: int3400: Clean up ODVP attributes after unregistering thermal
zone
thermal/drivers/qcom/tsens-v1: Validate sensor count before legacy
calibration
thermal/drivers/qcom/tsens: Bound sensor initialisation by num_sensors
thermal/drivers/rcar: Free IRQs before cancelling delayed work on
remove
thermal/drivers/imx91: Acquire runtime PM reference in
imx91_tmu_get_temp()
tools/thermal/tmon: Open log file with O_NOFOLLOW before validating
and truncating
thermal/drivers/qcom/tsens: Drop __init from ops init callbacks
thermal/drivers/imx91: Use pm_runtime_resume_and_get() in
imx91_tmu_change_mode()
drivers/thermal/imx91_thermal.c | 9 ++-
.../intel/int340x_thermal/int3400_thermal.c | 3 +-
drivers/thermal/intel/intel_hfi.c | 15 ++--
drivers/thermal/qcom/tsens-v0_1.c | 73 ++++++++-----------
drivers/thermal/qcom/tsens-v1.c | 60 ++++++---------
drivers/thermal/qcom/tsens-v2.c | 2 +-
drivers/thermal/qcom/tsens.c | 2 +-
drivers/thermal/renesas/rcar_thermal.c | 18 ++++-
tools/thermal/tmon/tmon.c | 36 ++++++---
9 files changed, 110 insertions(+), 108 deletions(-)
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 07/10] thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp()
2026-12-03 19:54 [PATCH 00/10] thermal: Fix Critical and High issues reported by Sashiko Lee Jones
@ 2026-12-03 19:54 ` Lee Jones
2026-12-03 20:11 ` sashiko-bot
2026-12-03 19:54 ` [PATCH 10/10] thermal/drivers/imx91: Use pm_runtime_resume_and_get() in imx91_tmu_change_mode() Lee Jones
1 sibling, 1 reply; 6+ messages in thread
From: Lee Jones @ 2026-12-03 19:54 UTC (permalink / raw)
To: lee, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Peng Fan, Pengfei Li, linux-pm, imx, linux-arm-kernel
Cc: linux-kernel, stable
The thermal core allows get_temp() to be called via sysfs even when the
thermal zone has been disabled and imx91_tmu_change_mode() has dropped
the runtime PM reference, gating the TMU clock. Reading IMX91_TMU_DATA0
in imx91_tmu_get_temp() while the clock is disabled causes an unclocked
register access.
Wrap the register read in imx91_tmu_get_temp() with
pm_runtime_resume_and_get() and pm_runtime_put().
Fixes: c411d8bf0699 ("thermal/drivers/imx91: Add support for i.MX91 thermal monitoring unit")
Closes: https://sashiko.dev/#/bug/linux-366503cb-0dfd-43b0-9c97-f75af5382e66
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/thermal/imx91_thermal.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/thermal/imx91_thermal.c b/drivers/thermal/imx91_thermal.c
index 6d0aba992244..c3a72df665a8 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;
}
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 10/10] thermal/drivers/imx91: Use pm_runtime_resume_and_get() in imx91_tmu_change_mode()
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 07/10] thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp() Lee Jones
@ 2026-12-03 19:54 ` Lee Jones
2026-12-03 20:21 ` Frank Li
1 sibling, 1 reply; 6+ messages in thread
From: Lee Jones @ 2026-12-03 19:54 UTC (permalink / raw)
To: lee, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Peng Fan, Pengfei Li, linux-pm, imx, linux-arm-kernel
Cc: linux-kernel, stable
When enabling the thermal zone, imx91_tmu_change_mode() calls
asynchronous pm_runtime_get() and immediately writes TMU control
registers before the device has resumed and enabled its clock. On
error, it also returns without dropping the incremented runtime PM
usage count.
Use synchronous pm_runtime_resume_and_get() instead.
Fixes: c411d8bf0699 ("thermal/drivers/imx91: Add support for i.MX91 thermal monitoring unit")
Closes: https://sashiko.dev/#/bug/linux-c0418783-a24c-4ee1-a794-72b47eb4dfce
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/thermal/imx91_thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/imx91_thermal.c b/drivers/thermal/imx91_thermal.c
index c3a72df665a8..dbd45a1910f5 100644
--- a/drivers/thermal/imx91_thermal.c
+++ b/drivers/thermal/imx91_thermal.c
@@ -213,7 +213,7 @@ static int imx91_tmu_change_mode(struct thermal_zone_device *tz, enum thermal_de
int ret;
if (mode == THERMAL_DEVICE_ENABLED) {
- ret = pm_runtime_get(tmu->dev);
+ ret = pm_runtime_resume_and_get(tmu->dev);
if (ret < 0)
return ret;
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 07/10] thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp()
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
0 siblings, 1 reply; 6+ messages in thread
From: sashiko-bot @ 2026-12-03 20:11 UTC (permalink / raw)
To: Lee Jones, imx; +Cc: Frank.Li
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?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203195529.3063246-1-lee@kernel.org?part=7
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 10/10] thermal/drivers/imx91: Use pm_runtime_resume_and_get() in imx91_tmu_change_mode()
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
0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2026-12-03 20:21 UTC (permalink / raw)
To: Lee Jones
Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Peng Fan, Pengfei Li, linux-pm, imx, linux-arm-kernel,
linux-kernel, stable
On Thu, Dec 03, 2026 at 07:54:21PM +0000, Lee Jones wrote:
> When enabling the thermal zone, imx91_tmu_change_mode() calls
> asynchronous pm_runtime_get() and immediately writes TMU control
> registers before the device has resumed and enabled its clock. On
> error, it also returns without dropping the incremented runtime PM
> usage count.
>
> Use synchronous pm_runtime_resume_and_get() instead.
>
> Fixes: c411d8bf0699 ("thermal/drivers/imx91: Add support for i.MX91 thermal monitoring unit")
> Closes: https://sashiko.dev/#/bug/linux-c0418783-a24c-4ee1-a794-72b47eb4dfce
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/thermal/imx91_thermal.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/imx91_thermal.c b/drivers/thermal/imx91_thermal.c
> index c3a72df665a8..dbd45a1910f5 100644
> --- a/drivers/thermal/imx91_thermal.c
> +++ b/drivers/thermal/imx91_thermal.c
> @@ -213,7 +213,7 @@ static int imx91_tmu_change_mode(struct thermal_zone_device *tz, enum thermal_de
> int ret;
>
> if (mode == THERMAL_DEVICE_ENABLED) {
> - ret = pm_runtime_get(tmu->dev);
> + ret = pm_runtime_resume_and_get(tmu->dev);
> if (ret < 0)
> return ret;
>
> --
> 2.56.1.911.g883d8bcb20-goog
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 07/10] thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp()
2026-12-03 20:11 ` sashiko-bot
@ 2026-12-03 20:34 ` Frank Li
0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2026-12-03 20:34 UTC (permalink / raw)
To: sashiko-reviews; +Cc: Lee Jones, imx, Frank.Li
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-03 20:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox