[PATCH RFC] watchdog: core: Ignore userspace keepalives once the system goes down
From: Arun Iyengar via B4 Relay
Date: Thu Nov 19 2026 - 11:54:12 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
A watchdog left running through a reboot should reset a system whose
reboot hangs. But a daemon still pinging after reboot(2), such as
systemd after "systemctl reboot -ff", keeps a hang in device_shutdown()
from ever being reset.
Ignore userspace keepalives once system_state is past SYSTEM_RUNNING,
as da9062_wdt and da9063_wdt do since commit 2f61b3a74699 ("watchdog:
da9062: da9063: prevent pings ahead of machine reset").
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
RFC: this changes every driver. A reboot or power-off whose
device_shutdown() outlasts the timeout now ends in a watchdog reset.
Tested on an Orange Pi Zero2 (H616, sunxi_wdt) on 7.3.5 with a test
module that oopses holding a device lock: "systemctl reboot -ff" was
reset after 14 s in 6 of 6 runs. Without the patch there was no reset
within 90 s (one run, older 7.3 build). Other drivers and kexec are
not tested.
Developed with Claude (Anthropic) as a coding assistant, which wrote
the code and the commit message. I reviewed and tested it.
---
drivers/watchdog/watchdog_dev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index aad3f1f1b4ce..0f149da49a69 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -201,6 +201,9 @@ static int watchdog_ping(struct watchdog_device *wdd)
if (!watchdog_hw_running(wdd))
return 0;
+ if (system_state > SYSTEM_RUNNING)
+ return 0;
+
set_bit(_WDOG_KEEPALIVE, &wd_data->status);
wd_data->last_keepalive = ktime_get();
---
base-commit: 865c2d0f1dd3f0937865dd11819eeb59298a814c
change-id: 20261119-watchdog-reboot-keepalive-fd50f4b828f2
Best regards,
--
Arun Iyengar <aiyengar1990@xxxxxxxxx>