diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c index d8b15fb1d7ea..addf8678d11e 100644 --- a/sys/dev/scsipi/cd.c +++ b/sys/dev/scsipi/cd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.163 2002/05/27 16:42:30 drochner Exp $ */ +/* $NetBSD: cd.c,v 1.164 2002/07/22 14:59:43 hannken Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.163 2002/05/27 16:42:30 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.164 2002/07/22 14:59:43 hannken Exp $"); #include "rnd.h" @@ -162,7 +162,7 @@ cdattach(parent, cd, periph, ops) { SC_DEBUG(periph, SCSIPI_DB2, ("cdattach: ")); - BUFQ_INIT(&cd->buf_queue); + bufq_alloc(&cd->buf_queue, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK); /* * Store information needed to contact our base driver @@ -242,14 +242,15 @@ cddetach(self, flags) s = splbio(); /* Kill off any queued buffers. */ - while ((bp = BUFQ_FIRST(&cd->buf_queue)) != NULL) { - BUFQ_REMOVE(&cd->buf_queue, bp); + while ((bp = BUFQ_GET(&cd->buf_queue)) != NULL) { bp->b_error = EIO; bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; biodone(bp); } + bufq_free(&cd->buf_queue); + /* Kill off any pending commands. */ scsipi_kill_pending(cd->sc_periph); @@ -670,7 +671,7 @@ cdstrategy(bp) * XXX Only do disksort() if the current operating mode does not * XXX include tagged queueing. */ - disksort_blkno(&cd->buf_queue, bp); + BUFQ_PUT(&cd->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -739,9 +740,8 @@ cdstart(periph) /* * See if there is a buf with work for us to do.. */ - if ((bp = BUFQ_FIRST(&cd->buf_queue)) == NULL) + if ((bp = BUFQ_GET(&cd->buf_queue)) == NULL) return; - BUFQ_REMOVE(&cd->buf_queue, bp); /* * If the device has become invalid, abort all the @@ -907,7 +907,7 @@ cdbounce(bp) * XXX Only do disksort() if the current operating mode * XXX does not include tagged queueing. */ - disksort_blkno(&cd->buf_queue, nbp); + BUFQ_PUT(&cd->buf_queue, nbp); /* * Tell the device to get going on the transfer if it's diff --git a/sys/dev/scsipi/cdvar.h b/sys/dev/scsipi/cdvar.h index 6a8733d1ced6..bba9eed46acf 100644 --- a/sys/dev/scsipi/cdvar.h +++ b/sys/dev/scsipi/cdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdvar.h,v 1.14 2002/04/23 20:41:20 bouyer Exp $ */ +/* $NetBSD: cdvar.h,v 1.15 2002/07/22 14:59:44 hannken Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. All rights reserved. @@ -51,7 +51,7 @@ struct cd_softc { u_long disksize; /* total number sectors */ } params; - struct buf_queue buf_queue; + struct bufq_state buf_queue; char name[16]; /* product name, for default disklabel */ const struct cd_ops *sc_ops; /* our bus-dependent ops vector */ diff --git a/sys/dev/scsipi/ss.c b/sys/dev/scsipi/ss.c index 9c0afd4c9cd2..c6904c1aa63e 100644 --- a/sys/dev/scsipi/ss.c +++ b/sys/dev/scsipi/ss.c @@ -1,4 +1,4 @@ -/* $NetBSD: ss.c,v 1.38 2001/11/15 09:48:18 lukem Exp $ */ +/* $NetBSD: ss.c,v 1.39 2002/07/22 14:59:44 hannken Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ss.c,v 1.38 2001/11/15 09:48:18 lukem Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ss.c,v 1.39 2002/07/22 14:59:44 hannken Exp $"); #include #include @@ -145,6 +145,11 @@ ssattach(struct device *parent, struct device *self, void *aux) printf("\n"); + /* + * Set up the buf queue for this device + */ + bufq_alloc(&ss->buf_queue, BUFQ_FCFS); + /* * look for non-standard scanners with help of the quirk table * and install functions for special handling @@ -159,10 +164,6 @@ ssattach(struct device *parent, struct device *self, void *aux) /* XXX add code to restart a SCSI2 scanner, if any */ } - /* - * Set up the buf queue for this device - */ - BUFQ_INIT(&ss->buf_queue); ss->flags &= ~SSF_AUTOCONF; } @@ -181,14 +182,15 @@ ssdetach(struct device *self, int flags) s = splbio(); /* Kill off any queued buffers. */ - while ((bp = BUFQ_FIRST(&ss->buf_queue)) != NULL) { - BUFQ_REMOVE(&ss->buf_queue, bp); + while ((bp = BUFQ_GET(&ss->buf_queue)) != NULL) { bp->b_error = EIO; bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; biodone(bp); } + bufq_free(&ss->buf_queue); + /* Kill off any pending commands. */ scsipi_kill_pending(ss->sc_periph); @@ -431,7 +433,7 @@ ssstrategy(bp) * at the end (a bit silly because we only have on user.. * (but it could fork())) */ - BUFQ_INSERT_TAIL(&ss->buf_queue, bp); + BUFQ_PUT(&ss->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -488,9 +490,8 @@ ssstart(periph) /* * See if there is a buf with work for us to do.. */ - if ((bp = BUFQ_FIRST(&ss->buf_queue)) == NULL) + if ((bp = BUFQ_GET(&ss->buf_queue)) == NULL) return; - BUFQ_REMOVE(&ss->buf_queue, bp); if (ss->special && ss->special->read) { (ss->special->read)(ss, bp); diff --git a/sys/dev/scsipi/ssvar.h b/sys/dev/scsipi/ssvar.h index 65c0c419b87c..3a493bb11415 100644 --- a/sys/dev/scsipi/ssvar.h +++ b/sys/dev/scsipi/ssvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ssvar.h,v 1.8 2001/04/25 17:53:41 bouyer Exp $ */ +/* $NetBSD: ssvar.h,v 1.9 2002/07/22 14:59:45 hannken Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -67,7 +67,7 @@ struct ss_softc { #define SSF_AUTOCONF 0x04 /* set during auto-configuration */ struct scsipi_periph *sc_periph; /* contains our targ, lun, etc. */ struct scan_io sio; - struct buf_queue buf_queue; /* the queue of pending IO operations */ + struct bufq_state buf_queue; /* the queue of pending IO operations */ u_int quirks; /* scanner is only mildly twisted */ #define SS_Q_GET_BUFFER_SIZE 0x0001 /* poll for available data in ssread() */ /* truncate to byte boundry is assumed by default unless one of these is set */ diff --git a/sys/dev/scsipi/st.c b/sys/dev/scsipi/st.c index f0f0c28a3d37..c239fd72ad83 100644 --- a/sys/dev/scsipi/st.c +++ b/sys/dev/scsipi/st.c @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.155 2002/05/05 15:16:31 bouyer Exp $ */ +/* $NetBSD: st.c,v 1.156 2002/07/22 14:59:45 hannken Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.155 2002/05/05 15:16:31 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.156 2002/07/22 14:59:45 hannken Exp $"); #include "opt_scsi.h" @@ -350,6 +350,11 @@ stattach(parent, st, aux) st->flags = ST_INIT_FLAGS; + /* + * Set up the buf queue for this device + */ + bufq_alloc(&st->buf_queue, BUFQ_FCFS); + /* * Check if the drive is a known criminal and take * Any steps needed to bring it into line @@ -375,11 +380,6 @@ stattach(parent, st, aux) (st->flags & ST_READONLY) ? "protected" : "enabled"); } - /* - * Set up the buf queue for this device - */ - BUFQ_INIT(&st->buf_queue); - #if NRND > 0 rnd_attach_source(&st->rnd_source, st->sc_dev.dv_xname, RND_TYPE_TAPE, 0); @@ -427,14 +427,15 @@ stdetach(self, flags) s = splbio(); /* Kill off any queued buffers. */ - while ((bp = BUFQ_FIRST(&st->buf_queue)) != NULL) { - BUFQ_REMOVE(&st->buf_queue, bp); + while ((bp = BUFQ_GET(&st->buf_queue)) != NULL) { bp->b_error = EIO; bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; biodone(bp); } + bufq_free(&st->buf_queue); + /* Kill off any pending commands. */ scsipi_kill_pending(st->sc_periph); @@ -1117,7 +1118,7 @@ ststrategy(bp) * at the end (a bit silly because we only have on user.. * (but it could fork())) */ - BUFQ_INSERT_TAIL(&st->buf_queue, bp); + BUFQ_PUT(&st->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -1175,9 +1176,8 @@ ststart(periph) return; } - if ((bp = BUFQ_FIRST(&st->buf_queue)) == NULL) + if ((bp = BUFQ_GET(&st->buf_queue)) == NULL) return; - BUFQ_REMOVE(&st->buf_queue, bp); /* * If the device has been unmounted by the user diff --git a/sys/dev/scsipi/stvar.h b/sys/dev/scsipi/stvar.h index d79cb99fa7d8..d73f87d506d8 100644 --- a/sys/dev/scsipi/stvar.h +++ b/sys/dev/scsipi/stvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: stvar.h,v 1.5 2002/03/20 14:54:00 christos Exp $ */ +/* $NetBSD: stvar.h,v 1.6 2002/07/22 14:59:45 hannken Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -146,7 +146,7 @@ struct st_softc { * additional sense data needed * for mode sense/select. */ - struct buf_queue buf_queue; /* the queue of pending IO */ + struct bufq_state buf_queue; /* the queue of pending IO */ /* operations */ #if NRND > 0 rndsource_element_t rnd_source;