Skip to contentSkip to conversation

watchdog: make DesignWare watchdog allow users to set bigger timeout value

PATCH In review Wang, Peng 1. (NSB - CN/Hangzhou) 2 participants 2 messages Nov 25, 2019 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: make DesignWare watchdog allow users to set bigger timeout value

From aabaa4b709bd451e566c906e8d1dca48f92f9b12 Mon Sep 17 00:00:00 2001
From: Peng Wang <[email protected]>
Date: Wed, 20 Nov 2019 15:12:59 +0800
Subject: [PATCH v2.1] watchdog: make DesignWare watchdog allow users to set bigger
timeout value

watchdog_dev.c provides means to allow users to set bigger timeout value than HW can support, make DesignWare watchdog align with this.

---

v2 -> v2.1:
- move Signed-off-by to be ahead of section separator

v1 -> v2:
- use top_s to compare with wdd->max_hw_heartbeat_ms
- update wdd->timeout in case it's greater than HW supports
- fix comments error

v1: initial version

---
 drivers/watchdog/dw_wdt.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/watchdog/dw_wdt.c +9 -1
index fef7c61..12c116e 100644
@@ -114,7 +114,15 @@ static int dw_wdt_set_timeout(struct watchdog_device *wdd, unsigned int top_s)
 	writel(top_val | top_val << WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT,
 	       dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
 
-	wdd->timeout = dw_wdt_top_in_seconds(dw_wdt, top_val);
+	/*
+	 * In case users set bigger timeout value than HW can support,
+	 * kernel(watchdog_dev.c) helps to feed watchdog before
+	 * wdd->max_hw_heartbeat_ms
+	 */
+	if (top_s * 1000 <= wdd->max_hw_heartbeat_ms)
+		wdd->timeout = dw_wdt_top_in_seconds(dw_wdt, top_val);
+	else
+		wdd->timeout = top_s;
 
 	return 0;
 }
Signature · 1 line
1.8.3.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Mon, Nov 25, 2019 at 02:04:13AM +0000, Wang, Peng 1. (NSB - CN/Hangzhou)…

From aabaa4b709bd451e566c906e8d1dca48f92f9b12 Mon Sep 17 00:00:00 2001
From: Peng Wang <[email protected]>
Date: Wed, 20 Nov 2019 15:12:59 +0800
Subject: [PATCH v2.1] watchdog: make DesignWare watchdog allow users to set bigger
timeout value

watchdog_dev.c provides means to allow users to set bigger timeout value than HW can support, make DesignWare watchdog align with this.

Quoted 40 lines

---

v2 -> v2.1:
- move Signed-off-by to be ahead of section separator

v1 -> v2:
- use top_s to compare with wdd->max_hw_heartbeat_ms
- update wdd->timeout in case it's greater than HW supports
- fix comments error

v1: initial version

---
 drivers/watchdog/dw_wdt.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/watchdog/dw_wdt.c +9 -1
index fef7c61..12c116e 100644
@@ -114,7 +114,15 @@ static int dw_wdt_set_timeout(struct watchdog_device *wdd, unsigned int top_s)
 	writel(top_val | top_val << WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT,
 	       dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
 
-	wdd->timeout = dw_wdt_top_in_seconds(dw_wdt, top_val);
+	/*
+	 * In case users set bigger timeout value than HW can support,
+	 * kernel(watchdog_dev.c) helps to feed watchdog before
+	 * wdd->max_hw_heartbeat_ms
+	 */
+	if (top_s * 1000 <= wdd->max_hw_heartbeat_ms)
+		wdd->timeout = dw_wdt_top_in_seconds(dw_wdt, top_val);
+	else
+		wdd->timeout = top_s;
 
 	return 0;
 }
Signature · 1 line
1.8.3.1