Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Binbin Zhou" <zhoubinbin@loongson.cn>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v7 8/8] thermal/drivers/loongson2: Add Loongson-2K0300 support
Date: Fri, 09 Oct 2026 03:07:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-164748@kernel.org> (raw)
In-Reply-To: <93002842dcf01ec651a9711075f5967026b95987.1791512067.git.zhoubinbin@loongson.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] thermal: loongson2: missing delay before reading ADC after initialization
--

commit 97ab3025b749644e2a07310bc78907ed2d3b519c
Author: Binbin Zhou <zhoubinbin@loongson.cn>
Subject: thermal/drivers/loongson2: Add Loongson-2K0300 support

This commit adds support for the Loongson-2K0300 thermal sensor, configuring
it with calibration data read from the syscon CHIP ID registers. It also
introduces a fallback mechanism to use an old fuse formula if the initial
calibrated temperature reading is outside of a valid range.

> diff --git a/drivers/thermal/loongson2_thermal.c b/drivers/thermal/loongson2_thermal.c
> index dbfb03aa08338..1db61509dbf37 100644
> --- a/drivers/thermal/loongson2_thermal.c
> +++ b/drivers/thermal/loongson2_thermal.c
[ ... ]
> @@ -83,6 +118,101 @@ static int loongson2_thermal_set_trips(struct thermal_zone_device *tz, int low,
[ ... ]
> +static int ls2k0300_thermal_hw_init(struct platform_device *pdev,
> +				    struct loongson2_thermal_data *data)
> +{
> +	struct device *dev = &pdev->dev;
> +	int ret;
> +
> +	data->regmap_cfg = syscon_regmap_lookup_by_phandle(dev->of_node, "loongson,chipid");
> +	if (IS_ERR(data->regmap_cfg))
> +		return PTR_ERR(data->regmap_cfg);
> +
> +	ret = ls2k0300_thermal_read_calib(data);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to read calibration data");
> +
> +	writel(LS2K0300_THSENS_INIT_MASK, data->ctrl_reg + LS2K0300_THSENS_CFG_REG);
> +
> +	ls2k0300_thermal_detect_old_fuse(dev, data);

[Severity: Medium]
Will this immediate ADC read return uninitialized or stale data?

The sensor is initialized by writing LS2K0300_THSENS_INIT_MASK, and on the
very next instruction ls2k0300_thermal_detect_old_fuse() reads the ADC
output without polling a readiness bit or applying a small delay.

If the hardware requires conversion latency, reading a 0 or stale value here
would produce a deeply negative temperature that spuriously satisfies the
temp < LOONGSON2_LOWEST_VALID_TEMP condition. Does this risk incorrectly
discarding valid calibration data and permanently enabling the uncalibrated
fallback logic for the boot session?

> +
> +	return 0;
> +}

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

      reply	other threads:[~2026-10-09  3:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09  2:57 [PATCH v7 0/8] thermal/drivers/loongson2: Fix trip programming and add Loongson-2K0300 support Binbin Zhou
2026-10-09  2:57 ` [PATCH v7 1/8] thermal/drivers/loongson2: Fix negative temperature conversion in set_trips Binbin Zhou
2026-10-09  2:57 ` [PATCH v7 2/8] thermal/drivers/loongson2: Fix clamp() usage for thermal trip points Binbin Zhou
2026-10-09  2:58 ` [PATCH v7 3/8] thermal/drivers/loongson2: Fix Loongson-2K2000 trip point programming Binbin Zhou
2026-10-09  2:58 ` [PATCH v7 4/8] thermal/drivers/loongson2: Simplify thermal sensor registration Binbin Zhou
2026-10-09  2:58 ` [PATCH v7 5/8] thermal/drivers/loongson2: Use bitfields and per-SoC thermal ops Binbin Zhou
2026-10-09  3:09   ` sashiko-bot
2026-10-09  2:58 ` [PATCH v7 6/8] thermal/drivers/loongson2: Move per-SoC ops into chip data Binbin Zhou
2026-10-09  2:58 ` [PATCH v7 7/8] dt-bindings: thermal: loongson,ls2k-thermal: Add compatible for Loongson-2K0300 Binbin Zhou
2026-10-09  2:58 ` [PATCH v7 8/8] thermal/drivers/loongson2: Add Loongson-2K0300 support Binbin Zhou
2026-10-09  3:07   ` 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-164748@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