git: b41b86b65f10 - stable/13 - ipmi(4): Add more watchdog error checks.

Alexander Motin mav at FreeBSD.org
Fri Aug 13 01:18:41 UTC 2021


The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=b41b86b65f10ccaa8cce8cc11a030ad464b654c0

commit b41b86b65f10ccaa8cce8cc11a030ad464b654c0
Author:     Alexander Motin <mav at FreeBSD.org>
AuthorDate: 2021-07-30 03:39:04 +0000
Commit:     Alexander Motin <mav at FreeBSD.org>
CommitDate: 2021-08-13 01:18:31 +0000

    ipmi(4): Add more watchdog error checks.
    
    Add request submission status checks before checking req->ir_compcode,
    otherwise it may be zero just because of initialization.
    
    Add checks for req->ir_compcode errors in ipmi_reset_watchdog() and
    ipmi_set_watchdog().  In first case explicitly check for 0x80, which
    means timer was not previously set, that I found happening after BMC
    cold reset.  This change makes watchdog timer to recover instead of
    permanently ignoring reset errors after BMC reset or upgraded.
    
    MFC after:      2 weeks
    Sponsored by:   iXsystems, Inc.
    
    (cherry picked from commit 9d3b47abbba74830661e90206cc0f692b159c432)
---
 sys/dev/ipmi/ipmi.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/sys/dev/ipmi/ipmi.c b/sys/dev/ipmi/ipmi.c
index 25077500d835..cd2a289b25cb 100644
--- a/sys/dev/ipmi/ipmi.c
+++ b/sys/dev/ipmi/ipmi.c
@@ -638,8 +638,15 @@ ipmi_reset_watchdog(struct ipmi_softc *sc)
 	IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 	    IPMI_RESET_WDOG, 0, 0);
 	error = ipmi_submit_driver_request(sc, req, 0);
-	if (error)
+	if (error) {
 		device_printf(sc->ipmi_dev, "Failed to reset watchdog\n");
+	} else if (req->ir_compcode == 0x80) {
+		error = ENOENT;
+	} else if (req->ir_compcode != 0) {
+		device_printf(sc->ipmi_dev, "Watchdog reset returned 0x%x\n",
+		    req->ir_compcode);
+		error = EINVAL;
+	}
 	return (error);
 }
 
@@ -671,8 +678,13 @@ ipmi_set_watchdog(struct ipmi_softc *sc, unsigned int sec)
 		req->ir_request[5] = 0;
 	}
 	error = ipmi_submit_driver_request(sc, req, 0);
-	if (error)
+	if (error) {
 		device_printf(sc->ipmi_dev, "Failed to set watchdog\n");
+	} else if (req->ir_compcode != 0) {
+		device_printf(sc->ipmi_dev, "Watchdog set returned 0x%x\n",
+		    req->ir_compcode);
+		error = EINVAL;
+	}
 	return (error);
 }
 
@@ -886,9 +898,9 @@ ipmi_startup(void *arg)
 		    IPMI_GET_CHANNEL_INFO, 1, 0);
 		req->ir_request[0] = i;
 
-		ipmi_submit_driver_request(sc, req, 0);
+		error = ipmi_submit_driver_request(sc, req, 0);
 
-		if (req->ir_compcode != 0)
+		if (error != 0 || req->ir_compcode != 0)
 			break;
 	}
 	device_printf(dev, "Number of channels %d\n", i);
@@ -901,9 +913,9 @@ ipmi_startup(void *arg)
 		IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 		    IPMI_GET_WDOG, 0, 0);
 
-		ipmi_submit_driver_request(sc, req, 0);
+		error = ipmi_submit_driver_request(sc, req, 0);
 
-		if (req->ir_compcode == 0x00) {
+		if (error == 0 && req->ir_compcode == 0x00) {
 			device_printf(dev, "Attached watchdog\n");
 			/* register the watchdog event handler */
 			sc->ipmi_watchdog_tag = EVENTHANDLER_REGISTER(


More information about the dev-commits-src-all mailing list