Skip to contentSkip to conversation

drivers: watchdog: marvell_gti: fix zero pretimeout handling

PATCH In review Bharat Bhushan 2 participants 4 messages Oct 9, 2023 – Oct 11, 2023 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drivers: watchdog: marvell_gti: fix zero pretimeout handling

When pretimeout is set to 0 then do not reprogram timer with zero timeout, this will reset device immediately. Also disable interrupt to stop pretimeout notification.

---
 drivers/watchdog/marvell_gti_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/watchdog/marvell_gti_wdt.c +7 -0
index d7eb8286e11e..25b7ce0f0738 100644
@@ -190,6 +190,13 @@ static int gti_wdt_set_pretimeout(struct watchdog_device *wdev,
 	struct gti_wdt_priv *priv = watchdog_get_drvdata(wdev);
 	struct watchdog_device *wdog_dev = &priv->wdev;
 
+	if (!timeout) {
+		/* Disable Interrupt */
+		writeq(GTI_CWD_INT_ENA_CLR_VAL(priv->wdt_timer_idx),
+		       priv->base + GTI_CWD_INT_ENA_CLR);
+		return 0;
+	}
+
 	/* pretimeout should 1/3 of max_timeout */
 	if (timeout * 3 <= wdog_dev->max_timeout)
 		return gti_wdt_settimeout(wdev, timeout * 3);
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drivers: watchdog: marvell_gti: Program the max_hw_heartbeat_ms

From: George Cherian <[email protected]>

Program the max_hw_heartbeat_ms value so that the watchdog_pretimeout worker is activated. This kernel worker thread makes sure to ping the watchdog in case the userspace is unable to do so. This kernel worker ping will be done only till the full watchdog timeout there by maintaining the watchdog functionality in case of a real hang.

---
 drivers/watchdog/marvell_gti_wdt.c | 1 +
 1 file changed, 1 insertion(+)
drivers/watchdog/marvell_gti_wdt.c +1 -0
index 25b7ce0f0738..bfe0c819248c 100644
@@ -299,6 +299,7 @@ static int gti_wdt_probe(struct platform_device *pdev)
 
 	/* Maximum timeout is 3 times the pretimeout */
 	wdog_dev->max_timeout = max_pretimeout * 3;
+	wdog_dev->max_hw_heartbeat_ms = max_pretimeout * 1000;
 	/* Minimum first timeout (pretimeout) is 1, so min_timeout as 3 */
 	wdog_dev->min_timeout = 3;
 	wdog_dev->timeout = wdog_dev->pretimeout;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drivers: watchdog: marvell_gti: Program the max_hw_heartbeat_ms

Quoted 10 lines · Bharat Bhushan

From: George Cherian <[email protected]>

Program the max_hw_heartbeat_ms value so that the watchdog_pretimeout worker is activated. This kernel worker thread makes sure to ping the watchdog in case the userspace is unable to do so. This kernel worker ping will be done only till the full watchdog timeout there by maintaining the watchdog functionality in case of a real hang.

Quoted 19 lines
---
 drivers/watchdog/marvell_gti_wdt.c | 1 +
 1 file changed, 1 insertion(+)
drivers/watchdog/marvell_gti_wdt.c +1 -0
index 25b7ce0f0738..bfe0c819248c 100644
@@ -299,6 +299,7 @@ static int gti_wdt_probe(struct platform_device *pdev)
 
 	/* Maximum timeout is 3 times the pretimeout */
 	wdog_dev->max_timeout = max_pretimeout * 3;
+	wdog_dev->max_hw_heartbeat_ms = max_pretimeout * 1000;
 	/* Minimum first timeout (pretimeout) is 1, so min_timeout as 3 */
 	wdog_dev->min_timeout = 3;
 	wdog_dev->timeout = wdog_dev->pretimeout;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/2
#3 lore raw
In reply to Bharat Bhushan
Quoted 5 lines · Bharat Bhushan

When pretimeout is set to 0 then do not reprogram timer with zero timeout, this will reset device immediately. Also disable interrupt to stop pretimeout notification.

Quoted 25 lines
---
 drivers/watchdog/marvell_gti_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/watchdog/marvell_gti_wdt.c +7 -0
index d7eb8286e11e..25b7ce0f0738 100644
@@ -190,6 +190,13 @@ static int gti_wdt_set_pretimeout(struct watchdog_device *wdev,
 	struct gti_wdt_priv *priv = watchdog_get_drvdata(wdev);
 	struct watchdog_device *wdog_dev = &priv->wdev;
 
+	if (!timeout) {
+		/* Disable Interrupt */
+		writeq(GTI_CWD_INT_ENA_CLR_VAL(priv->wdt_timer_idx),
+		       priv->base + GTI_CWD_INT_ENA_CLR);
+		return 0;
+	}
+
 	/* pretimeout should 1/3 of max_timeout */
 	if (timeout * 3 <= wdog_dev->max_timeout)
 		return gti_wdt_settimeout(wdev, timeout * 3);
Signature · 1 line
2.34.1