Skip to content

Commit ef9b7bf

Browse files
westeriWim Van Sebroeck
authored andcommitted
watchdog: iTCO_wdt: Set NO_REBOOT if the watchdog is not already running
Daniel reported that the commit 1ae3e78 ("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. Fixes: 1ae3e78 ("watchdog: iTCO_wdt: No need to stop the timer in probe") Reported-by: Daniel P. Berrangé <[email protected]> Signed-off-by: Mika Westerberg <[email protected]> Tested-by: Daniel P. Berrangé <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 47c0080 commit ef9b7bf

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/watchdog/iTCO_wdt.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,18 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)
423423
return time_left;
424424
}
425425

426-
static void iTCO_wdt_set_running(struct iTCO_wdt_private *p)
426+
/* Returns true if the watchdog was running */
427+
static bool iTCO_wdt_set_running(struct iTCO_wdt_private *p)
427428
{
428429
u16 val;
429430

430-
/* Bit 11: TCO Timer Halt -> 0 = The TCO timer is * enabled */
431+
/* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled */
431432
val = inw(TCO1_CNT(p));
432-
if (!(val & BIT(11)))
433+
if (!(val & BIT(11))) {
433434
set_bit(WDOG_HW_RUNNING, &p->wddev.status);
435+
return true;
436+
}
437+
return false;
434438
}
435439

436440
/*
@@ -518,9 +522,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
518522
return -ENODEV; /* Cannot reset NO_REBOOT bit */
519523
}
520524

521-
/* Set the NO_REBOOT bit to prevent later reboots, just for sure */
522-
p->update_no_reboot_bit(p->no_reboot_priv, true);
523-
524525
if (turn_SMI_watchdog_clear_off >= p->iTCO_version) {
525526
/*
526527
* Bit 13: TCO_EN -> 0
@@ -572,7 +573,13 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
572573
watchdog_set_drvdata(&p->wddev, p);
573574
platform_set_drvdata(pdev, p);
574575

575-
iTCO_wdt_set_running(p);
576+
if (!iTCO_wdt_set_running(p)) {
577+
/*
578+
* If the watchdog was not running set NO_REBOOT now to
579+
* prevent later reboots.
580+
*/
581+
p->update_no_reboot_bit(p->no_reboot_priv, true);
582+
}
576583

577584
/* Check that the heartbeat value is within it's range;
578585
if not reset to the default */

0 commit comments

Comments
 (0)