From: sashiko-bot@kernel.org
To: "Tzung-Bi Shih" <tzungbi@kernel.org>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: msc313e: Fix premature reset during timeout update
Date: Sun, 13 Sep 2026 07:00:09 +0000 [thread overview]
Message-ID: <20260913070009.D63D61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260913065126.8350-1-tzungbi@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete race condition fix leading to premature system reset during watchdog timeout update.
--
commit 7f35d2e3193543673ce5c7858773cd48582d5c52
Author: Tzung-Bi Shih <tzungbi@kernel.org>
watchdog: msc313e: Fix premature reset during timeout update
Updating the 32-bit hardware timeout requires writing to two 16-bit
registers sequentially. Clear the watchdog counter before updating the
registers to prevent the timer from timing out prematurely.
> diff --git a/drivers/watchdog/msc313e_wdt.c b/drivers/watchdog/msc313e_wdt.c
> index 4a5cce2a16b18..a743087e922d5 100644
> --- a/drivers/watchdog/msc313e_wdt.c
> +++ b/drivers/watchdog/msc313e_wdt.c
> @@ -46,6 +46,9 @@ static void msc313e_wdt_set_hw_timeout(struct msc313e_wdt_priv *priv,
> {
> u32 t = timeout * clk_get_rate(priv->clk);
>
> + /* Clear before to prevent premature reset during non-atomic updates. */
> + writew(1, priv->base + REG_WDT_CLR);
> +
> writew(t & 0xffff, priv->base + REG_WDT_MAX_PRD_L);
> writew((t >> 16) & 0xffff, priv->base + REG_WDT_MAX_PRD_H);
[Severity: High]
This is a pre-existing issue, but does this non-atomic update still leave a
race condition window?
If a preemption or interrupt occurs between these two writes in
msc313e_wdt_set_hw_timeout(), the active threshold becomes a hybrid of the
old high bits and the new low bits.
Since the counter was just cleared to 0 immediately prior to this, if the
old high bits are 0 and the new low bits are small, the intermediate
threshold will be very low.
Could the counter reach this small intermediate threshold during the
preemption window and still trigger a premature hardware reset?
> writew(1, priv->base + REG_WDT_CLR);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260913065126.8350-1-tzungbi@kernel.org?part=1
prev parent reply other threads:[~2026-09-13 7:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 6:51 [PATCH] watchdog: msc313e: Fix premature reset during timeout update Tzung-Bi Shih
2026-09-13 7:00 ` 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=20260913070009.D63D61F000FF@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 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.