From: sashiko-bot@kernel.org
To: "Binbin Zhou" <zhoubinbin@loongson.cn>
Cc: mfd@lists.linux.dev, lee@kernel.org, robh@kernel.org,
devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 2/5] thermal/drivers/loongson2: Move thermal_ops to chip_data for SoC scalability
Date: Tue, 04 Aug 2026 12:55:39 +0000 [thread overview]
Message-ID: <20260804125540.3741E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <7fe74a58c164da2e7a897598142f28df0e5ef0c4.1785829933.git.zhoubinbin@loongson.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The driver misuses the `clamp()` macro when setting temperature thresholds, failing to bound the requested trip values to the hardware's supported range `[-40, 125]`.
--
--- Patch [2]: [PATCH v4 2/5] thermal/drivers/loongson2: Move thermal_ops to chip_data for SoC scalability ---
commit 1f38b1d9f1db90805ef5765872a4c9de0db11e9c
Author: Binbin Zhou <zhoubinbin@loongson.cn>
thermal/drivers/loongson2: Move thermal_ops to chip_data for SoC scalability
In preparation for supporting additional Loongson SoCs, this commit
relocates the thermal zone device operations pointer from the probe
routine to the per-SoC chip_data structure. This eliminates the need to
add conditional branches in probe() when a new SoC is introduced.
> diff --git a/drivers/thermal/loongson2_thermal.c b/drivers/thermal/loongson2_thermal.c
> index 5f47fa51fb907..1a8ca2cd06f1b 100644
> --- a/drivers/thermal/loongson2_thermal.c
> +++ b/drivers/thermal/loongson2_thermal.c
[ ... ]
> @@ -160,7 +156,7 @@ static int loongson2_thermal_probe(struct platform_device *pdev)
> loongson2_thermal_set(data, 0, 0, false);
>
[Severity: High]
This is a pre-existing issue, but does loongson2_thermal_set() misuse the
clamp macro when setting temperature thresholds?
Looking at drivers/thermal/loongson2_thermal.c:loongson2_thermal_set(), the
arguments to clamp() appear to be in the wrong order:
/* Set low temperature threshold */
loongson2_set_ctrl_regs(data, clamp(-40, low, high), true, enable);
/* Set high temperature threshold */
loongson2_set_ctrl_regs(data, clamp(125, low, high), false, enable);
Because the clamp macro arguments are swapped (using clamp(-40, low, high)
instead of clamp(low, -40, 125) and clamp(high, -40, 125)), values like a
high trip point > 155C are not bounded to 125.
If root sets a thermal trip point > 155C via sysfs, adding HECTO (100) to
156+ results in a value > 255.
When this is written to the 16-bit hardware register, can it overflow into
bit 8 (the enable bit), overwriting the control state and truncating the
threshold to an incorrect value?
Could this cause immediate and continuous hardware thermal alarms (IRQ
storm), rendering the system unusable?
> for (i = 0; i <= LOONGSON2_MAX_SENSOR_SEL_NUM; i++) {
> - tzd = devm_thermal_of_zone_register(dev, i, data, thermal_ops);
> + tzd = devm_thermal_of_zone_register(dev, i, data, data->chip_data->thermal_ops);
> if (!IS_ERR(tzd))
> break;
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1785829933.git.zhoubinbin@loongson.cn?part=2
next prev parent reply other threads:[~2026-08-04 12:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 12:40 [PATCH v4 0/5] thermal: loongson2: Add support for Loongson-2K0300 SoC Binbin Zhou
2026-08-04 12:42 ` [PATCH v4 1/5] thermal/drivers/loongson2: Correct thermal sensor registration loop Binbin Zhou
2026-08-04 13:01 ` sashiko-bot
2026-08-04 12:43 ` [PATCH v4 2/5] thermal/drivers/loongson2: Move thermal_ops to chip_data for SoC scalability Binbin Zhou
2026-08-04 12:55 ` sashiko-bot [this message]
2026-08-04 12:43 ` [PATCH v4 3/5] dt-bindings: mfd: syscon: Allow syscon compatible for Loongson-2K0300 chip id Binbin Zhou
2026-08-04 12:46 ` sashiko-bot
2026-08-05 6:59 ` Krzysztof Kozlowski
2026-08-04 12:43 ` [PATCH v4 4/5] dt-bindings: thermal: loongson,ls2k-thermal: Add compatible for Loongson-2K0300 Binbin Zhou
2026-08-04 12:49 ` sashiko-bot
2026-08-04 12:43 ` [PATCH v4 5/5] thermal/drivers/loongson2: Add support " Binbin Zhou
2026-08-04 12:59 ` sashiko-bot
2026-08-05 9:43 ` [PATCH v4 0/5] thermal: loongson2: Add support for Loongson-2K0300 SoC Huacai Chen
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=20260804125540.3741E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhoubinbin@loongson.cn \
/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.