From: sashiko-bot@kernel.org
To: "Ben Grisdale" <bengris32@protonmail.ch>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 4/4] thermal/drivers/mediatek: Add MT6797 support
Date: Thu, 03 Dec 2026 12:53:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-247796@kernel.org> (raw)
In-Reply-To: <20261203-mt6797-thermal-support-v1-4-19595fe11814@protonmail.ch>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] thermal/mediatek: negative signed left shift in
raw_to_mcelsius_v1_5()
- [Medium] thermal/mediatek: raw_to_mcelsius_v1_5() returns 0 instead of
invalid temp
--
commit f202360240c2d8c5a36415fdb23e266d0c8c9198
Author: Roman Vivchar <rva333@protonmail.com>
thermal/drivers/mediatek: Add MT6797 support
This commit adds MT6797 thermal controller support to the MediaTek
AUXADC thermal driver, wiring it to the v1.5 temperature conversion
formula and registering the mediatek,mt6797-thermal compatible.
> diff --git a/drivers/thermal/mediatek/auxadc_thermal.c b/drivers/thermal/mediatek/auxadc_thermal.c
> index 319ab741e325b..a8d22af7d4ea6 100644
> --- a/drivers/thermal/mediatek/auxadc_thermal.c
> +++ b/drivers/thermal/mediatek/auxadc_thermal.c
[ ... ]
> @@ -623,6 +672,51 @@ static const struct mtk_thermal_data mt2712_thermal_data = {
> .version = MTK_THERMAL_V1,
> };
>
> +/*
> + * The MT6797 thermal controller has six banks. Each bank can read up to
> + * four temperature sensors simultaneously. It has a total of 4
> + * temperature sensors used across its banks.
> + */
> +static const struct mtk_thermal_data mt6797_thermal_data = {
[ ... ]
> + .version = MTK_THERMAL_V1_5,
[Severity: Medium]
Does selecting MTK_THERMAL_V1_5 trigger undefined behavior from a
negative signed left shift in raw_to_mcelsius_v1_5()?
Because MediaTek thermal sensors have a negative temperature
coefficient, s32 tmp is negative at normal operating temperatures above
the calibration room temperature (default 20 C). MT6797 is the first
SoC to use raw_to_mcelsius_v1_5():
drivers/thermal/mediatek/auxadc_thermal.c:raw_to_mcelsius_v1_5() {
...
tmp = tmp - (tmp << 1);
return (format_2 + tmp) * 100;
}
Left-shifting a negative signed integer triggers UBSAN
shift-out-of-bounds splats (or traps under CONFIG_UBSAN_TRAP) on every
temperature read. Returning (format_2 - tmp) * 100, matching
raw_to_mcelsius_v2(), avoids the shift.
[Severity: Medium]
Can raw_to_mcelsius_v1_5() also report a bogus 0 C reading instead of
-ENODATA when an MSR register reads 0?
Right after mtk_thermal_probe() registers the thermal zone, TEMP_MSR0..3
can read 0 until the first AUXADC conversion completes (up to 60 ms).
raw_to_mcelsius_v1_5() short-circuits raw == 0 to return 0 mC, which
passes mtk_thermal_temp_is_valid() in mtk_thermal_bank_temperature()
instead of being converted to THERMAL_TEMP_INVALID.
That causes thermal_zone_get_temp() to return 0 C rather than -ENODATA,
and max() across banks will mask valid sub-zero temperatures with 0 C.
Returning THERMAL_TEMP_INVALID when raw == 0 (or dropping the early
return so mtk_thermal_temp_is_valid() rejects it) would prevent this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-mt6797-thermal-support-v1-0-19595fe11814@protonmail.ch?part=4
prev parent reply other threads:[~2026-12-03 12:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:03 [PATCH 0/4] thermal/drivers/mediatek: Sampling mode, mobile calibration & MT6797 support Ben Grisdale via B4 Relay
2026-12-03 12:03 ` [PATCH 1/4] thermal/drivers/mediatek: Add efuse calibration support for mobile SoCs Ben Grisdale via B4 Relay
2026-12-03 12:28 ` sashiko-bot
2026-12-03 12:03 ` [PATCH 2/4] thermal/drivers/mediatek: Add support for setting sampling mode per SoC Ben Grisdale via B4 Relay
2026-12-03 12:03 ` [PATCH 3/4] dt-bindings: thermal: mediatek,thermal: Add MT6797 Ben Grisdale via B4 Relay
2026-12-03 12:03 ` [PATCH 4/4] thermal/drivers/mediatek: Add MT6797 support Ben Grisdale via B4 Relay
2026-12-03 12:53 ` 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=sashiko-outbox-247796@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bengris32@protonmail.ch \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--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