Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Haoning CHENG" <Haoning.CHENG@cn.bosch.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev,
	devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 3/3] thermal/drivers/imx: Add calibration offset support
Date: Tue, 14 Jul 2026 11:00:54 +0000	[thread overview]
Message-ID: <20260714110054.ECD931F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714-b4-symana21-11221-imx-thermal-support-upstream-6-18-v8-3-d54d8690e16e@cn.bosch.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing pm_runtime_put() on the error path in imx_get_temp() causes a runtime PM leak.
- [High] Missing pm_runtime_put() on the error path in imx_set_trip_temp() causes a runtime PM leak.
--

--- Patch [3]: [PATCH v8 3/3] thermal/drivers/imx: Add calibration offset support ---
commit a5acc3eb3799b4fe9bc9d1fba54049882d4b5c06
Author: Haoning CHENG <Haoning.CHENG@cn.bosch.com>

thermal/drivers/imx: Add calibration offset support

This commit adds support for an optional calibration offset to align
reported CPU temperatures with board-level measurements. It reads the
fsl,temp-calibration-offset-millicelsius property from the device tree
and applies it symmetrically to the threshold and temperature readings
for i.MX6/6SX/7D devices.

> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 168069a16e930..87ae2e40cc6fe 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
[ ... ]
> @@ -283,6 +290,7 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
>  		*temp = (n_meas - data->c1 + 25) * 1000;
>  	else
>  		*temp = data->c2 - n_meas * data->c1;
> +	*temp += data->calibration_offset;
>  
>  	/* Update alarm value to next higher trip point for TEMPMON_IMX6Q */
>  	if (data->socdata->version == TEMPMON_IMX6Q) {

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this file I
noticed a potential issue earlier in imx_get_temp(). Does the early return 
for invalid sensor data leak a PM runtime reference?

Earlier in the function, it calls pm_runtime_resume_and_get():

    ret = pm_runtime_resume_and_get(data->dev);
    if (ret < 0)
        return ret;

    regmap_read(map, soc_data->temp_data, &val);

    if ((val & soc_data->temp_valid_mask) == 0)
        return -EAGAIN;

If the sensor is polled before data is valid and it takes this -EAGAIN
path, shouldn't there be a matching pm_runtime_put(data->dev) to prevent
the device and its power domain from permanently remaining awake?

[Severity: High]
This is also a pre-existing issue, but the same pattern appears to exist
in imx_set_trip_temp() during bounds checking. Does this code leak the
PM runtime usage counter?

drivers/thermal/imx_thermal.c:imx_set_trip_temp() {
    ...
    ret = pm_runtime_resume_and_get(data->dev);
    if (ret < 0)
        return ret;

    if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
        return -EINVAL;
    ...
}

If a user writes an out-of-bounds temperature, this early return misses
the pm_runtime_put(data->dev) call. Could this be updated to properly
release the reference on this error path?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-b4-symana21-11221-imx-thermal-support-upstream-6-18-v8-0-d54d8690e16e@cn.bosch.com?part=3

  reply	other threads:[~2026-07-14 11:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 10:28 [PATCH v8 0/3] thermal: imx: Add calibration offset support Haoning CHENG via B4 Relay
2026-07-14 10:28 ` [PATCH v8 1/3] dt-bindings: thermal: imx: Document calibration offset property Haoning CHENG via B4 Relay
2026-07-14 10:28 ` [PATCH v8 2/3] thermal/drivers/imx: Fix rounding and clamp for i.MX7D alarm Haoning CHENG via B4 Relay
2026-07-14 14:29   ` Frank Li
2026-07-14 10:28 ` [PATCH v8 3/3] thermal/drivers/imx: Add calibration offset support Haoning CHENG via B4 Relay
2026-07-14 11:00   ` sashiko-bot [this message]
2026-07-14 14:35   ` Frank Li

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=20260714110054.ECD931F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=Haoning.CHENG@cn.bosch.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=robh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox