[Skiboot] [PATCH 5/9] ipmi-watchdog: Add a flag to determine if we are still ticking

William A. Kennington III wak at google.com
Thu May 24 10:13:31 AEST 2018


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 <wak at google.com>
---
 hw/ipmi/ipmi-watchdog.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/hw/ipmi/ipmi-watchdog.c b/hw/ipmi/ipmi-watchdog.c
index b5cb5fee4..fc559c6da 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;
-- 
2.17.0.441.gb46fe60e1d-goog



More information about the Skiboot mailing list