[PATCH v7 4/4] watchdog: vt8500: Add a restart handler

From: Alexey Charkov

Date: Fri Nov 13 2026 - 08:43:24 EST


Reset the SoC through the watchdog when the machine's own restart hook
leaves it running: the PMSR write in vt8500_restart() has no effect on
WM8950, so a reboot there ends in "Reboot failed -- System halted"
unless a watchdog armed from userspace happens to fire.

Arm the match a millisecond ahead of the current count, which leaves
ample margin for the register writes to land, then wait for the reset
to assert so that no later handler runs in the meantime. Return 0 if it
never does, or if the match can't be armed at all, to let the remaining
handlers have their turn, as an error would stop the restart chain.

Register at priority 0, the last resort, so that the handler runs only
after the ARM machine restart hook at 128 has failed to reset the SoC.

Signed-off-by: Alexey Charkov <alchark@xxxxxxxxx>
---
drivers/watchdog/vt8500-wdt.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/drivers/watchdog/vt8500-wdt.c b/drivers/watchdog/vt8500-wdt.c
index e0f838fd1d50..bde8a5e1a9d4 100644
--- a/drivers/watchdog/vt8500-wdt.c
+++ b/drivers/watchdog/vt8500-wdt.c
@@ -4,6 +4,7 @@
#include <linux/auxiliary_bus.h>
#include <linux/bits.h>
#include <linux/container_of.h>
+#include <linux/delay.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/iopoll.h>
@@ -25,6 +26,10 @@

#define VT8500_WDT_DEFAULT_TIMEOUT 30 /* seconds */

+/* How far ahead of the current count to arm the match for a restart */
+#define VT8500_WDT_RESTART_TICKS (VT8500_TIMER_HZ / 1000) /* 1 ms */
+#define VT8500_WDT_RESTART_WAIT_MS 10
+
static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
@@ -75,9 +80,21 @@ static int vt8500_watchdog_stop(struct watchdog_device *wdd)
return 0;
}

+static int vt8500_watchdog_restart(struct watchdog_device *wdd,
+ unsigned long action, void *data)
+{
+ struct vt8500_wdt_info *info = watchdog_get_drvdata(wdd);
+
+ if (!vt8500_watchdog_arm(info, VT8500_WDT_RESTART_TICKS))
+ mdelay(VT8500_WDT_RESTART_WAIT_MS);
+
+ return 0;
+}
+
static const struct watchdog_ops vt8500_watchdog_ops = {
.start = vt8500_watchdog_start,
.stop = vt8500_watchdog_stop,
+ .restart = vt8500_watchdog_restart,
};

static const struct watchdog_info vt8500_watchdog_info = {
@@ -107,6 +124,7 @@ static int vt8500_wdt_probe(struct auxiliary_device *auxdev,
info = container_of(auxdev, struct vt8500_wdt_info, auxdev);
watchdog_set_drvdata(wdd, info);
watchdog_set_nowayout(wdd, nowayout);
+ watchdog_set_restart_priority(wdd, 0);

/* Let the core feed a watchdog left running, e.g. across kexec */
if (readl(info->regbase + VT8500_WDT_EN_REG) & VT8500_WDT_EN)

--
2.56.0