From c9f363245238b746660dd6198d4c28c7529dacea Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Wed, 23 May 2018 17:13:31 -0700 Subject: ipmi-watchdog: Add a flag to determine if we are still ticking This makes it easier for future changes to ensure that the watchdog stops ticking and doesn't requeue itself for execution in the background. This way it is safe for resets to be performed after the ticks are assumed to be stopped and it won't start the timer again. Signed-off-by: William A. Kennington III Signed-off-by: Stewart Smith --- hw/ipmi/ipmi-watchdog.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'hw') diff --git a/hw/ipmi/ipmi-watchdog.c b/hw/ipmi/ipmi-watchdog.c index b5cb5fe..fc559c6 100644 --- a/hw/ipmi/ipmi-watchdog.c +++ b/hw/ipmi/ipmi-watchdog.c @@ -46,11 +46,12 @@ more frequently than necessary. */ #define WDT_MARGIN 300 static struct timer wdt_timer; -static bool wdt_stopped = false; +static bool wdt_stopped; +static bool wdt_ticking; static void ipmi_wdt_complete(struct ipmi_msg *msg) { - if (msg->cmd == IPMI_CMD(IPMI_RESET_WDT) && !msg->user_data) + if (msg->cmd == IPMI_CMD(IPMI_RESET_WDT) && wdt_ticking) schedule_timer(&wdt_timer, msecs_to_tb( (WDT_TIMEOUT - WDT_MARGIN)*100)); @@ -121,11 +122,18 @@ void ipmi_wdt_stop(void) void ipmi_wdt_final_reset(void) { + /* We can safely stop the timer prior to setting up our final + * watchdog timeout since we have enough margin before the + * timeout. */ + wdt_ticking = false; + cancel_timer(&wdt_timer); + + /* Configure the watchdog and make sure it is still enabled */ set_wdt(WDT_RESET_ACTION | WDT_PRETIMEOUT_SMI, WDT_TIMEOUT, WDT_MARGIN/10, true); sync_reset_wdt(); + ipmi_set_boot_count(); - cancel_timer(&wdt_timer); } void ipmi_wdt_init(void) @@ -136,6 +144,7 @@ void ipmi_wdt_init(void) /* Start the WDT. We do it synchronously to make sure it has * started before skiboot continues booting. Otherwise we * could crash before the wdt has actually been started. */ + wdt_ticking = true; sync_reset_wdt(); return; -- cgit v1.1