Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "David Yang" <mmyangfl@gmail.com>, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: sp805_wdt: re-enable the clock in the restart handler
Date: Fri, 20 Nov 2026 20:19:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-226033@kernel.org> (raw)
In-Reply-To: <20261120201029.1685193-1-mmyangfl@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] watchdog: sp805_wdt: sleeping clk_prepare_enable() call in
  wdt_restart()
- [Low] watchdog: sp805_wdt: missing Fixes trailer for wdt_restart()
  clock fix
--

commit 800a9ee3ac4d2d74f9b4e848c39474209c8cef7f
Author: David Yang <mmyangfl@gmail.com>

> watchdog: sp805_wdt: re-enable the clock in the restart handler
>
> wdt_restart() fail to reboot the system if the watchdog counter clock
> was previously disabled: If userspace cleanly stops the watchdog, the
> core calls wdt_disable() which disables wdt->clk. No reset comes.
>
> Re-enable the clock in it as in npcm_wdt.
>
> Link: https://lore.kernel.org/r/20260911031916.A8E051F000FF@smtp.kernel.org
> Signed-off-by: David Yang <mmyangfl@gmail.com>

[Severity: Low]
Should this bug fix include a Fixes tag for the commit that introduced
wdt_restart()?

  Fixes: 6c5c0d48b686 ("watchdog: sp805: add restart handler")

> diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
> index a14ff7ac0db48..20b2fbb7334db 100644
> --- a/drivers/watchdog/sp805_wdt.c
> +++ b/drivers/watchdog/sp805_wdt.c
> @@ -138,6 +138,9 @@ wdt_restart(struct watchdog_device *wdd, unsigned long mode, void *cmd)
>  {
>  	struct sp805_wdt *wdt = watchdog_get_drvdata(wdd);
>  
> +	/* For reset, we start the WDT clock and leave it running. */
> +	clk_prepare_enable(wdt->clk);

[Severity: High]
Can wdt_restart() call clk_prepare_enable()?

do_kernel_restart() invokes restart handlers via
atomic_notifier_call_chain(&restart_handler_list, ...) under
rcu_read_lock() with local interrupts disabled, whereas clk_prepare()
acquires the sleeping prepare_lock mutex and calls ->prepare() callbacks.
When wdt->clk is unprepared (either because the watchdog was never started
or because wdt_disable() called clk_disable_unprepare()), this sleeps in
atomic context and can deadlock or hang system reboot.

Unlike sp805_wdt, npcm_wdt prepares its clock at probe time via
devm_clk_get_optional_prepared() and uses clk_enable() / clk_disable() at
runtime so that npcm_wdt_restart() only calls atomic-safe clk_enable().

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

      reply	other threads:[~2026-11-20 20:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 20:10 [PATCH] watchdog: sp805_wdt: re-enable the clock in the restart handler David Yang
2026-11-20 20:19 ` 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-226033@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=mmyangfl@gmail.com \
    --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