Skip to contentSkip to conversation

watchdog: msc313e: Check if the WDT was running at boot

PATCH In review Daniel Palmer 2 participants 2 messages Dec 28, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: msc313e: Check if the WDT was running at boot

Check if the WDT was running at boot and set the running flag if it was. This prevents the system from getting rebooted if the userland daemon doesn't take over soon enough or there isn't a userland daemon at all.

---
 drivers/watchdog/msc313e_wdt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/watchdog/msc313e_wdt.c +4 -0
index 0d497aa0fb7d..90171431fc59 100644
@@ -120,6 +120,10 @@ static int msc313e_wdt_probe(struct platform_device *pdev)
 	priv->wdev.max_timeout = U32_MAX / clk_get_rate(priv->clk);
 	priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT;
 
+	/* If the period is non-zero the WDT is running */
+	if (readw(priv->base + REG_WDT_MAX_PRD_L) | (readw(priv->base + REG_WDT_MAX_PRD_H) << 16))
+		set_bit(WDOG_HW_RUNNING, &priv->wdev.status);
+
 	watchdog_set_drvdata(&priv->wdev, priv);
 
 	watchdog_init_timeout(&priv->wdev, timeout, dev);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Daniel Palmer

Check if the WDT was running at boot and set the running flag if it was. This prevents the system from getting rebooted if the userland daemon doesn't take over soon enough or there isn't a userland daemon at all.

Quoted 20 lines
---
  drivers/watchdog/msc313e_wdt.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/watchdog/msc313e_wdt.c +4 -0
index 0d497aa0fb7d..90171431fc59 100644
@@ -120,6 +120,10 @@ static int msc313e_wdt_probe(struct platform_device *pdev)
  	priv->wdev.max_timeout = U32_MAX / clk_get_rate(priv->clk);
  	priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT;
 
+	/* If the period is non-zero the WDT is running */
+	if (readw(priv->base + REG_WDT_MAX_PRD_L) | (readw(priv->base + REG_WDT_MAX_PRD_H) << 16))
+		set_bit(WDOG_HW_RUNNING, &priv->wdev.status);
+
  	watchdog_set_drvdata(&priv->wdev, priv);
 
  	watchdog_init_timeout(&priv->wdev, timeout, dev);