Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Binbin Zhou" <zhoubinbin@loongson.cn>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 3/7] thermal/drivers/loongson2: Fix Loongson-2K2000 trip point programming
Date: Mon, 28 Sep 2026 04:54:37 +0000	[thread overview]
Message-ID: <20260928045438.0083D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <da9af5d5cf5f3635556729ae0b853f4502173bd8.1790561983.git.zhoubinbin@loongson.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] thermal: torn write in loongson2_2k2000_set_trips_regs() can trigger spurious interrupts
--

commit 89df6fff6e860d7cc010f8ec79a9f1531d8e5cca
Author: Binbin Zhou <zhoubinbin@loongson.cn>

    thermal/drivers/loongson2: Fix Loongson-2K2000 trip point programming
    
    Loongson-2K2000 uses a different trip point layout than Loongson-2K1000:
    the low 8 bits of the gate value are written to the control register,
    while the high 8 bits are written to separate HI_GATE_HI/LOW registers.
    The gate value is calculated as (temp + 311) * 0x4000 / 820.
    
    Introduce a per-SoC set_trips_regs() callback. Keep the existing
    Loongson-2K1000 logic and add the Loongson-2K2000 implementation.
    Move the common clamping into loongson2_thermal_set_trips() and pass
    Celsius values to the callback.

> diff --git a/drivers/thermal/loongson2_thermal.c b/drivers/thermal/loongson2_thermal.c
> index bcabca3601572..45fe6100134ee 100644
> --- a/drivers/thermal/loongson2_thermal.c
> +++ b/drivers/thermal/loongson2_thermal.c

[ ... ]

> @@ -81,6 +99,26 @@ static int loongson2_2k1000_get_temp(struct thermal_zone_device *tz, int *temp)
>  	return 0;
>  }
>  
> +static void loongson2_2k2000_set_trips_regs(struct loongson2_thermal_data *data,
> +					    int temp, bool low, bool enable)
> +{
> +	int hi_reg, ctrl_reg;
> +	int val = 0, gate;
> +
> +	ctrl_reg = low ? LOONGSON2_THSENS_CTRL_LOW_REG : LOONGSON2_THSENS_CTRL_HI_REG;
> +	gate = (temp + 311) * 0x4000 / 820;
> +
> +	val = gate & 0xff;
> +	val |= enable ? 0x100 : 0;
> +	writel(val, data->ctrl_reg + ctrl_reg);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Medium]
Will this writel() cause the hardware to evaluate a torn threshold?

By writing the low 8 bits and immediately enabling the hardware comparator here,
before the upper 8 bits are written to hi_reg below, there is a time window
where the active hardware uses a torn threshold (new low bits, old high bits).

If this torn value is momentarily crossed by the current live temperature, could
it fire a spurious hardware interrupt?

> +
> +	hi_reg = low ? LS2K2000_THSENS_HI_GATE_LOW_REG : LS2K2000_THSENS_HI_GATE_HI_REG;
> +
> +	val = readl(data->ctrl_reg + hi_reg);
> +	val = (val & ~0xff) | ((gate >> 8) & 0xff);
> +	writel(val, data->ctrl_reg + hi_reg);
> +}
> +
>  static int loongson2_2k2000_get_temp(struct thermal_zone_device *tz, int *temp)
>  {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790561983.git.zhoubinbin@loongson.cn?part=3

  reply	other threads:[~2026-09-28  4:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28  4:44 [PATCH v6 0/7] thermal: loongson2: Add support for Loongson-2K0300 SoC Binbin Zhou
2026-09-28  4:44 ` [PATCH v6 1/7] thermal/drivers/loongson2: Correct thermal sensor registration loop Binbin Zhou
2026-09-28  7:15   ` Daniel Lezcano
2026-09-28  8:17     ` Binbin Zhou
2026-09-28 13:23       ` Daniel Lezcano
2026-09-29  3:06         ` Binbin Zhou
2026-09-29  5:46           ` Daniel Lezcano
2026-09-29  8:23             ` Binbin Zhou
2026-09-29  8:43               ` Daniel Lezcano
2026-09-28  4:44 ` [PATCH v6 2/7] thermal/drivers/loongson2: Fix clamp() usage for thermal trip points Binbin Zhou
2026-09-28  4:44 ` [PATCH v6 3/7] thermal/drivers/loongson2: Fix Loongson-2K2000 trip point programming Binbin Zhou
2026-09-28  4:54   ` sashiko-bot [this message]
2026-09-28  4:44 ` [PATCH v6 4/7] thermal/drivers/loongson2: Use bitfields and per-SoC thermal ops Binbin Zhou
2026-09-28  4:52   ` sashiko-bot
2026-09-28  4:44 ` [PATCH v6 5/7] thermal/drivers/loongson2: Move per-SoC ops into chip data Binbin Zhou
2026-09-28  4:44 ` [PATCH v6 6/7] dt-bindings: thermal: loongson,ls2k-thermal: Add compatible for Loongson-2K0300 Binbin Zhou
2026-09-28  4:44 ` [PATCH v6 7/7] thermal/drivers/loongson2: Add Loongson-2K0300 support Binbin Zhou
2026-09-28  4:53   ` sashiko-bot

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=20260928045438.0083D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox