All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH 2/6] watchdog: dw_wdt: Guard shared IRQ handler during system suspend and resume
Date: Thu, 03 Dec 2026 19:00:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-248454@kernel.org> (raw)
In-Reply-To: <20261203173039.1142495-3-lee@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] watchdog: dw_wdt: smp_store_release() in dw_wdt_resume() does
  not order MMIO
--

commit f1633c3b40a2644c283cea9e5ef06c0e803b416b
Author: Lee Jones <lee@kernel.org>

watchdog: dw_wdt: Guard shared IRQ handler during system suspend and resume

This commit tracks suspend state in struct dw_wdt with acquire/release
operations and calls synchronize_irq() in dw_wdt_suspend() so the shared
dw_wdt_irq() handler avoids accessing watchdog registers while clocks are
gated or reset is asserted.

> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index b9a34857810b5..3bf3f54b9356c 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c

[ ... ]

> @@ -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:

[Severity: Medium]
Does smp_store_release(&dw_wdt->suspended, false) order the preceding
MMIO writes in dw_wdt_resume() before dw_wdt_irq() can observe
suspended == false on another CPU?

smp_store_release() only orders normal shared memory, not device I/O.
On RISC-V, writel()'s mmiowb_set_pending() is a no-op outside a spinlock
and __smp_store_release() emits RISCV_FENCE(rw, w) without the device
output bit o; on 32-bit ARM SMP, it emits dmb(ish) instead of dsb(st).

Because resume_device_irqs() runs before dw_wdt_resume(), a shared
interrupt on another CPU can race as follows:

CPU0                              CPU1
dw_wdt_resume()
  writel(..., WDOG_TIMEOUT...)
  writel(..., WDOG_CONTROL...)
  dw_wdt_ping()
  smp_store_release(&suspended, false)
                                  dw_wdt_irq()
                                    smp_load_acquire(&suspended)
                                    readl(WDOG_INTERRUPT_STATUS...)
                                      <-- reads before ping reaches HW

When dw_wdt->rst is absent or shared and a pretimeout status bit was
pending before dw_wdt_ping(), dw_wdt_irq() can read a stale non-zero
status and trigger a spurious watchdog_notify_pretimeout(), which panics
the kernel when CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC is enabled.

A read-back readl() or an explicit wmb() before smp_store_release()
would ensure the MMIO writes are ordered before suspended is cleared.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203173039.1142495-1-lee@kernel.org?part=2

  reply	other threads:[~2026-12-03 19:00 UTC|newest]

Thread overview: 14+ 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 18:31   ` sashiko-bot
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 19:00   ` sashiko-bot [this message]
2026-12-03 17:30 ` [PATCH 3/6] watchdog: npcm: Enable clock before checking running state in probe Lee Jones
2026-12-04  1:02   ` Guenter Roeck
2026-12-03 17:30 ` [PATCH 4/6] watchdog: sbsa: Evaluate MediaTek WS0 workaround after IRQ fallback Lee Jones
2026-12-04  1:03   ` Guenter Roeck
2026-12-03 17:30 ` [PATCH 5/6] watchdog: octeon-wdt: Serialise countdown and IRQ state with raw spinlock Lee Jones
2026-12-03 19:45   ` sashiko-bot
2026-12-03 17:30 ` [PATCH 6/6] watchdog: rzv2h: Avoid 32-bit overflow in max_hw_heartbeat_ms calculation Lee Jones
2026-12-04  1:04   ` Guenter Roeck
2026-12-04  1:08 ` [PATCH 0/6] watchdog: Fix High issues reported by Sashiko Guenter Roeck

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-248454@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --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 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.