Skip to contentSkip to conversation

watchdog: pnx4008: readout watchddog state

PATCH Superseded Alexandre Belloni 2 participants 4 messages Apr 11, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: pnx4008: readout watchddog state

Readout the enabled state so it is possible to get the pre-userspace handler working. Also, avoid disabling the watchdog when nowayout is set to ensure the watchdog continues working and triggers if there is an issue later in the boot or if userspace fails to start.

---
 drivers/watchdog/pnx4008_wdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/pnx4008_wdt.c +5 -1
index 8e261799c84e..9e3714e3814c 100644
@@ -209,7 +209,11 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)
 	watchdog_set_nowayout(&pnx4008_wdd, nowayout);
 	watchdog_set_restart_priority(&pnx4008_wdd, 128);
 
-	pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */
+	if (readl(WDTIM_CTRL(wdt_base)) & COUNT_ENAB)
+		set_bit(WDOG_HW_RUNNING, &pnx4008_wdd.status);
+
+	if (!nowayout)
+		pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */
 
 	ret = watchdog_register_device(&pnx4008_wdd);
 	if (ret < 0) {
Signature · 1 line
2.20.1
maintainer
#1 lore raw

Hi Alexandre,

Quoted 15 lines · Alexandre Belloni

Readout the enabled state so it is possible to get the pre-userspace handler working. Also, avoid disabling the watchdog when nowayout is set to ensure the watchdog continues working and triggers if there is an issue later in the boot or if userspace fails to start.

---
 drivers/watchdog/pnx4008_wdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/pnx4008_wdt.c +0 -0
index 8e261799c84e..9e3714e3814c 100644

drivers/watchdog/pnx4008_wdt.c static int pnx4008_wdt_probe(struct platform_device *pdev) · line 216

Quoted 9 lines
drivers/watchdog/pnx4008_wdt.c +5 -1
@@ -209,7 +209,11 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)
 	watchdog_set_nowayout(&pnx4008_wdd, nowayout);
 	watchdog_set_restart_priority(&pnx4008_wdd, 128);
 
-	pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */
+	if (readl(WDTIM_CTRL(wdt_base)) & COUNT_ENAB)
+		set_bit(WDOG_HW_RUNNING, &pnx4008_wdd.status);
+
+	if (!nowayout)
+		pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */

I don't see the point of stopping the watchdog here, even though that is the old behavior. If it is possible to detect that the watchdog is running, we can let the core handle pings until the watchdog device is opened. The code above does that, but only if nowayout is set. That seems inconsistent and unnecessary. Is there a downside to doing that unconditionally ?

Nitpick: s/watchddog/watchdog/ in subject line.

Thanks,
Guenter

Quoted 6 lines
drivers/watchdog/pnx4008_wdt.c +0 -0
 	ret = watchdog_register_device(&pnx4008_wdd);
 	if (ret < 0) {
Signature · 1 line
2.20.1
#2 lore raw
Quoted 21 lines · Guenter Roeck

Hi Alexandre,

Quoted 18 lines · Alexandre Belloni

Readout the enabled state so it is possible to get the pre-userspace handler working. Also, avoid disabling the watchdog when nowayout is set to ensure the watchdog continues working and triggers if there is an issue later in the boot or if userspace fails to start.

---
 drivers/watchdog/pnx4008_wdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/pnx4008_wdt.c +0 -0
index 8e261799c84e..9e3714e3814c 100644
@@ -209,7 +209,11 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)
 	watchdog_set_nowayout(&pnx4008_wdd, nowayout);
 	watchdog_set_restart_priority(&pnx4008_wdd, 128);
 
Quoted 13 lines

drivers/watchdog/pnx4008_wdt.c static int pnx4008_wdt_probe(struct platform_device *pdev) · line 216

Quoted 6 lines
drivers/watchdog/pnx4008_wdt.c +5 -1
-	pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */
+	if (readl(WDTIM_CTRL(wdt_base)) & COUNT_ENAB)
+		set_bit(WDOG_HW_RUNNING, &pnx4008_wdd.status);
+
+	if (!nowayout)
+		pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */

I don't see the point of stopping the watchdog here, even though that is the old behavior. If it is possible to detect that the watchdog is running, we can let the core handle pings until the watchdog device is opened. The code above does that, but only if nowayout is set. That seems inconsistent and unnecessary. Is there a downside to doing that unconditionally ?

I guess the downside is the change of behaviour. I don't think many will be affected but they will have to ensure the core pings the watchdog until the device is open. WATCHDOG_HANDLE_BOOT_ENABLED is y by default so that should be fine for most.

Honestly, I would just never disable the watchdog, that is the whole point of this patch. If you are fine with that, I will just remove the line.

Quoted 2 lines

Nitpick: s/watchddog/watchdog/ in subject line.

I'll fix it.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
maintainer
#3 lore raw
Quoted 36 lines · Alexandre Belloni
Quoted 21 lines · Guenter Roeck

Hi Alexandre,

Quoted 18 lines · Alexandre Belloni

Readout the enabled state so it is possible to get the pre-userspace handler working. Also, avoid disabling the watchdog when nowayout is set to ensure the watchdog continues working and triggers if there is an issue later in the boot or if userspace fails to start.

---
 drivers/watchdog/pnx4008_wdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/pnx4008_wdt.c +0 -0
index 8e261799c84e..9e3714e3814c 100644
@@ -209,7 +209,11 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)
 	watchdog_set_nowayout(&pnx4008_wdd, nowayout);
 	watchdog_set_restart_priority(&pnx4008_wdd, 128);
 
Quoted 13 lines

drivers/watchdog/pnx4008_wdt.c static int pnx4008_wdt_probe(struct platform_device *pdev) · line 216

Quoted 6 lines
drivers/watchdog/pnx4008_wdt.c +5 -1
-	pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */
+	if (readl(WDTIM_CTRL(wdt_base)) & COUNT_ENAB)
+		set_bit(WDOG_HW_RUNNING, &pnx4008_wdd.status);
+
+	if (!nowayout)
+		pnx4008_wdt_stop(&pnx4008_wdd);	/* disable for now */

I don't see the point of stopping the watchdog here, even though that is the old behavior. If it is possible to detect that the watchdog is running, we can let the core handle pings until the watchdog device is opened. The code above does that, but only if nowayout is set. That seems inconsistent and unnecessary. Is there a downside to doing that unconditionally ?

Quoted 5 lines

I guess the downside is the change of behaviour. I don't think many will be affected but they will have to ensure the core pings the watchdog until the device is open. WATCHDOG_HANDLE_BOOT_ENABLED is y by default so that should be fine for most.

Your code already does change behavior if nowayout is set.

Quoted 4 lines

Honestly, I would just never disable the watchdog, that is the whole point of this patch. If you are fine with that, I will just remove the line.

Please.

Thanks,
Guenter

Quoted 11 lines
Quoted 3 lines

Nitpick: s/watchddog/watchdog/ in subject line.

I'll fix it.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com