[5.15, 5.10, 5,4] watchdog: iTCO: Backport of handle_boot_enabled=0 fix
Subsystems (2)
cover [5.15, 5.10, 5,4] watchdog: iTCO: Backport of handle_boot_enabled=0 fix
This suggests a commit (and a follow-up fix for it) from 5.16+ for stable because it fixes the usage of watchdog.handle_boot_enabled=0 for iTCO, closing a monitoring gap in OTA update scenarios.
These patches are applicable to and have been tested with 5.15, 5.10 and 5.4 stable heads.
Jan
Mika Westerberg (2):
watchdog: iTCO_wdt: No need to stop the timer in probe
watchdog: iTCO_wdt: Set NO_REBOOT if the watchdog is not already
running
drivers/watchdog/iTCO_wdt.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/2 watchdog: iTCO_wdt: No need to stop the timer in probe
From: Mika Westerberg <[email protected]>
commit 1ae3e78c08209ac657c59f6f7ea21bbbd7f6a1d4 upstream.
The watchdog core can handle pinging of the watchdog before userspace opens the device. For this reason instead of stopping the timer, just mark it as running and let the watchdog core take care of it.
--- drivers/watchdog/iTCO_wdt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/watchdog/iTCO_wdt.c +11 -2
@@ -424,6 +424,16 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)return time_left; } +static void iTCO_wdt_set_running (struct iTCO_wdt_private *p) +{ +u16 val; + +/* Bit 11: TCO Timer Halt -> 0 = The TCO timer is * enabled */ + val =inw (TCO1_CNT (p)); +if (!(val &BIT (11 ))) +set_bit (WDOG_HW_RUNNING , &p->wddev.status); +} +/* * Kernel Interfaces */
@@ -566,8 +576,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)watchdog_set_drvdata (&p->wddev, p);platform_set_drvdata (pdev, p); -/* Make sure the watchdog is not running */ -iTCO_wdt_stop (&p->wddev); +iTCO_wdt_set_running (p);/* Check that the heartbeat value is within it's range; if not reset to the default */
Signature · 1 line
2.35.3
PATCH 2/2 watchdog: iTCO_wdt: Set NO_REBOOT if the watchdog is not already running
In reply to Jan KiszkaFrom: Mika Westerberg <[email protected]>
commit ef9b7bf52c2f47f0a9bf988543c577b92c92d15e upstream.
Daniel reported that the commit 1ae3e78c0820 ("watchdog: iTCO_wdt: No need to stop the timer in probe") makes QEMU implementation of the iTCO watchdog not to trigger reboot anymore when NO_REBOOT flag is initially cleared using this option (in QEMU command line):
-global ICH9-LPC.noreboot=false
The problem with the commit is that it left the unconditional setting of NO_REBOOT that is not cleared anymore when the kernel keeps pinging the watchdog (as opposed to the previous code that called iTCO_wdt_stop() that cleared it).
Fix this so that we only set NO_REBOOT if the watchdog was not initially running.
--- drivers/watchdog/iTCO_wdt.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/watchdog/iTCO_wdt.c +14 -7
@@ -424,14 +424,18 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)return time_left; } -static void iTCO_wdt_set_running (struct iTCO_wdt_private *p) +/* Returns true if the watchdog was running */ +static bool iTCO_wdt_set_running (struct iTCO_wdt_private *p) {u16 val; -/* Bit 11: TCO Timer Halt -> 0 = The TCO timer is * enabled */ +/* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled */ val =inw (TCO1_CNT (p)); -if (!(val &BIT (11 ))) +if (!(val &BIT (11 ))) {set_bit (WDOG_HW_RUNNING , &p->wddev.status); +return true; + } +return false; }/*
@@ -522,9 +526,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev)return -ENODEV ;/* Cannot reset NO_REBOOT bit */ } -/* Set the NO_REBOOT bit to prevent later reboots, just for sure */ - p->update_no_reboot_bit (p->no_reboot_priv, true); -if (turn_SMI_watchdog_clear_off >= p->iTCO_version) {/* * Bit 13: TCO_EN -> 0
@@ -576,7 +577,13 @@ static int iTCO_wdt_probe(struct platform_device *pdev)watchdog_set_drvdata (&p->wddev, p);platform_set_drvdata (pdev, p); -iTCO_wdt_set_running (p); +if (!iTCO_wdt_set_running (p)) { +/* +* If the watchdog was not running set NO_REBOOT now to +* prevent later reboots. +*/ + p->update_no_reboot_bit (p->no_reboot_priv, true); + }/* Check that the heartbeat value is within it's range; if not reset to the default */
Signature · 1 line
2.35.3
Quoted 6 lines · Jan Kiszka
This suggests a commit (and a follow-up fix for it) from 5.16+ for stable because it fixes the usage of watchdog.handle_boot_enabled=0 for iTCO, closing a monitoring gap in OTA update scenarios.
These patches are applicable to and have been tested with 5.15, 5.10 and 5.4 stable heads.
Queued up this and the other series, thanks Jan!
Signature · 2 lines
Thanks, Sasha