summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-08-01 22:49:38 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-08-01 22:49:38 +0000
commit537747624b6d9a808c56233517e47cc629b23e30 (patch)
treee20006aef80cf558acab2a3e6b2194792c8a9b10 /sys
parent93fbbcd0517d3df98f023984a19abd8fbe7e0baf (diff)
Add a wait between send and receive command. Talked through with jordan.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ipmi.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c
index c4f2f6a1802..af3bdb3b260 100644
--- a/sys/dev/ipmi.c
+++ b/sys/dev/ipmi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipmi.c,v 1.46 2006/08/01 20:02:04 marco Exp $ */
+/* $OpenBSD: ipmi.c,v 1.47 2006/08/01 22:49:37 marco Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave
@@ -148,6 +148,7 @@ int get_sdr(struct ipmi_softc *, u_int16_t, u_int16_t *);
int ipmi_sendcmd(struct ipmi_softc *, int, int, int, int, int, const void*);
int ipmi_recvcmd(struct ipmi_softc *, int, int *, void *);
+void ipmi_delay(struct ipmi_softc *, int);
int ipmi_watchdog(void *, int);
@@ -988,7 +989,7 @@ ipmi_sendcmd(struct ipmi_softc *sc, int rssa, int rslun, int netfn, int cmd,
int txlen, const void *data)
{
u_int8_t *buf;
- int rc;
+ int rc = -1;
dbg_printf(50, "ipmi_sendcmd: rssa=%.2x nfln=%.2x cmd=%.2x len=%.2x\n",
rssa, NETFN_LUN(netfn, rslun), cmd, txlen);
@@ -1012,18 +1013,21 @@ ipmi_sendcmd(struct ipmi_softc *sc, int rssa, int rslun, int netfn, int cmd,
/* Set message checksum */
imbreq->data[txlen] = cksum8(&imbreq->rqSa, txlen + 3);
#endif
- return (-1);
+ goto done;
} else
buf = sc->sc_if->buildmsg(sc, NETFN_LUN(netfn, rslun), cmd,
txlen, data, &txlen);
if (buf == NULL) {
printf("%s: sendcmd malloc fails\n", DEVNAME(sc));
- return (-1);
+ goto done;
}
rc = sc->sc_if->sendmsg(sc, txlen, buf);
free(buf, M_DEVBUF);
+ ipmi_delay(sc, 5); /* give bmc chance to digest command */
+
+done:
return (rc);
}
@@ -1061,6 +1065,16 @@ ipmi_recvcmd(struct ipmi_softc *sc, int maxlen, int *rxlen, void *data)
return (rc);
}
+void
+ipmi_delay(struct ipmi_softc *sc, int period)
+{
+ /* period is in 10 ms increments */
+ if (cold)
+ delay(period * 10000);
+ else
+ while (tsleep(sc, PWAIT, "ipmicmd", period) != EWOULDBLOCK);
+}
+
/* Read a partial SDR entry */
int
get_sdr_partial(struct ipmi_softc *sc, u_int16_t recordId, u_int16_t reserveId,
@@ -1680,9 +1694,6 @@ ipmi_attach(struct device *parent, struct device *self, void *aux)
ipmi_unmap_regs(sc, ia);
return;
}
-
- delay(250000);
-
if (ipmi_recvcmd(sc, sizeof(cmd), &len, cmd)) {
printf(": unable to retrieve device id\n");
ipmi_unmap_regs(sc, ia);