From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Avi Fishman" <avifishman70@gmail.com>,
"Tomer Maimon" <tmaimon77@gmail.com>,
"Tali Perry" <tali.perry1@gmail.com>,
"Patrick Venture" <venture@google.com>,
"Nancy Yuen" <yuenn@google.com>,
"Benjamin Fair" <benjaminfair@google.com>,
"Wim Van Sebroeck" <wim@linux-watchdog.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
openbmc@lists.ozlabs.org, linux-watchdog@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 3/6] watchdog: npcm: Enable clock before checking running state in probe
Date: Thu, 3 Dec 2026 17:30:06 +0000 [thread overview]
Message-ID: <20261203173039.1142495-4-lee@kernel.org> (raw)
In-Reply-To: <20261203173039.1142495-1-lee@kernel.org>
npcm_wdt_probe() obtains the watchdog clock via
devm_clk_get_optional_prepared() and immediately calls
npcm_is_running(), reading the watchdog register before clk_enable() has
been invoked. On platforms with a gated peripheral clock, this causes
an unclocked MMIO access during probe.
Enable the clock before calling npcm_is_running(), start the watchdog
via __npcm_wdt_start() if it is already running (disabling the clock
otherwise), and disable the clock on subsequent probe error paths if it
was left enabled.
Fixes: af084fdccfaf ("watchdog: npcm: Enable clock if provided")
Closes: https://sashiko.dev/#/bug/linux-119dbba3-5231-4944-9d7e-e954378626c9
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/watchdog/npcm_wdt.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
index df7f66e77965..7a05673da4fc 100644
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -448,24 +448,35 @@ static int npcm_wdt_probe(struct platform_device *pdev)
npcm_get_reset_status(wdt, dev, data, start);
+ ret = clk_enable(wdt->clk);
+ if (ret)
+ return ret;
+
if (npcm_is_running(&wdt->wdd)) {
/* Restart with the default or device-tree specified timeout */
- npcm_wdt_start(&wdt->wdd);
+ __npcm_wdt_start(&wdt->wdd);
set_bit(WDOG_HW_RUNNING, &wdt->wdd.status);
+ } else {
+ clk_disable(wdt->clk);
}
ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0, "watchdog",
wdt);
if (ret)
- return ret;
+ goto err_disable_clk;
ret = devm_watchdog_register_device(dev, &wdt->wdd);
if (ret)
- return ret;
+ goto err_disable_clk;
dev_info(dev, "NPCM watchdog driver enabled\n");
return 0;
+
+err_disable_clk:
+ if (watchdog_hw_running(&wdt->wdd))
+ clk_disable(wdt->clk);
+ return ret;
}
#ifdef CONFIG_OF
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-03 17:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:30 [PATCH 0/6] watchdog: Fix High issues reported by Sashiko Lee Jones
2026-12-03 17:30 ` [PATCH 1/6] watchdog: da9063: Stop ping worker on system suspend Lee Jones
2026-12-03 17:30 ` [PATCH 2/6] watchdog: dw_wdt: Guard shared IRQ handler during system suspend and resume Lee Jones
2026-12-03 17:30 ` Lee Jones [this message]
2026-12-03 17:30 ` [PATCH 4/6] watchdog: sbsa: Evaluate MediaTek WS0 workaround after IRQ fallback Lee Jones
2026-12-03 17:30 ` [PATCH 5/6] watchdog: octeon-wdt: Serialise countdown and IRQ state with raw spinlock Lee Jones
2026-12-03 17:30 ` [PATCH 6/6] watchdog: rzv2h: Avoid 32-bit overflow in max_hw_heartbeat_ms calculation Lee Jones
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=20261203173039.1142495-4-lee@kernel.org \
--to=lee@kernel.org \
--cc=andrew@codeconstruct.com.au \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=j.neuschaefer@gmx.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=openbmc@lists.ozlabs.org \
--cc=stable@vger.kernel.org \
--cc=tali.perry1@gmail.com \
--cc=tmaimon77@gmail.com \
--cc=venture@google.com \
--cc=wim@linux-watchdog.org \
--cc=yuenn@google.com \
/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