Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tzung-Bi Shih" <tzungbi@kernel.org>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 7/9] watchdog: msc313e: Sync timeout value if WDT was running at boot
Date: Fri, 28 Aug 2026 16:22:09 +0000	[thread overview]
Message-ID: <20260828162210.3C2881F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828161348.13212-8-tzungbi@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Non-atomic update of 32-bit hardware watchdog timeout registers while the timer is actively running, risking premature system reset.
--

commit 6f0fb889160225480fa3164d876a1cf0757c5b2c
Author: Tzung-Bi Shih <tzungbi@kernel.org>

watchdog: msc313e: Sync timeout value if WDT was running at boot

If WDT was running at boot, the hardware timeout might be set to values
other than the final software timeout. This commit syncs the hardware
timeout to match the software timeout during probe.

> diff --git a/drivers/watchdog/msc313e_wdt.c b/drivers/watchdog/msc313e_wdt.c
> index 72620adec641a..eea26c6c95d84 100644
> --- a/drivers/watchdog/msc313e_wdt.c
> +++ b/drivers/watchdog/msc313e_wdt.c
[ ... ]
> @@ -145,12 +145,21 @@ static int msc313e_wdt_probe(struct platform_device *pdev)
[ ... ]
>  	/* If the period is non-zero the WDT is running */
>  	if (msc313e_wdt_get_hw_timeout(priv)) {
> +		msc313e_wdt_set_hw_timeout(priv, priv->wdev.timeout);

[Severity: Medium]
Could this trigger a premature system reset during boot?

This new call updates the hardware timeout while the watchdog timer is
actively running. Looking at msc313e_wdt_set_hw_timeout():

drivers/watchdog/msc313e_wdt.c:msc313e_wdt_set_hw_timeout() {
	...
	writew(t & 0xffff, priv->base + REG_WDT_MAX_PRD_L);
	writew((t >> 16) & 0xffff, priv->base + REG_WDT_MAX_PRD_H);
	writew(1, priv->base + REG_WDT_CLR);
}

The two 16-bit registers are updated sequentially before the counter is
cleared. If the hardware does not shadow these registers, the intermediate
32-bit max period value could fall below the running hardware counter.

This creates a window where the watchdog might immediately reset the system
before the counter is cleared.

>  		set_bit(WDOG_HW_RUNNING, &priv->wdev.status);
>  		/*
>  		 * Keep the clock enabled. The watchdog core will skip the next

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260828161348.13212-1-tzungbi@kernel.org?part=7

  reply	other threads:[~2026-08-28 16:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 16:13 [PATCH v2 0/9] watchdog: msc313e: Fix issues Sashiko reported Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 1/9] watchdog: msc313e: Fix NULL pointer dereference in PM callbacks Tzung-Bi Shih
2026-09-09 21:07   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 2/9] watchdog: msc313e: Avoid division by zero Tzung-Bi Shih
2026-09-09 21:08   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 3/9] watchdog: msc313e: Fix clock leak and spurious timer in settimeout() Tzung-Bi Shih
2026-09-09 21:10   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 4/9] watchdog: msc313e: Enable clock before accessing hardware registers Tzung-Bi Shih
2026-08-28 16:25   ` sashiko-bot
2026-09-09 21:14   ` Guenter Roeck
2026-09-12 16:36     ` Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 5/9] watchdog: msc313e: Fix spurious reset on suspend Tzung-Bi Shih
2026-08-28 16:25   ` sashiko-bot
2026-09-09 21:16   ` Guenter Roeck
2026-09-09 23:02     ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 6/9] watchdog: msc313e: Fix undefined behavior Tzung-Bi Shih
2026-09-09 21:17   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 7/9] watchdog: msc313e: Sync timeout value if WDT was running at boot Tzung-Bi Shih
2026-08-28 16:22   ` sashiko-bot [this message]
2026-09-09 21:19   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 8/9] watchdog: msc313e: Propagate error code in resume() Tzung-Bi Shih
2026-08-28 16:27   ` sashiko-bot
2026-09-09 21:21   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 9/9] watchdog: msc313e: Replace commas with semicolons in probe() Tzung-Bi Shih
2026-09-09 21:22   ` Guenter Roeck
2026-08-28 16:20 ` [PATCH v2 0/9] watchdog: msc313e: Fix issues Sashiko reported Daniel Palmer

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=20260828162210.3C2881F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tzungbi@kernel.org \
    /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