[PATCH 2/6] watchdog: dw_wdt: Guard shared IRQ handler during system suspend and resume

From: Lee Jones

Date: Thu Dec 03 2026 - 12:31:07 EST


dw_wdt_irq() is registered with IRQF_SHARED and unconditionally reads
WDOG_INTERRUPT_STATUS_REG_OFFSET. Because dw_wdt_suspend() asserts
reset and disables the clocks during normal dpm_suspend() before
suspend_device_irqs() runs (and resume_device_irqs() runs before
dw_wdt_resume() re-enables them), a shared interrupt firing in either
window causes an unclocked register read while the watchdog is in reset.

Track suspended state with acquire/release ordering and synchronise
with any in-flight IRQ handler via synchronize_irq() before asserting
reset and gating clocks in dw_wdt_suspend().

Fixes: 46a1946314bf ("watchdog: dw_wdt: Add pre-timeouts support")
Closes: https://sashiko.dev/#/bug/linux-f2a43bc3-4f5e-47b2-8d47-8fd4d6ed485f
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/watchdog/dw_wdt.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index b9a34857810b..3bf3f54b9356 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -89,6 +89,8 @@ struct dw_wdt {
struct dw_wdt_timeout timeouts[DW_WDT_NUM_TOPS];
struct watchdog_device wdd;
struct reset_control *rst;
+ int irq;
+ bool suspended;
/* Save/restore */
u32 control;
u32 timeout;
@@ -363,6 +365,10 @@ static irqreturn_t dw_wdt_irq(int irq, void *devid)
struct dw_wdt *dw_wdt = devid;
u32 val;

+ /* Pairs with smp_store_release() in dw_wdt_resume() and error path. */
+ if (smp_load_acquire(&dw_wdt->suspended))
+ return IRQ_NONE;
+
/*
* We don't clear the IRQ status. It's supposed to be done by the
* following ping operations.
@@ -384,9 +390,16 @@ static int dw_wdt_suspend(struct device *dev)
dw_wdt->control = readl(dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
dw_wdt->timeout = readl(dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);

+ WRITE_ONCE(dw_wdt->suspended, true);
+ if (dw_wdt->irq > 0)
+ synchronize_irq(dw_wdt->irq);
+
err = reset_control_assert(dw_wdt->rst);
- if (err)
+ if (err) {
+ /* Pairs with smp_load_acquire() in dw_wdt_irq(). */
+ smp_store_release(&dw_wdt->suspended, false);
return err;
+ }

clk_disable_unprepare(dw_wdt->pclk);
clk_disable_unprepare(dw_wdt->clk);
@@ -416,6 +429,9 @@ static int dw_wdt_resume(struct device *dev)

dw_wdt_ping(&dw_wdt->wdd);

+ /* Pairs with smp_load_acquire() in dw_wdt_irq(). */
+ smp_store_release(&dw_wdt->suspended, false);
+
return 0;

unprepare_pclk:
@@ -619,7 +635,8 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
*/
ret = platform_get_irq_optional(pdev, 0);
if (ret > 0) {
- ret = devm_request_irq(dev, ret, dw_wdt_irq,
+ dw_wdt->irq = ret;
+ ret = devm_request_irq(dev, dw_wdt->irq, dw_wdt_irq,
IRQF_SHARED | IRQF_TRIGGER_RISING,
pdev->name, dw_wdt);
if (ret)
--
2.56.1.911.g883d8bcb20-goog