Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Akari Tsuyukusa" <akkun11.open@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org,
	linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 1/7] watchdog: mtk_wdt: add explicit compatibles for SoCs using mt6589 fallback
Date: Thu, 16 Jul 2026 16:37:19 +0000	[thread overview]
Message-ID: <20260716163719.A068C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716161923.266315-2-akkun11.open@gmail.com>

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

Pre-existing issues:
- [High] Watchdog is registered to userspace before its state is fully initialized from the device tree.
- [High] Watchdog hardware is not stopped during system suspend if it was running before boot but not opened by userspace.
--

--- Patch [1]: [PATCH 1/7] watchdog: mtk_wdt: add explicit compatibles for SoCs using mt6589 fallback ---
commit d59566877973f13ae59e846770f459a7512fd9eb
Author: Akari Tsuyukusa <akkun11.open@gmail.com>

watchdog: mtk_wdt: add explicit compatibles for SoCs using mt6589 fallback

This patch adds dedicated of_device_id entries for several SoCs that
currently rely on the "mediatek,mt6589-wdt" fallback compatible. This
allows the driver to match directly on the SoC-specific string, which is
a prerequisite for removing the fallback string from DTS files.

> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
> index 91d110646e16f..345d2e89f414e 100644
> --- a/drivers/watchdog/mtk_wdt.c
> +++ b/drivers/watchdog/mtk_wdt.c
> @@ -492,17 +492,28 @@ static int mtk_wdt_resume(struct device *dev)
>  }

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential
problem with how the watchdog is handled during system suspend and resume.

In mtk_wdt_suspend() and mtk_wdt_resume(), the driver only checks
watchdog_active(), which is true if userspace has opened the device:

drivers/watchdog/mtk_wdt.c:mtk_wdt_suspend() {
    ...
	if (watchdog_active(&mtk_wdt->wdt_dev))
		mtk_wdt_stop(&mtk_wdt->wdt_dev);
    ...
}

Will this cause the system to reboot unexpectedly during suspend if the
hardware watchdog was already running before boot (WDOG_HW_RUNNING) but
hasn't been opened by userspace?

Should these functions also ensure the hardware is properly stopped even
when the device hasn't been opened?

[Severity: High]
This is also a pre-existing issue, but does mtk_wdt_probe() expose the
device to userspace too early?

drivers/watchdog/mtk_wdt.c:mtk_wdt_probe() {
    ...
	err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev);
	if (unlikely(err))
		return err;

	// ... [code omitted] ...

	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 userspace opens and starts the watchdog immediately after
devm_watchdog_register_device() completes, could it be started with
incorrect configurations before the device tree properties are parsed?

Additionally, if toprgu_register_reset_controller() fails after the watchdog
is registered, the probe will fail. Could this cause the watchdog to be
deregistered while it is actively in use by userspace?

>  
>  static const struct of_device_id mtk_wdt_dt_ids[] = {
> +	{ .compatible = "mediatek,mt2701-wdt" },
>  	{ .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data },

[ ... ]

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

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

Thread overview: 15+ 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 [this message]
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
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

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=20260716163719.A068C1F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox