summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2010-06-01 15:27:17 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2010-06-01 15:27:17 +0000
commit601a8f7fc032bd3c0e5c879f26f26bd3f0d9f677 (patch)
treec3cc0576ae8a6265a514b0b8a29cdf97c52125ea /sys/scsi
parent100ce6973a66257f35c13703444cd4f93d7316a4 (diff)
move cd, st & ss over to bufq's again.
Tested by myself and krw. ok krw@
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/cd.c24
-rw-r--r--sys/scsi/ss.c18
-rw-r--r--sys/scsi/ss_mustek.c4
-rw-r--r--sys/scsi/ss_scanjet.c4
-rw-r--r--sys/scsi/ssvar.h5
-rw-r--r--sys/scsi/st.c29
6 files changed, 34 insertions, 50 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 46b6d3b29e9..7b1008eac9f 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.167 2010/05/18 04:41:14 dlg Exp $ */
+/* $OpenBSD: cd.c,v 1.168 2010/06/01 15:27:16 thib Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -110,8 +110,7 @@ struct cd_softc {
u_int32_t blksize;
daddr64_t disksize; /* total number sectors */
} sc_params;
- struct buf sc_buf_queue;
- struct mutex sc_buf_mtx;
+ struct bufq *sc_bufq;
struct mutex sc_start_mtx;
u_int sc_start_count;
struct timeout sc_timeout;
@@ -213,7 +212,6 @@ cdattach(struct device *parent, struct device *self, void *aux)
SC_DEBUG(sc_link, SDEV_DB2, ("cdattach:\n"));
- mtx_init(&sc->sc_buf_mtx, IPL_BIO);
mtx_init(&sc->sc_start_mtx, IPL_BIO);
/*
@@ -230,6 +228,7 @@ cdattach(struct device *parent, struct device *self, void *aux)
*/
sc->sc_dk.dk_driver = &cddkdriver;
sc->sc_dk.dk_name = sc->sc_dev.dv_xname;
+ sc->sc_bufq = bufq_init(BUFQ_DEFAULT);
disk_attach(&sc->sc_dk);
/*
@@ -274,7 +273,7 @@ cddetach(struct device *self, int flags)
struct cd_softc *sc = (struct cd_softc *)self;
int bmaj, cmaj, mn;
- scsi_buf_killqueue(&sc->sc_buf_queue, &sc->sc_buf_mtx);
+ bufq_drain(sc->sc_bufq);
/* Locate the lowest minor number to be detached. */
mn = DISKMINOR(self->dv_unit, 0);
@@ -291,6 +290,7 @@ cddetach(struct device *self, int flags)
powerhook_disestablish(sc->sc_cdpwrhook);
/* Detach disk. */
+ bufq_destroy(sc->sc_bufq);
disk_detach(&sc->sc_dk);
return (0);
@@ -520,12 +520,8 @@ cdstrategy(struct buf *bp)
(sc->sc_flags & (CDF_WLABEL|CDF_LABELLING)) != 0) <= 0)
goto done;
- /*
- * Place it in the queue of disk activities for this disk
- */
- mtx_enter(&sc->sc_buf_mtx);
- disksort(&sc->sc_buf_queue, bp);
- mtx_leave(&sc->sc_buf_mtx);
+ /* Place it in the queue of disk activities for this disk. */
+ BUFQ_QUEUE(sc->sc_bufq, bp);
/*
* Tell the device to get going on the transfer if it's
@@ -592,7 +588,7 @@ cdstart(void *v)
CLR(sc->sc_flags, CDF_WAITING);
restart:
while (!ISSET(sc->sc_flags, CDF_WAITING) &&
- (bp = scsi_buf_dequeue(&sc->sc_buf_queue, &sc->sc_buf_mtx)) != NULL) {
+ (bp = BUFQ_DEQUEUE(sc->sc_bufq)) != NULL) {
/*
* If the device has become invalid, abort all the
* reads and writes until all files have been closed and
@@ -610,7 +606,7 @@ restart:
xs = scsi_xs_get(sc_link, SCSI_NOSLEEP);
if (xs == NULL) {
- scsi_buf_requeue(&sc->sc_buf_queue, bp, &sc->sc_buf_mtx);
+ BUFQ_REQUEUE(sc->sc_bufq, bp);
break;
}
@@ -696,7 +692,7 @@ cd_buf_done(struct scsi_xfer *xs)
/* The adapter is busy, requeue the buf and try it later. */
disk_unbusy(&sc->sc_dk, bp->b_bcount - xs->resid,
bp->b_flags & B_READ);
- scsi_buf_requeue(&sc->sc_buf_queue, bp, &sc->sc_buf_mtx);
+ BUFQ_REQUEUE(sc->sc_bufq, bp);
scsi_xs_put(xs);
SET(sc->sc_flags, CDF_WAITING); /* break out of cdstart loop */
timeout_add(&sc->sc_timeout, 1);
diff --git a/sys/scsi/ss.c b/sys/scsi/ss.c
index 3eb378bd312..5c58eebf4ef 100644
--- a/sys/scsi/ss.c
+++ b/sys/scsi/ss.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ss.c,v 1.71 2010/04/12 09:51:48 dlg Exp $ */
+/* $OpenBSD: ss.c,v 1.72 2010/06/01 15:27:16 thib Exp $ */
/* $NetBSD: ss.c,v 1.10 1996/05/05 19:52:55 christos Exp $ */
/*
@@ -354,17 +354,12 @@ ssattach(parent, self, aux)
/* XXX fill in the rest of the scan_io struct by calling the
compute_sizes routine */
- mtx_init(&ss->sc_buf_mtx, IPL_BIO);
mtx_init(&ss->sc_start_mtx, IPL_BIO);
timeout_set(&ss->timeout, ssstart, ss);
- /*
- * Set up the buf queue for this device
- */
- ss->sc_buf_queue.b_active = 0;
- ss->sc_buf_queue.b_actf = 0;
- ss->sc_buf_queue.b_actb = &ss->sc_buf_queue.b_actf;
+ /* Set up the buf queue for this device. */
+ ss->sc_bufq = bufq_init(BUFQ_DEFAULT);
}
void
@@ -584,7 +579,7 @@ ssstrategy(bp)
* at the end (a bit silly because we only have on user..)
* (but it could fork() or dup())
*/
- scsi_buf_enqueue(&ss->sc_buf_queue, bp, &ss->sc_buf_mtx);
+ BUFQ_QUEUE(ss->sc_bufq, bp);
/*
* Tell the device to get going on the transfer if it's
@@ -641,8 +636,7 @@ ssstart(v)
CLR(ss->flags, SSF_WAITING);
restart:
while (!ISSET(ss->flags, SSF_WAITING) &&
- (bp = scsi_buf_dequeue(&ss->sc_buf_queue, &ss->sc_buf_mtx)) != NULL) {
-
+ (bp = BUFQ_DEQUEUE(ss->sc_bufq)) != NULL) {
xs = scsi_xs_get(sc_link, SCSI_NOSLEEP);
if (xs == NULL)
break;
@@ -692,7 +686,7 @@ ssdone(struct scsi_xfer *xs)
case XS_NO_CCB:
/* The adapter is busy, requeue the buf and try it later. */
- scsi_buf_requeue(&ss->sc_buf_queue, bp, &ss->sc_buf_mtx);
+ BUFQ_REQUEUE(ss->sc_bufq, bp);
scsi_xs_put(xs);
SET(ss->flags, SSF_WAITING); /* break out of cdstart loop */
timeout_add(&ss->timeout, 1);
diff --git a/sys/scsi/ss_mustek.c b/sys/scsi/ss_mustek.c
index 47899c45fa4..4d0d199ad50 100644
--- a/sys/scsi/ss_mustek.c
+++ b/sys/scsi/ss_mustek.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ss_mustek.c,v 1.21 2010/04/12 09:51:48 dlg Exp $ */
+/* $OpenBSD: ss_mustek.c,v 1.22 2010/06/01 15:27:16 thib Exp $ */
/* $NetBSD: ss_mustek.c,v 1.4 1996/05/05 19:52:57 christos Exp $ */
/*
@@ -486,7 +486,7 @@ mustek_read_done(struct scsi_xfer *xs)
case XS_NO_CCB:
/* The adapter is busy, requeue the buf and try it later. */
- scsi_buf_requeue(&ss->sc_buf_queue, bp, &ss->sc_buf_mtx);
+ BUFQ_REQUEUE(ss->sc_bufq, bp);
scsi_xs_put(xs);
SET(ss->flags, SSF_WAITING); /* break out of cdstart loop */
timeout_add(&ss->timeout, 1);
diff --git a/sys/scsi/ss_scanjet.c b/sys/scsi/ss_scanjet.c
index 1a63981ca0f..7d0cc5dcfaf 100644
--- a/sys/scsi/ss_scanjet.c
+++ b/sys/scsi/ss_scanjet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ss_scanjet.c,v 1.38 2010/04/12 09:51:48 dlg Exp $ */
+/* $OpenBSD: ss_scanjet.c,v 1.39 2010/06/01 15:27:16 thib Exp $ */
/* $NetBSD: ss_scanjet.c,v 1.6 1996/05/18 22:58:01 christos Exp $ */
/*
@@ -324,7 +324,7 @@ scanjet_read_done(struct scsi_xfer *xs)
case XS_NO_CCB:
/* The adapter is busy, requeue the buf and try it later. */
- scsi_buf_requeue(&ss->sc_buf_queue, bp, &ss->sc_buf_mtx);
+ BUFQ_REQUEUE(ss->sc_bufq, bp);
scsi_xs_put(xs);
SET(ss->flags, SSF_WAITING); /* break out of cdstart loop */
timeout_add(&ss->timeout, 1);
diff --git a/sys/scsi/ssvar.h b/sys/scsi/ssvar.h
index 14fbffd29d1..ba6f9e5c8b5 100644
--- a/sys/scsi/ssvar.h
+++ b/sys/scsi/ssvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssvar.h,v 1.16 2010/01/15 05:50:31 krw Exp $ */
+/* $OpenBSD: ssvar.h,v 1.17 2010/06/01 15:27:16 thib Exp $ */
/* $NetBSD: ssvar.h,v 1.2 1996/03/30 21:47:11 christos Exp $ */
/*
@@ -70,11 +70,10 @@ struct ss_softc {
#define SSF_WAITING 0x04
struct scsi_link *sc_link; /* contains our targ, lun, etc. */
struct scan_io sio;
- struct buf sc_buf_queue; /* the queue of pending IO operations */
+ struct bufq *sc_bufq;
const struct quirkdata *quirkdata; /* if we have a rogue entry */
struct ss_special special; /* special handlers for spec. devices */
struct timeout timeout;
- struct mutex sc_buf_mtx;
struct mutex sc_start_mtx;
u_int sc_start_count;
};
diff --git a/sys/scsi/st.c b/sys/scsi/st.c
index c53129ce6b0..3522b64d4b5 100644
--- a/sys/scsi/st.c
+++ b/sys/scsi/st.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: st.c,v 1.94 2010/04/12 09:51:48 dlg Exp $ */
+/* $OpenBSD: st.c,v 1.95 2010/06/01 15:27:16 thib Exp $ */
/* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */
/*
@@ -216,9 +216,8 @@ struct st_softc {
#define BLKSIZE_SET_BY_USER 0x04
#define BLKSIZE_SET_BY_QUIRK 0x08
- struct buf sc_buf_queue; /* the queue of pending IO operations */
+ struct bufq *sc_bufq;
struct timeout sc_timeout;
- struct mutex sc_buf_mtx;
struct mutex sc_start_mtx;
u_int sc_start_count;
};
@@ -336,17 +335,12 @@ stattach(struct device *parent, struct device *self, void *aux)
st_identify_drive(st, sa->sa_inqbuf);
printf("\n");
- mtx_init(&st->sc_buf_mtx, IPL_BIO);
mtx_init(&st->sc_start_mtx, IPL_BIO);
timeout_set(&st->sc_timeout, ststart, st);
- /*
- * Set up the buf queue for this device
- */
- st->sc_buf_queue.b_active = 0;
- st->sc_buf_queue.b_actf = 0;
- st->sc_buf_queue.b_actb = &st->sc_buf_queue.b_actf;
+ /* Set up the buf queue for this device. */
+ st->sc_bufq = bufq_init(BUFQ_DEFAULT);
/* Start up with media position unknown. */
st->media_fileno = -1;
@@ -372,7 +366,7 @@ stactivate(struct device *self, int act)
case DVACT_DEACTIVATE:
st->flags |= ST_DYING;
- scsi_buf_killqueue(&st->sc_buf_queue, &st->sc_buf_mtx);
+ bufq_drain(st->sc_bufq);
break;
}
@@ -385,7 +379,7 @@ stdetach(struct device *self, int flags)
struct st_softc *st = (struct st_softc *)self;
int bmaj, cmaj, mn;
- scsi_buf_killqueue(&st->sc_buf_queue, &st->sc_buf_mtx);
+ bufq_drain(st->sc_bufq);
/* Locate the lowest minor number to be detached. */
mn = STUNIT(self->dv_unit);
@@ -405,6 +399,8 @@ stdetach(struct device *self, int flags)
vdevgone(cmaj, mn, mn + 3, VCHR);
}
+ bufq_destroy(st->sc_bufq);
+
return (0);
}
@@ -887,7 +883,7 @@ ststrategy(struct buf *bp)
* at the end (a bit silly because we only have on user..
* (but it could fork()))
*/
- scsi_buf_enqueue(&st->sc_buf_queue, bp, &st->sc_buf_mtx);
+ BUFQ_QUEUE(st->sc_bufq, bp);
/*
* Tell the device to get going on the transfer if it's
@@ -950,8 +946,7 @@ ststart(void *v)
CLR(st->flags, ST_WAITING);
restart:
while (!ISSET(st->flags, ST_WAITING) &&
- (bp = scsi_buf_dequeue(&st->sc_buf_queue, &st->sc_buf_mtx)) != NULL) {
-
+ (bp = BUFQ_DEQUEUE(st->sc_bufq)) != NULL) {
/*
* if the device has been unmounted by the user
* then throw away all requests until done
@@ -971,7 +966,7 @@ restart:
xs = scsi_xs_get(sc_link, SCSI_NOSLEEP);
if (xs == NULL) {
- scsi_buf_requeue(&st->sc_buf_queue, bp, &st->sc_buf_mtx);
+ BUFQ_REQUEUE(st->sc_bufq, bp);
break;
}
@@ -1098,7 +1093,7 @@ st_buf_done(struct scsi_xfer *xs)
case XS_NO_CCB:
/* The adapter is busy, requeue the buf and try it later. */
- scsi_buf_requeue(&st->sc_buf_queue, bp, &st->sc_buf_mtx);
+ BUFQ_REQUEUE(st->sc_bufq, bp);
scsi_xs_put(xs);
SET(st->flags, ST_WAITING); /* break out of cdstart loop */
timeout_add(&st->sc_timeout, 1);