Petr Pavlu 725c47
From 2253042d86f57d90a621ac2513a7a7a13afcf809 Mon Sep 17 00:00:00 2001
Petr Pavlu 725c47
From: Petr Pavlu <petr.pavlu@suse.com>
Petr Pavlu 725c47
Date: Thu, 13 May 2021 14:26:36 +0200
Petr Pavlu 725c47
Subject: [PATCH] ipmi/watchdog: Stop watchdog timer when the current action is
Petr Pavlu 725c47
 'none'
Petr Pavlu 725c47
Patch-mainline: Queued in subsystem maintainer repository
Petr Pavlu 725c47
Git-repo: git://github.com/cminyard/linux-ipmi.git
Petr Pavlu 725c47
Git-commit: 2253042d86f57d90a621ac2513a7a7a13afcf809
Petr Pavlu 725c47
References: bsc#1184855
Petr Pavlu 725c47
Petr Pavlu 725c47
When an IPMI watchdog timer is being stopped in ipmi_close() or
Petr Pavlu 725c47
ipmi_ioctl(WDIOS_DISABLECARD), the current watchdog action is updated to
Petr Pavlu 725c47
WDOG_TIMEOUT_NONE and _ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB) is called
Petr Pavlu 725c47
to install this action. The latter function ends up invoking
Petr Pavlu 725c47
__ipmi_set_timeout() which makes the actual 'Set Watchdog Timer' IPMI
Petr Pavlu 725c47
request.
Petr Pavlu 725c47
Petr Pavlu 725c47
For IPMI 1.0, this operation results in fully stopping the watchdog timer.
Petr Pavlu 725c47
For IPMI >= 1.5, function __ipmi_set_timeout() always specifies the "don't
Petr Pavlu 725c47
stop" flag in the prepared 'Set Watchdog Timer' IPMI request. This causes
Petr Pavlu 725c47
that the watchdog timer has its action correctly updated to 'none' but the
Petr Pavlu 725c47
timer continues to run. A problem is that IPMI firmware can then still log
Petr Pavlu 725c47
an expiration event when the configured timeout is reached, which is
Petr Pavlu 725c47
unexpected because the watchdog timer was requested to be stopped.
Petr Pavlu 725c47
Petr Pavlu 725c47
The patch fixes this problem by not setting the "don't stop" flag in
Petr Pavlu 725c47
__ipmi_set_timeout() when the current action is WDOG_TIMEOUT_NONE which
Petr Pavlu 725c47
results in stopping the watchdog timer. This makes the behaviour for
Petr Pavlu 725c47
IPMI >= 1.5 consistent with IPMI 1.0. It also matches the logic in
Petr Pavlu 725c47
__ipmi_heartbeat() which does not allow to reset the watchdog if the
Petr Pavlu 725c47
current action is WDOG_TIMEOUT_NONE as that would start the timer.
Petr Pavlu 725c47
Petr Pavlu 725c47
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Petr Pavlu 725c47
Message-Id: <10a41bdc-9c99-089c-8d89-fa98ce5ea080@suse.com>
Petr Pavlu 725c47
Cc: stable@vger.kernel.org
Petr Pavlu 725c47
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Petr Pavlu 725c47
---
Petr Pavlu 725c47
 drivers/char/ipmi/ipmi_watchdog.c | 22 ++++++++++++----------
Petr Pavlu 725c47
 1 file changed, 12 insertions(+), 10 deletions(-)
Petr Pavlu 725c47
Petr Pavlu 725c47
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
Petr Pavlu 725c47
index 32c334e34d55..e4ff3b50de7f 100644
Petr Pavlu 725c47
--- a/drivers/char/ipmi/ipmi_watchdog.c
Petr Pavlu 725c47
+++ b/drivers/char/ipmi/ipmi_watchdog.c
Petr Pavlu 725c47
@@ -371,16 +371,18 @@ static int __ipmi_set_timeout(struct ipmi_smi_msg  *smi_msg,
Petr Pavlu 725c47
 	data[0] = 0;
Petr Pavlu 725c47
 	WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS);
Petr Pavlu 725c47
 
Petr Pavlu 725c47
-	if ((ipmi_version_major > 1)
Petr Pavlu 725c47
-	    || ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) {
Petr Pavlu 725c47
-		/* This is an IPMI 1.5-only feature. */
Petr Pavlu 725c47
-		data[0] |= WDOG_DONT_STOP_ON_SET;
Petr Pavlu 725c47
-	} else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
Petr Pavlu 725c47
-		/*
Petr Pavlu 725c47
-		 * In ipmi 1.0, setting the timer stops the watchdog, we
Petr Pavlu 725c47
-		 * need to start it back up again.
Petr Pavlu 725c47
-		 */
Petr Pavlu 725c47
-		hbnow = 1;
Petr Pavlu 725c47
+	if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
Petr Pavlu 725c47
+		if ((ipmi_version_major > 1) ||
Petr Pavlu 725c47
+		    ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) {
Petr Pavlu 725c47
+			/* This is an IPMI 1.5-only feature. */
Petr Pavlu 725c47
+			data[0] |= WDOG_DONT_STOP_ON_SET;
Petr Pavlu 725c47
+		} else {
Petr Pavlu 725c47
+			/*
Petr Pavlu 725c47
+			 * In ipmi 1.0, setting the timer stops the watchdog, we
Petr Pavlu 725c47
+			 * need to start it back up again.
Petr Pavlu 725c47
+			 */
Petr Pavlu 725c47
+			hbnow = 1;
Petr Pavlu 725c47
+		}
Petr Pavlu 725c47
 	}
Petr Pavlu 725c47
 
Petr Pavlu 725c47
 	data[1] = 0;
Petr Pavlu 725c47
-- 
Petr Pavlu 725c47
2.26.2
Petr Pavlu 725c47