All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Akari Tsuyukusa" <akkun11.open@gmail.com>
Cc: devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org,
	conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH 6/7] watchdog: mtk_wdt: add reset controller support for MT6589
Date: Thu, 16 Jul 2026 16:33:12 +0000	[thread overview]
Message-ID: <20260716163313.19E5D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716161923.266315-7-akkun11.open@gmail.com>

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

Pre-existing issues:
- [High] The watchdog device and reset controller are registered before the driver has finished reading its configuration from the device tree.
--

--- Patch [6]: [PATCH 6/7] watchdog: mtk_wdt: add reset controller support for MT6589 ---
commit f121306c9b4fd3b69e7cdcb03d9c4a147f872914
Author: Akari Tsuyukusa <akkun11.open@gmail.com>

watchdog: mtk_wdt: add reset controller support for MT6589
    
This commit adds reset data for the MT6589 fallback, assigning the proper
reset controller information to the mt6589 entry in the device tree match
table.

> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
> index 345d2e89f414e..c8ce45a597956 100644
> --- a/drivers/watchdog/mtk_wdt.c
> +++ b/drivers/watchdog/mtk_wdt.c

[ ... ]

> @@ -496,7 +501,7 @@ static const struct of_device_id mtk_wdt_dt_ids[] = {
>  	{ .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data },
>  	{ .compatible = "mediatek,mt6572-wdt" },
>  	{ .compatible = "mediatek,mt6582-wdt" },
> -	{ .compatible = "mediatek,mt6589-wdt" },
> +	{ .compatible = "mediatek,mt6589-wdt", .data = &mt6589_data },

[Severity: High]
This is a pre-existing issue, but while reviewing the watchdog data
initialization, I noticed a potential race condition during device probe.

Is it possible for the watchdog device or reset controller to be accessed 
before their configuration flags are fully initialized?

In drivers/watchdog/mtk_wdt.c:mtk_wdt_probe():

	err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev);
	if (unlikely(err))
		return err;

	dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)\n",
		 mtk_wdt->wdt_dev.timeout, nowayout);

	wdt_data = of_device_get_match_data(dev);
	if (wdt_data) {
		err = toprgu_register_reset_controller(pdev,
						       wdt_data->toprgu_sw_rst_num);
		if (err)
			return err;

		mtk_wdt->has_swsysrst_en = wdt_data->has_swsysrst_en;
	}

	mtk_wdt->disable_wdt_extrst =
		of_property_read_bool(dev->of_node, "mediatek,disable-extrst");

	mtk_wdt->reset_by_toprgu =
		of_property_read_bool(dev->of_node, "mediatek,reset-by-toprgu");

If a userspace process opens the watchdog character device immediately after 
devm_watchdog_register_device() completes, or a concurrently probing driver 
acquires the reset controller after toprgu_register_reset_controller() 
returns, could they operate with uninitialized state variables 
(disable_wdt_extrst, reset_by_toprgu, and has_swsysrst_en)?

This could potentially misconfigure the hardware, failing to disable external 
resets or missing software reset enables, which might cause system lockups or 
failed peripheral resets.

>  	{ .compatible = "mediatek,mt6735-wdt", .data = &mt6735_data },
>  	{ .compatible = "mediatek,mt6795-wdt", .data = &mt6795_data },
>  	{ .compatible = "mediatek,mt6797-wdt" },

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260716161923.266315-1-akkun11.open@gmail.com?part=6

  reply	other threads:[~2026-07-16 16:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 16:19 [PATCH 0/7] Add reset support to MT6589 wdt and remove fallback compatibles Akari Tsuyukusa
2026-07-16 16:19 ` [PATCH 1/7] watchdog: mtk_wdt: add explicit compatibles for SoCs using mt6589 fallback Akari Tsuyukusa
2026-07-16 16:37   ` sashiko-bot
2026-07-16 16:19 ` [PATCH 2/7] dt-bindings: watchdog: mediatek,mtk-wdt: add compatibles for all SoCs Akari Tsuyukusa
2026-07-16 16:19 ` [PATCH 3/7] arm/arm64: dts: mediatek: drop mt6589 fallback from watchdog Akari Tsuyukusa
2026-07-16 16:36   ` sashiko-bot
2026-07-16 18:35   ` Roman Vivchar
2026-07-16 16:19 ` [PATCH 4/7] dt-bindings: watchdog: mediatek,mtk-wdt: remove mt6589 fallback items Akari Tsuyukusa
2026-07-16 16:49   ` sashiko-bot
2026-07-16 16:19 ` [PATCH 5/7] dt-bindings: reset: Add bindings for MediaTek MT6589 reset controller Akari Tsuyukusa
2026-07-16 16:47   ` sashiko-bot
2026-07-16 16:19 ` [PATCH 6/7] watchdog: mtk_wdt: add reset controller support for MT6589 Akari Tsuyukusa
2026-07-16 16:33   ` sashiko-bot [this message]
2026-07-16 16:19 ` [PATCH 7/7] arm: dts: mediatek: mt6589: add reset support for wdt Akari Tsuyukusa
2026-07-16 16:32   ` sashiko-bot
2026-07-17  7:13 ` [PATCH 0/7] Add reset support to MT6589 wdt and remove fallback compatibles Akari Tsuyukusa

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=20260716163313.19E5D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akkun11.open@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-watchdog@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 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.