Skip to content

Commit

Permalink
ipmi(4): Add more watchdog error checks.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amotin committed Jul 30, 2021
1 parent 74f80bc commit 9d3b47a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions sys/dev/ipmi/ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down

0 comments on commit 9d3b47a

Please sign in to comment.