Re: [PATCH 3/5] watchdog: gpio: Support watchdogs with a minimum heartbeat interval

From: Guenter Roeck

Date: Mon Oct 19 2026 - 21:02:22 EST


On 10/16/26 15:16, Florian Fainelli wrote:
Read the optional hw-min-interval-ms property into min_hw_heartbeat_ms so
the watchdog core defers keepalives that would toggle the GPIO too soon.
Reject zero intervals and intervals at or above the hardware margin.
Devices without the property retain their existing behavior.

Remove the arbitrary 65535 ms upper bound on hw_margin_ms as well. There
is no register width to constrain this software interval, and the MTX-1
watchdog needs a larger margin with a 1600 ms minimum ping interval.

Signed-off-by: Florian Fainelli <f.fainelli@xxxxxxxxx>

For my reference:

Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>

---
drivers/watchdog/gpio_wdt.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index ff323d6e692e..a431c77fa179 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -138,10 +138,20 @@ static int gpio_wdt_probe(struct platform_device *pdev)
ret = device_property_read_u32(dev, "hw_margin_ms", &hw_margin);
if (ret)
return ret;
- /* Disallow values lower than 2 and higher than 65535 ms */
- if (hw_margin < 2 || hw_margin > 65535)
+ /* The core feeds the watchdog at half the hardware margin. */
+ if (hw_margin < 2)
return -EINVAL;
+ if (device_property_present(dev, "hw-min-interval-ms")) {
+ ret = device_property_read_u32(dev, "hw-min-interval-ms",
+ &priv->wdd.min_hw_heartbeat_ms);
+ if (ret)
+ return ret;
+ if (!priv->wdd.min_hw_heartbeat_ms ||
+ priv->wdd.min_hw_heartbeat_ms >= hw_margin)
+ return -EINVAL;
+ }
+
priv->always_running = device_property_read_bool(dev, "always-running");
watchdog_set_drvdata(&priv->wdd, priv);