diff mbox series

[2/9] ipmi-watchdog: Make it possible to set DONT_STOP

Message ID 20180524001335.15457-3-wak@google.com
State Accepted
Headers show
Series ipmi-watchdog: Fixes for error handling and general cleanups | expand

Commit Message

William Kennington May 24, 2018, 12:13 a.m. UTC
The IPMI standard supports setting a DONT_STOP bit during an Watchdog
Set operation. Most of the time we don't want to stop the Watchdog when
updating the settings so we should be using this bit. This patch makes
it possible for callers of set_wdt to prevent the watchdog from being
stopped. This only changes the behavior of the watchdog during the
initial settings update when initializing skiboot. The watchdog is no
longer disabled and then immediately re-enabled.

Signed-off-by: William A. Kennington III <wak@google.com>
---
 hw/ipmi/ipmi-watchdog.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/hw/ipmi/ipmi-watchdog.c b/hw/ipmi/ipmi-watchdog.c
index 966d10de4..ee1608443 100644
--- a/hw/ipmi/ipmi-watchdog.c
+++ b/hw/ipmi/ipmi-watchdog.c
@@ -57,7 +57,8 @@  static void ipmi_wdt_complete(struct ipmi_msg *msg)
 	ipmi_free_msg(msg);
 }
 
-static void set_wdt(uint8_t action, uint16_t count, uint8_t pretimeout)
+static void set_wdt(uint8_t action, uint16_t count, uint8_t pretimeout,
+		bool dont_stop)
 {
 	struct ipmi_msg *ipmi_msg;
 
@@ -69,7 +70,8 @@  static void set_wdt(uint8_t action, uint16_t count, uint8_t pretimeout)
 	}
 	ipmi_msg->error = ipmi_wdt_complete;
 	ipmi_msg->data[0] = TIMER_USE_POST |
-		TIMER_USE_DONT_LOG; 			/* Timer Use */
+		TIMER_USE_DONT_LOG |
+		(dont_stop ? TIMER_USE_DONT_STOP : 0);
 	ipmi_msg->data[1] = action;			/* Timer Actions */
 	ipmi_msg->data[2] = pretimeout;			/* Pre-timeout Interval */
 	ipmi_msg->data[3] = 0;				/* Timer Use Flags */
@@ -113,7 +115,7 @@  void ipmi_wdt_stop(void)
 {
 	if (!wdt_stopped) {
 		wdt_stopped = true;
-		set_wdt(WDT_NO_ACTION, 100, 0);
+		set_wdt(WDT_NO_ACTION, 100, 0, false);
 	}
 }
 
@@ -123,10 +125,10 @@  void ipmi_wdt_final_reset(void)
 	 * behaviour */
 #if 0
 	set_wdt(WDT_RESET_ACTION | WDT_PRETIMEOUT_SMI, WDT_TIMEOUT,
-		WDT_MARGIN/10);
+		WDT_MARGIN/10, true);
 	reset_wdt(NULL, (void *) 1);
 #endif
-	set_wdt(WDT_NO_ACTION, 100, 0);
+	set_wdt(WDT_NO_ACTION, 100, 0, false);
 	ipmi_set_boot_count();
 	cancel_timer(&wdt_timer);
 }
@@ -134,7 +136,7 @@  void ipmi_wdt_final_reset(void)
 void ipmi_wdt_init(void)
 {
 	init_timer(&wdt_timer, reset_wdt, NULL);
-	set_wdt(WDT_RESET_ACTION, WDT_TIMEOUT, 0);
+	set_wdt(WDT_RESET_ACTION, WDT_TIMEOUT, 0, true);
 
 	/* Start the WDT. We do it synchronously to make sure it has
 	 * started before skiboot continues booting. Otherwise we