Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "HaoNing Cheng" <Haoning.CHENG@cn.bosch.com>
Cc: conor+dt@kernel.org, robh@kernel.org, imx@lists.linux.dev,
	Frank.Li@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/2] thermal/drivers/imx: Add calibration offset support
Date: Thu, 09 Jul 2026 05:54:07 +0000	[thread overview]
Message-ID: <20260709055408.040201F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709-b4-symana21-11221-imx-thermal-support-upstream-6-18-v1-2-00f88f42930b@cn.bosch.com>

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

New issues:
- [High] The i.MX7D alarm temperature calculation truncates towards zero, leading to an early hardware trigger and an IRQ storm when the calibration offset is not a multiple of 1000.

Pre-existing issues:
- [High] The computed `alarm_value` is shifted and written to the high alarm control hardware register without bitwise masking, allowing out-of-bounds or negative values to corrupt adjacent register fields.
--

--- Patch [2]: [PATCH 2/2] thermal/drivers/imx: Add calibration offset support ---
commit b15c0dce27dccd66bd58b8f22bb746933db67a41
Author: HaoNing Cheng <Haoning.CHENG@cn.bosch.com>

thermal/drivers/imx: Add calibration offset support

Some boards need a small per-design correction to align the reported CPU
temperature with board-level measurements.

> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 5aaacbc534786..3e1eec2fc3613 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -241,7 +242,7 @@ static void imx_set_alarm_temp(struct imx_thermal_data *data,
>  	data->alarm_temp = alarm_temp;
>  
>  	if (data->socdata->version == TEMPMON_IMX7D)
> -		alarm_value = alarm_temp / 1000 + data->c1 - 25;
> +		alarm_value = (alarm_temp - data->calibration_offset) / 1000 + data->c1 - 25;

[Severity: High]
If the device tree property fsl,temp-calibration-offset-millicelsius is set
to a value that is not a multiple of 1000 (e.g., 500), does this integer
division truncate towards zero and cause an early hardware alarm trigger?

When the hardware asserts the thermal interrupt due to the truncated threshold,
the IRQ handler would read the temperature, calculate that the temperature is
still below the alarm_temp, and immediately re-enable the IRQ. Could this
regression lead to an infinite IRQ storm?

[Severity: High]
This is a pre-existing issue, but the computed alarm_value is shifted and
written to the high alarm control register shortly after this without masking:

    regmap_write(map, soc_data->high_alarm_ctrl + REG_SET,
                 alarm_value << soc_data->high_alarm_shift);

Since the newly introduced calibration offset could make alarm_value negative
or exceed its 9-bit mask, shifting a negative signed value will set the upper
bits to 1. 

Because this is a bit-set operation, could writing this value overwrite and
corrupt the adjacent IMX7_TEMPSENSE0_PANIC_ALARM field (bits 18-26)? The same
pattern appears to exist for the panic alarm threshold in imx_set_panic_temp().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-b4-symana21-11221-imx-thermal-support-upstream-6-18-v1-0-00f88f42930b@cn.bosch.com?part=2

      reply	other threads:[~2026-07-09  5:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  5:43 [PATCH 0/2] thermal: imx: Add calibration offset support HaoNing Cheng via B4 Relay
2026-07-09  5:43 ` [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property HaoNing Cheng via B4 Relay
2026-07-09  5:50   ` sashiko-bot
2026-07-09  6:26   ` Rob Herring (Arm)
2026-07-09  5:43 ` [PATCH 2/2] thermal/drivers/imx: Add calibration offset support HaoNing Cheng via B4 Relay
2026-07-09  5:54   ` sashiko-bot [this message]

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=20260709055408.040201F000E9@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