summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-05-15 00:46:56 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-05-15 00:46:56 +0000
commitad51e6296f182f850c372f6973a6996c7cc93d5c (patch)
tree1ac0b80ad2a4dfb8276d0bb085caaada400e5ef7
parentdb0db330576946456e7cc5401dd4fc0f6583992e (diff)
Make _bmc_io_wait 1 second instead of 500ms.
Prevent multiple reads and writes to the bmc at the same time which could interrupt a complete bmc transaction. tested by various people.
-rw-r--r--sys/dev/ipmi.c23
-rw-r--r--sys/dev/ipmivar.h4
2 files changed, 19 insertions, 8 deletions
diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c
index e1224d4f835..df7e3ae9ea1 100644
--- a/sys/dev/ipmi.c
+++ b/sys/dev/ipmi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipmi.c,v 1.39 2006/05/12 02:11:53 deraadt Exp $ */
+/* $OpenBSD: ipmi.c,v 1.40 2006/05/15 00:46:55 marco Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave
@@ -1337,16 +1337,19 @@ read_sensor(struct ipmi_softc *sc, struct ipmi_sensor *psensor)
{
struct sdrtype1 *s1 = (struct sdrtype1 *) psensor->i_sdr;
u_int8_t data[8];
- int rxlen;
+ int rxlen, rv = -1;
+
+ if (!cold)
+ lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
memset(data, 0, sizeof(data));
data[0] = psensor->i_num;
if (ipmi_sendcmd(sc, s1->owner_id, s1->owner_lun, SE_NETFN,
SE_GET_SENSOR_READING, 1, data))
- return (-1);
+ goto done;
if (ipmi_recvcmd(sc, sizeof(data), &rxlen, data))
- return (-1);
+ goto done;
dbg_printf(10, "values=%.2x %.2x %.2x %.2x %s\n",
data[0],data[1],data[2],data[3], psensor->i_sensor.desc);
@@ -1356,8 +1359,11 @@ read_sensor(struct ipmi_softc *sc, struct ipmi_sensor *psensor)
psensor->i_sensor.flags |= SENSOR_FINVALID;
}
psensor->i_sensor.status = ipmi_sensor_status(sc, psensor, data);
-
- return (0);
+ rv = 0;
+done:
+ if (!cold)
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ return (rv);
}
int
@@ -1672,10 +1678,13 @@ ipmi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_wdog_period = 0;
wdog_register(sc, ipmi_watchdog);
+ /* lock around read_sensor so that no one messes with the bmc regs */
+ lockinit(&sc->sc_lock, PZERO, DEVNAME(sc), 0, 0);
+
/* setup ticker */
sc->sc_retries = 0;
sc->sc_wakeup = 0;
- sc->sc_max_retries = 50; /* XXX 50ms the right value? */
+ sc->sc_max_retries = 100; /* XXX 1 second the right value? */
timeout_set(&sc->sc_timeout, _bmc_io_wait, sc);
}
diff --git a/sys/dev/ipmivar.h b/sys/dev/ipmivar.h
index 8d893878283..a359755a54e 100644
--- a/sys/dev/ipmivar.h
+++ b/sys/dev/ipmivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipmivar.h,v 1.12 2006/05/08 22:51:18 gwk Exp $ */
+/* $OpenBSD: ipmivar.h,v 1.13 2006/05/15 00:46:55 marco Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave
@@ -97,6 +97,8 @@ struct ipmi_softc {
int sc_retries;
int sc_wakeup;
+ struct lock sc_lock;
+
struct ipmi_bmc_args *sc_iowait_args;
};