ipmi(4): don't panic if ipmi_sendcmd() fails

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ipmi(4): don't panic if ipmi_sendcmd() fails

Naoki Fukaumi
Hi tech@,

sending IPMI command can fail for some reason (e.g. during BMC reset,
and possibly BMC is just busy?), then it should be better to return
error than panic().

--- sys/dev/ipmi.c
+++ sys/dev/ipmi.c
@@ -1039,10 +1039,10 @@ ipmi_cmd_poll(struct ipmi_cmd *c)
 {
  mtx_enter(&c->c_sc->sc_cmd_mtx);
 
- if (ipmi_sendcmd(c)) {
- panic("%s: sendcmd fails", DEVNAME(c->c_sc));
- }
- c->c_ccode = ipmi_recvcmd(c);
+ if ((c->c_ccode = ipmi_sendcmd(c)))
+ printf("%s: sendcmd fails\n", DEVNAME(c->c_sc));
+ else
+ c->c_ccode = ipmi_recvcmd(c);
 
  mtx_leave(&c->c_sc->sc_cmd_mtx);
 }
@@ -1819,8 +1819,6 @@ ipmiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *proc)
  c->c_txlen = req->msg.data_len;
  c->c_rxlen = 0;
  ipmi_cmd(c);
-
- KASSERT(c->c_ccode != -1);
  break;
  case IPMICTL_RECEIVE_MSG_TRUNC:
  case IPMICTL_RECEIVE_MSG:

--
FUKAUMI Naoki

Reply | Threaded
Open this post in threaded view
|

Re: ipmi(4): don't panic if ipmi_sendcmd() fails

YASUOKA Masahiko-3
On Tue, 06 Mar 2018 12:37:28 +0900 (JST)
Naoki Fukaumi <[hidden email]> wrote:
> sending IPMI command can fail for some reason (e.g. during BMC reset,
> and possibly BMC is just busy?), then it should be better to return
> error than panic().

Verified.

  # ipmitool mc reset warm
  # ipmitool fru

caused the panic without the diff, but after applying the diff, kernel
keeps working.

ok?

don't panic if ipmi_sendcmd() fails
diff from fukaumi at soum.co.jp.

Index: sys/dev/ipmi.c
===================================================================
RCS file: /var/cvs/openbsd/src/sys/dev/ipmi.c,v
retrieving revision 1.100
diff -u -p -r1.100 ipmi.c
--- sys/dev/ipmi.c 1 Jan 2018 16:16:23 -0000 1.100
+++ sys/dev/ipmi.c 23 Mar 2018 04:16:02 -0000
@@ -1039,10 +1039,10 @@ ipmi_cmd_poll(struct ipmi_cmd *c)
 {
  mtx_enter(&c->c_sc->sc_cmd_mtx);
 
- if (ipmi_sendcmd(c)) {
- panic("%s: sendcmd fails", DEVNAME(c->c_sc));
- }
- c->c_ccode = ipmi_recvcmd(c);
+ if ((c->c_ccode = ipmi_sendcmd(c)))
+ printf("%s: sendcmd fails\n", DEVNAME(c->c_sc));
+ else
+ c->c_ccode = ipmi_recvcmd(c);
 
  mtx_leave(&c->c_sc->sc_cmd_mtx);
 }
@@ -1819,8 +1819,6 @@ ipmiioctl(dev_t dev, u_long cmd, caddr_t
  c->c_txlen = req->msg.data_len;
  c->c_rxlen = 0;
  ipmi_cmd(c);
-
- KASSERT(c->c_ccode != -1);
  break;
  case IPMICTL_RECEIVE_MSG_TRUNC:
  case IPMICTL_RECEIVE_MSG: