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