Skip to contentSkip to conversation

watchdog: core: stop watchdog when executing poweroff command

PATCH In review Meng Li 2 participants 2 messages Aug 14, 2023 Watchdog device drivers

lore
Share & tools
lore

Meng Li

author
#0 lore raw

PATCH v2 1/1 watchdog: core: stop watchdog when executing poweroff command

From: Meng Li <[email protected]>

On some platforms, for example, Intel SoC FPGA platform, the watchdog is started in u-boot, and so kernel will create a timer and work to keep watchdog alive. But when user executes commands "poweroff" or "shutdown -h", the system is reset when watchdog triggers timeout even if WDOG_STOP_ON_REBOOT is set in watchdog driver. The root cause is that the watchdog is not stopped properly because the SYS_POWER_OFF case is not supported in notify callback function. So, add this case to stop watchdog when executing poweroff command.

---

v2:
- fix typos in commit log

---
 drivers/watchdog/watchdog_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/watchdog_core.c +1 -1
index d4c5a736fdcb..5b55ccae06d4 100644
@@ -161,7 +161,7 @@ static int watchdog_reboot_notifier(struct notifier_block *nb,
 	struct watchdog_device *wdd;
 
 	wdd = container_of(nb, struct watchdog_device, reboot_nb);
-	if (code == SYS_DOWN || code == SYS_HALT) {
+	if (code == SYS_DOWN || code == SYS_HALT || code == SYS_POWER_OFF) {
 		if (watchdog_hw_running(wdd)) {
 			int ret;
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Meng Li

From: Meng Li <[email protected]>

On some platforms, for example, Intel SoC FPGA platform, the watchdog is started in u-boot, and so kernel will create a timer and work to keep watchdog alive. But when user executes commands "poweroff" or "shutdown -h", the system is reset when watchdog triggers timeout even if WDOG_STOP_ON_REBOOT is set in watchdog driver. The root cause is that the watchdog is not stopped properly because the SYS_POWER_OFF case is not supported in notify callback function. So, add this case to stop watchdog when executing poweroff command.

Quoted 1 line

Makes sense.

Guenter

Quoted 25 lines

---

v2:
- fix typos in commit log

---
 drivers/watchdog/watchdog_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/watchdog_core.c +1 -1
index d4c5a736fdcb..5b55ccae06d4 100644
@@ -161,7 +161,7 @@ static int watchdog_reboot_notifier(struct notifier_block *nb,
 	struct watchdog_device *wdd;
 
 	wdd = container_of(nb, struct watchdog_device, reboot_nb);
-	if (code == SYS_DOWN || code == SYS_HALT) {
+	if (code == SYS_DOWN || code == SYS_HALT || code == SYS_POWER_OFF) {
 		if (watchdog_hw_running(wdd)) {
 			int ret;
 
Signature · 1 line
2.17.1