summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2009-11-15 14:13:13 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2009-11-15 14:13:13 +0000
commit55163d97e22789e99d598a9cfacf7f98d1872138 (patch)
tree08a72266833d521fe02065a7e40d5c04742239b6
parent9fb43e3df4f7129d8df3b814baede2c7e1656f11 (diff)
Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation of ccb's for bioctl and sensors. Tested by johan@ and okan@. Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.
-rw-r--r--sys/dev/ic/ciss.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/sys/dev/ic/ciss.c b/sys/dev/ic/ciss.c
index 7fb0f4f6221..ad77a4011f9 100644
--- a/sys/dev/ic/ciss.c
+++ b/sys/dev/ic/ciss.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ciss.c,v 1.34 2009/04/29 08:24:26 reyk Exp $ */
+/* $OpenBSD: ciss.c,v 1.35 2009/11/15 14:13:12 krw Exp $ */
/*
* Copyright (c) 2005,2006 Michael Shalayeff
@@ -382,12 +382,8 @@ ciss_attach(struct ciss_softc *sc)
sc->sc_link.device = &ciss_dev;
sc->sc_link.adapter_softc = sc;
sc->sc_link.openings = sc->maxcmd / (sc->maxunits? sc->maxunits : 1);
-#if NBIO > 0
- /* XXX Reserve some ccb's for sensor and bioctl. */
- if (sc->maxunits < 2 && sc->sc_link.openings > 2)
- sc->sc_link.openings -= 2;
-#endif
sc->sc_link.adapter = &ciss_switch;
+ sc->sc_link.luns = 1;
sc->sc_link.adapter_target = sc->maxunits;
sc->sc_link.adapter_buswidth = sc->maxunits;
bzero(&saa, sizeof(saa));
@@ -409,8 +405,8 @@ ciss_attach(struct ciss_softc *sc)
#endif
#if NBIO > 0
- /* XXX for now we can only deal w/ one volume and need reserved ccbs. */
- if (!scsibus || sc->maxunits > 1 || sc->sc_link.openings == sc->maxcmd)
+ /* XXX for now we can only deal w/ one volume. */
+ if (!scsibus || sc->maxunits > 1)
return 0;
/* now map all the physdevs into their lds */
@@ -764,6 +760,9 @@ ciss_inq(struct ciss_softc *sc, struct ciss_inquiry *inq)
struct ciss_cmd *cmd;
ccb = ciss_get_ccb(sc);
+ if (ccb == NULL)
+ return ENOMEM;
+
ccb->ccb_len = sizeof(*inq);
ccb->ccb_data = inq;
cmd = &ccb->ccb_cmd;
@@ -796,6 +795,9 @@ ciss_ldmap(struct ciss_softc *sc)
total = sizeof(*lmap) + (sc->maxunits - 1) * sizeof(lmap->map);
ccb = ciss_get_ccb(sc);
+ if (ccb == NULL)
+ return ENOMEM;
+
ccb->ccb_len = total;
ccb->ccb_data = lmap;
cmd = &ccb->ccb_cmd;
@@ -836,6 +838,9 @@ ciss_sync(struct ciss_softc *sc)
flush->flush = sc->sc_flush;
ccb = ciss_get_ccb(sc);
+ if (ccb == NULL)
+ return ENOMEM;
+
ccb->ccb_len = sizeof(*flush);
ccb->ccb_data = flush;
cmd = &ccb->ccb_cmd;
@@ -886,13 +891,14 @@ ciss_scsi_raw_cmd(struct scsi_xfer *xs) /* TODO */
/* TODO check this target has not yet employed w/ any volume */
ccb = ciss_get_ccb(sc);
+ if (ccb == NULL)
+ return NO_CCB;
+
cmd = &ccb->ccb_cmd;
ccb->ccb_len = xs->datalen;
ccb->ccb_data = xs->data;
ccb->ccb_xs = xs;
-
-
cmd->cdblen = xs->cmdlen;
cmd->flags = CISS_CDB_CMD | CISS_CDB_SIMPL;
if (xs->flags & SCSI_DATA_IN)
@@ -945,6 +951,9 @@ ciss_scsi_cmd(struct scsi_xfer *xs)
/* XXX emulate SYNCHRONIZE_CACHE ??? */
ccb = ciss_get_ccb(sc);
+ if (ccb == NULL)
+ return NO_CCB;
+
cmd = &ccb->ccb_cmd;
ccb->ccb_len = xs->datalen;
ccb->ccb_data = xs->data;
@@ -1291,6 +1300,7 @@ ciss_ldid(struct ciss_softc *sc, int target, struct ciss_ldid *id)
ccb = ciss_get_ccb(sc);
if (ccb == NULL)
return ENOMEM;
+
ccb->ccb_len = sizeof(*id);
ccb->ccb_data = id;
ccb->ccb_xs = NULL;
@@ -1319,6 +1329,7 @@ ciss_ldstat(struct ciss_softc *sc, int target, struct ciss_ldstat *stat)
ccb = ciss_get_ccb(sc);
if (ccb == NULL)
return ENOMEM;
+
ccb->ccb_len = sizeof(*stat);
ccb->ccb_data = stat;
ccb->ccb_xs = NULL;
@@ -1347,6 +1358,7 @@ ciss_pdid(struct ciss_softc *sc, u_int8_t drv, struct ciss_pdid *id, int wait)
ccb = ciss_get_ccb(sc);
if (ccb == NULL)
return ENOMEM;
+
ccb->ccb_len = sizeof(*id);
ccb->ccb_data = id;
ccb->ccb_xs = NULL;
@@ -1425,6 +1437,7 @@ ciss_blink(struct ciss_softc *sc, int ld, int pd, int stat,
ccb = ciss_get_ccb(sc);
if (ccb == NULL)
return ENOMEM;
+
ccb->ccb_len = sizeof(*blink);
ccb->ccb_data = blink;
ccb->ccb_xs = NULL;