diff options
| author | thorpej <thorpej@NetBSD.org> | 2000-01-21 23:39:55 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2000-01-21 23:39:55 +0000 |
| commit | dc59bc1db30221dc062e86bb7873bad0b45ca133 (patch) | |
| tree | e3095a5ffd141a53bbafa4a4333cec5e0d9565ed /sys/dev | |
| parent | 52242fdf9fd92890ab284190ffbe195798ae887d (diff) | |
Update for sys/buf.h/disksort_*() changes.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ata/wd.c | 21 | ||||
| -rw-r--r-- | sys/dev/ic/rrunner.c | 23 | ||||
| -rw-r--r-- | sys/dev/ic/rrunnervar.h | 5 | ||||
| -rw-r--r-- | sys/dev/isa/mcd.c | 22 | ||||
| -rw-r--r-- | sys/dev/md.c | 17 | ||||
| -rw-r--r-- | sys/dev/mscp/mscp_disk.c | 4 | ||||
| -rw-r--r-- | sys/dev/mscp/mscp_subr.c | 19 | ||||
| -rw-r--r-- | sys/dev/mscp/mscpvar.h | 4 | ||||
| -rw-r--r-- | sys/dev/pci/if_esh_pci.c | 3 | ||||
| -rw-r--r-- | sys/dev/qbus/uda.c | 20 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_netbsdkintf.c | 31 | ||||
| -rw-r--r-- | sys/dev/scsipi/cd.c | 16 | ||||
| -rw-r--r-- | sys/dev/scsipi/cdvar.h | 4 | ||||
| -rw-r--r-- | sys/dev/scsipi/sd.c | 16 | ||||
| -rw-r--r-- | sys/dev/scsipi/sdvar.h | 4 | ||||
| -rw-r--r-- | sys/dev/scsipi/ss.c | 24 | ||||
| -rw-r--r-- | sys/dev/scsipi/ssvar.h | 4 | ||||
| -rw-r--r-- | sys/dev/scsipi/st.c | 26 | ||||
| -rw-r--r-- | sys/dev/vnd.c | 28 | ||||
| -rw-r--r-- | sys/dev/vndvar.h | 5 |
20 files changed, 113 insertions, 183 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index f8860bafc37..d2054812e3c 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.199 1999/12/23 21:23:19 leo Exp $ */ +/* $NetBSD: wd.c,v 1.200 2000/01/21 23:39:57 thorpej Exp $ */ /* * Copyright (c) 1998 Manuel Bouyer. All rights reserved. @@ -133,7 +133,7 @@ struct wd_softc { /* General disk infos */ struct device sc_dev; struct disk sc_dk; - struct buf sc_q; + struct buf_queue sc_q; /* IDE disk soft states */ struct ata_bio sc_wdc_bio; /* current transfer */ struct buf *sc_bp; /* buf being transfered */ @@ -261,6 +261,8 @@ wdattach(parent, self, aux) char buf[41], c, *p, *q; WDCDEBUG_PRINT(("wdattach\n"), DEBUG_FUNCS | DEBUG_PROBE); + BUFQ_INIT(&wd->sc_q); + wd->openings = aa_link->aa_openings; wd->drvp = aa_link->aa_drv_data;; wd->wdc_softc = parent; @@ -400,8 +402,8 @@ wddetach(self, flags) s = splbio(); /* Kill off any queued buffers. */ - while ((bp = sc->sc_q.b_actf) != NULL) { - sc->sc_q.b_actf = bp->b_actf; + while ((bp = BUFQ_FIRST(&sc->sc_q)) != NULL) { + BUFQ_REMOVE(&sc->sc_q, bp); bp->b_error = EIO; bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; @@ -471,7 +473,7 @@ wdstrategy(bp) goto done; /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); - disksort(&wd->sc_q, bp); + disksort_blkno(&wd->sc_q, bp); wdstart(wd); splx(s); return; @@ -491,17 +493,16 @@ wdstart(arg) void *arg; { struct wd_softc *wd = arg; - struct buf *dp, *bp=0; + struct buf *bp = NULL; WDCDEBUG_PRINT(("wdstart %s\n", wd->sc_dev.dv_xname), DEBUG_XFERS); while (wd->openings > 0) { /* Is there a buf for us ? */ - dp = &wd->sc_q; - if ((bp = dp->b_actf) == NULL) /* yes, an assign */ - return; - dp->b_actf = bp->b_actf; + if ((bp = BUFQ_FIRST(&wd->sc_q)) == NULL) + return; + BUFQ_REMOVE(&wd->sc_q, bp); /* * Make the command. First lock the device diff --git a/sys/dev/ic/rrunner.c b/sys/dev/ic/rrunner.c index 8b8f7238c0b..176e0efc9d9 100644 --- a/sys/dev/ic/rrunner.c +++ b/sys/dev/ic/rrunner.c @@ -1,4 +1,4 @@ -/* $NetBSD: rrunner.c,v 1.13 1999/06/20 16:44:49 thorpej Exp $ */ +/* $NetBSD: rrunner.c,v 1.14 2000/01/21 23:39:58 thorpej Exp $ */ /* * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -300,6 +300,7 @@ eshconfig(sc) sc->sc_send.ec_offset = 0; sc->sc_send.ec_descr = sc->sc_send_ring; TAILQ_INIT(&sc->sc_send.ec_di_queue); + BUFQ_INIT(&sc->sc_send.ec_buf_queue); for (i = 0; i < RR_MAX_SNAP_RECV_RING_SIZE; i++) if (bus_dmamap_create(sc->sc_dmat, RR_DMA_MAX, 1, RR_DMA_MAX, @@ -1428,16 +1429,7 @@ esh_fpstrategy(bp) */ struct esh_send_ring_ctl *ring = &sc->sc_send; - - if (ring->ec_queue != NULL) { - assert(ring->ec_lastqueue); - - ring->ec_lastqueue->b_actf = bp; - } else { - ring->ec_queue = bp; - } - ring->ec_lastqueue = bp; - bp->b_actf = NULL; + BUFQ_INSERT_TAIL(&ring->ec_buf_queue, bp); #ifdef ESH_PRINTF printf("esh_fpstrategy: ready to call eshstart to write!\n"); #endif @@ -2080,7 +2072,8 @@ eshstart(ifp) if ((sc->sc_flags & ESH_FL_FP_RING_UP) != 0 && send->ec_cur_mbuf == NULL && send->ec_cur_buf == NULL && - send->ec_cur_dmainfo == NULL && send->ec_queue != NULL) { + send->ec_cur_dmainfo == NULL && + BUFQ_FIRST(&send->ec_buf_queue) != NULL) { struct buf *bp; #ifdef ESH_PRINTF @@ -2088,10 +2081,8 @@ eshstart(ifp) send->ec_queue); #endif - bp = send->ec_cur_buf = send->ec_queue; - send->ec_queue = send->ec_queue->b_actf; - if (send->ec_queue == NULL) - send->ec_lastqueue = NULL; + bp = send->ec_cur_buf = BUFQ_FIRST(&send->ec_buf_queue); + BUFQ_REMOVE(&send->ec_buf_queue, bp); send->ec_offset = 0; send->ec_len = bp->b_bcount; diff --git a/sys/dev/ic/rrunnervar.h b/sys/dev/ic/rrunnervar.h index 7bbf0e4226d..27232ab04d1 100644 --- a/sys/dev/ic/rrunnervar.h +++ b/sys/dev/ic/rrunnervar.h @@ -1,4 +1,4 @@ -/* $NetBSD: rrunnervar.h,v 1.5 1998/11/20 04:12:58 kml Exp $ */ +/* $NetBSD: rrunnervar.h,v 1.6 2000/01/21 23:39:58 thorpej Exp $ */ /* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -114,8 +114,7 @@ struct esh_send_ring_ctl { struct buf *ec_cur_buf; /* current buf being processed */ struct esh_dmainfo *ec_cur_dmainfo; /* current dmainfo being processed */ - struct buf *ec_queue; /* queue of bufs to send */ - struct buf *ec_lastqueue; /* last entry in the queue */ + struct buf_queue ec_buf_queue; /* queue of bufs to send */ int ec_error; /* encountered error? */ u_int16_t ec_producer; /* latest buffer driver produced */ u_int16_t ec_consumer; /* latest buffer runcode consumed */ diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c index e946cbfbb0a..448156ab8b9 100644 --- a/sys/dev/isa/mcd.c +++ b/sys/dev/isa/mcd.c @@ -1,4 +1,4 @@ -/* $NetBSD: mcd.c,v 1.63 1999/02/08 16:33:17 bouyer Exp $ */ +/* $NetBSD: mcd.c,v 1.64 2000/01/21 23:39:58 thorpej Exp $ */ /* * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved. @@ -144,7 +144,8 @@ struct mcd_softc { #define MCD_MD_UNKNOWN -1 int lastupc; #define MCD_UPC_UNKNOWN -1 - struct buf buf_queue; + struct buf_queue buf_queue; + int active; u_char readcmd; u_char debug; u_char probe; @@ -245,6 +246,8 @@ mcdattach(parent, self, aux) return; } + BUFQ_INIT(&sc->buf_queue); + /* * Initialize and attach the disk structure. */ @@ -489,9 +492,9 @@ mcdstrategy(bp) /* Queue it. */ s = splbio(); - disksort(&sc->buf_queue, bp); + disksort_blkno(&sc->buf_queue, bp); splx(s); - if (!sc->buf_queue.b_active) + if (!sc->active) mcdstart(sc); return; @@ -506,23 +509,22 @@ void mcdstart(sc) struct mcd_softc *sc; { - struct buf *bp, *dp = &sc->buf_queue; + struct buf *bp; int s; loop: s = splbio(); - bp = dp->b_actf; - if (bp == NULL) { + if ((bp = BUFQ_FIRST(&sc->buf_queue)) == NULL) { /* Nothing to do. */ - dp->b_active = 0; + sc->active = 0; splx(s); return; } /* Block found to process; dequeue. */ MCD_TRACE("start: found block bp=0x%x\n", bp, 0, 0, 0); - dp->b_actf = bp->b_actf; + BUFQ_REMOVE(&sc->buf_queue, bp); splx(s); /* Changed media? */ @@ -534,7 +536,7 @@ loop: goto loop; } - dp->b_active = 1; + sc->active = 1; /* Instrumentation. */ s = splbio(); diff --git a/sys/dev/md.c b/sys/dev/md.c index f5f0a05a2e3..b928d8049f3 100644 --- a/sys/dev/md.c +++ b/sys/dev/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.21 2000/01/21 12:14:53 tsutsui Exp $ */ +/* $NetBSD: md.c,v 1.22 2000/01/21 23:39:57 thorpej Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -84,7 +84,7 @@ struct md_softc { struct device sc_dev; /* REQUIRED first entry */ struct disk sc_dkdev; /* hook for generic disk handling */ struct md_conf sc_md; - struct buf *sc_buflist; + struct buf_queue sc_buflist; }; /* shorthand for fields in sc_md: */ #define sc_addr sc_md.md_addr @@ -147,6 +147,8 @@ md_attach(parent, self, aux) { struct md_softc *sc = (struct md_softc *)self; + BUFQ_INIT(&sc->sc_buflist); + /* XXX - Could accept aux info here to set the config. */ #ifdef MEMORY_DISK_HOOKS /* @@ -339,9 +341,8 @@ mdstrategy(bp) #if MEMORY_DISK_SERVER case MD_UMEM_SERVER: /* Just add this job to the server's queue. */ - bp->b_actf = sc->sc_buflist; - sc->sc_buflist = bp; - if (bp->b_actf == NULL) { + BUFQ_INSERT_TAIL(&sc->sc_buflist, bp); + if (BUFQ_FIRST(&sc->sc_buflist) == bp) { /* server queue was empty. */ wakeup((caddr_t)sc); /* see md_server_loop() */ @@ -504,16 +505,14 @@ md_server_loop(sc) for (;;) { /* Wait for some work to arrive. */ - while (sc->sc_buflist == NULL) { + while ((bp = BUFQ_FIRST(&sc->sc_buflist)) == NULL) { error = tsleep((caddr_t)sc, md_sleep_pri, "md_idle", 0); if (error) return error; } /* Unlink buf from head of list. */ - bp = sc->sc_buflist; - sc->sc_buflist = bp->b_actf; - bp->b_actf = NULL; + BUFQ_REMOVE(&sc->sc_buflist, bp); /* Do the transfer to/from user space. */ error = 0; diff --git a/sys/dev/mscp/mscp_disk.c b/sys/dev/mscp/mscp_disk.c index 875633a3489..d063c57fa6c 100644 --- a/sys/dev/mscp/mscp_disk.c +++ b/sys/dev/mscp/mscp_disk.c @@ -1,4 +1,4 @@ -/* $NetBSD: mscp_disk.c,v 1.21 1999/06/06 19:16:18 ragge Exp $ */ +/* $NetBSD: mscp_disk.c,v 1.22 2000/01/21 23:39:59 thorpej Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -288,7 +288,7 @@ raclose(dev, flags, fmt, p) #if notyet if (ra->ra_openpart == 0) { s = splimp(); - while (udautab[unit].b_actf) + while (BUFQ_FIRST(&udautab[unit]) != NULL) sleep((caddr_t)&udautab[unit], PZERO - 1); splx(s); ra->ra_state = CLOSED; diff --git a/sys/dev/mscp/mscp_subr.c b/sys/dev/mscp/mscp_subr.c index b1734897085..7cd8e1d4615 100644 --- a/sys/dev/mscp/mscp_subr.c +++ b/sys/dev/mscp/mscp_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: mscp_subr.c,v 1.12 1999/06/06 19:16:18 ragge Exp $ */ +/* $NetBSD: mscp_subr.c,v 1.13 2000/01/21 23:39:59 thorpej Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -160,7 +160,7 @@ mscp_attach(parent, self, aux) mi->mi_rsp.mri_size = NRSP; mi->mi_rsp.mri_desc = mi->mi_uda->mp_ca.ca_rspdsc; mi->mi_rsp.mri_ring = mi->mi_uda->mp_rsp; - SIMPLEQ_INIT(&mi->mi_resq); + BUFQ_INIT(&mi->mi_resq); if (mscp_init(mi)) { printf("%s: can't init, controller hung\n", @@ -451,7 +451,7 @@ mscp_intr(mi) /* * If there are any not-yet-handled request, try them now. */ - if (SIMPLEQ_FIRST(&mi->mi_resq)) + if (BUFQ_FIRST(&mi->mi_resq)) mscp_kickaway(mi); } @@ -485,10 +485,7 @@ mscp_strategy(bp, usc) struct mscp_softc *mi = (void *)usc; int s = splimp(); -/* SIMPLEQ_INSERT_TAIL(&mi->mi_resq, bp, xxx) */ - bp->b_actf = NULL; - *mi->mi_resq.sqh_last = bp; - mi->mi_resq.sqh_last = &bp->b_actf; + BUFQ_INSERT_TAIL(&mi->mi_resq, bp); mscp_kickaway(mi); splx(s); } @@ -502,7 +499,7 @@ mscp_kickaway(mi) struct mscp *mp; int next; - while ((bp = SIMPLEQ_FIRST(&mi->mi_resq))) { + while ((bp = BUFQ_FIRST(&mi->mi_resq)) != NULL) { /* * Ok; we are ready to try to start a xfer. Get a MSCP packet * and try to start... @@ -535,11 +532,7 @@ mscp_kickaway(mi) bp->b_resid = next; (*mi->mi_me->me_fillin)(bp, mp); (*mi->mi_mc->mc_go)(mi->mi_dev.dv_parent, &mi->mi_xi[next]); - if ((mi->mi_resq.sqh_first = bp->b_actf) == NULL) - mi->mi_resq.sqh_last = &mi->mi_resq.sqh_first; -#if 0 - mi->mi_w = bp->b_actf; -#endif + BUFQ_REMOVE(&mi->mi_resq, bp); } } diff --git a/sys/dev/mscp/mscpvar.h b/sys/dev/mscp/mscpvar.h index 1ec0de046c0..e3c1e08ee76 100644 --- a/sys/dev/mscp/mscpvar.h +++ b/sys/dev/mscp/mscpvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: mscpvar.h,v 1.7 1999/06/06 19:16:18 ragge Exp $ */ +/* $NetBSD: mscpvar.h,v 1.8 2000/01/21 23:39:59 thorpej Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -191,7 +191,7 @@ struct mscp_softc { bus_space_handle_t mi_iph; /* initialisation and polling */ bus_space_handle_t mi_sah; /* status & address (read part) */ bus_space_handle_t mi_swh; /* status & address (write part) */ - SIMPLEQ_HEAD(, buf) mi_resq; /* While waiting for packets */ + struct buf_queue mi_resq; /* While waiting for packets */ }; /* mi_flags */ diff --git a/sys/dev/pci/if_esh_pci.c b/sys/dev/pci/if_esh_pci.c index 94f3284f889..befd4f4b867 100644 --- a/sys/dev/pci/if_esh_pci.c +++ b/sys/dev/pci/if_esh_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_esh_pci.c,v 1.5 1998/07/05 06:49:15 jonathan Exp $ */ +/* $NetBSD: if_esh_pci.c,v 1.6 2000/01/21 23:39:59 thorpej Exp $ */ /* * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -54,6 +54,7 @@ #include <sys/syslog.h> #include <sys/select.h> #include <sys/device.h> +#include <sys/buf.h> #include <net/if.h> #include <net/if_dl.h> diff --git a/sys/dev/qbus/uda.c b/sys/dev/qbus/uda.c index a20613870d3..fc9124c8c11 100644 --- a/sys/dev/qbus/uda.c +++ b/sys/dev/qbus/uda.c @@ -1,4 +1,4 @@ -/* $NetBSD: uda.c,v 1.30 1999/06/06 19:14:49 ragge Exp $ */ +/* $NetBSD: uda.c,v 1.31 2000/01/21 23:39:59 thorpej Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -61,26 +61,12 @@ #include "ioconf.h" /* - * Variants of SIMPLEQ macros for use with buf structs. - */ -#define BUFQ_INSERT_TAIL(head, elm) { \ - (elm)->b_actf = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->b_actf; \ -} - -#define BUFQ_REMOVE_HEAD(head, elm) { \ - if (((head)->sqh_first = (elm)->b_actf) == NULL) \ - (head)->sqh_last = &(head)->sqh_first; \ -} - -/* * Software status, per controller. */ struct uda_softc { struct device sc_dev; /* Autoconfig info */ struct uba_unit sc_unit; /* Struct common for UBA to communicate */ - SIMPLEQ_HEAD(, buf) sc_bufq; /* bufs awaiting for resources */ + struct buf_queue sc_bufq; /* bufs awaiting for resources */ struct mscp_pack *sc_uuda; /* Unibus address of uda struct */ struct mscp_pack sc_uda; /* Struct for uda communication */ bus_dma_tag_t sc_dmat; @@ -224,7 +210,7 @@ udaattach(parent, self, aux) sc->sc_sah = ua->ua_ioh + 2; sc->sc_dmat = ua->ua_dmat; ctlr = sc->sc_dev.dv_unit; - SIMPLEQ_INIT(&sc->sc_bufq); + BUFQ_INIT(&sc->sc_bufq); /* * Fill in the uba_unit struct, so we can communicate with the uba. diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 01b856e3634..66fd8f5ea2d 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.46 2000/01/09 03:39:13 oster Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.47 2000/01/21 23:39:59 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -214,7 +214,7 @@ struct raid_softc { char sc_xname[20]; /* XXX external name */ struct disk sc_dkdev; /* generic disk device info */ struct pool sc_cbufpool; /* component buffer pool */ - struct buf buf_queue; /* used for the device queue */ + struct buf_queue buf_queue; /* used for the device queue */ }; /* sc_flags */ #define RAIDF_INITED 0x01 /* unit has been initialized */ @@ -325,9 +325,7 @@ raidattach(num) bzero(raid_softc, num * sizeof(struct raid_softc)); for (raidID = 0; raidID < num; raidID++) { - raid_softc[raidID].buf_queue.b_actf = NULL; - raid_softc[raidID].buf_queue.b_actb = - &raid_softc[raidID].buf_queue.b_actf; + BUFQ_INIT(&raid_softc[raidID].buf_queue); RF_Calloc(raidPtrs[raidID], 1, sizeof(RF_Raid_t), (RF_Raid_t *)); if (raidPtrs[raidID] == NULL) { @@ -522,7 +520,6 @@ raidstrategy(bp) RF_Raid_t *raidPtr; struct raid_softc *rs = &raid_softc[raidID]; struct disklabel *lp; - struct buf *dp; int wlabel; if ((rs->sc_flags & RAIDF_INITED) ==0) { @@ -572,13 +569,8 @@ raidstrategy(bp) bp->b_resid = 0; /* stuff it onto our queue */ + BUFQ_INSERT_TAIL(&rs->buf_queue, bp); - dp = &rs->buf_queue; - bp->b_actf = NULL; - bp->b_actb = dp->b_actb; - *dp->b_actb = bp; - dp->b_actb = &bp->b_actf; - raidstart(raidPtrs[raidID]); splx(s); @@ -1361,7 +1353,6 @@ raidstart(raidPtr) struct raid_softc *rs; int do_async; struct buf *bp; - struct buf *dp; unit = raidPtr->raidid; rs = &raid_softc[unit]; @@ -1372,21 +1363,11 @@ raidstart(raidPtr) RF_UNLOCK_MUTEX(raidPtr->mutex); /* get the next item, if any, from the queue */ - dp = &rs->buf_queue; - bp = dp->b_actf; - if (bp == NULL) { + if ((bp = BUFQ_FIRST(&rs->buf_queue)) == NULL) { /* nothing more to do */ return; } - - /* update structures */ - dp = bp->b_actf; - if (dp != NULL) { - dp->b_actb = bp->b_actb; - } else { - rs->buf_queue.b_actb = bp->b_actb; - } - *bp->b_actb = dp; + BUFQ_REMOVE(&rs->buf_queue, bp); /* Ok, for the bp we have here, bp->b_blkno is relative to the * partition.. Need to make it absolute to the underlying diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c index 395971d7a37..3cc30e24794 100644 --- a/sys/dev/scsipi/cd.c +++ b/sys/dev/scsipi/cd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.134 1999/11/03 20:50:18 matt Exp $ */ +/* $NetBSD: cd.c,v 1.135 2000/01/21 23:40:00 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -159,6 +159,8 @@ cdattach(parent, cd, sc_link, ops) { SC_DEBUG(sc_link, SDEV_DB2, ("cdattach: ")); + BUFQ_INIT(&cd->buf_queue); + /* * Store information needed to contact our base driver */ @@ -229,8 +231,8 @@ cddetach(self, flags) s = splbio(); /* Kill off any queued buffers. */ - while ((bp = cd->buf_queue.b_actf) != NULL) { - cd->buf_queue.b_actf = bp->b_actf; + while ((bp = BUFQ_FIRST(&cd->buf_queue)) != NULL) { + BUFQ_REMOVE(&cd->buf_queue, bp); bp->b_error = EIO; bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; @@ -544,7 +546,7 @@ cdstrategy(bp) /* * Place it in the queue of disk activities for this disk */ - disksort(&cd->buf_queue, bp); + disksort_blkno(&cd->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -589,7 +591,6 @@ cdstart(v) register struct scsipi_link *sc_link = cd->sc_link; struct disklabel *lp = cd->sc_dk.dk_label; struct buf *bp = 0; - struct buf *dp; struct scsipi_rw_big cmd_big; #if NCD_SCSIBUS > 0 struct scsi_rw cmd_small; @@ -617,10 +618,9 @@ cdstart(v) /* * See if there is a buf with work for us to do.. */ - dp = &cd->buf_queue; - if ((bp = dp->b_actf) == NULL) /* yes, an assign */ + if ((bp = BUFQ_FIRST(&cd->buf_queue)) == NULL) return; - dp->b_actf = bp->b_actf; + BUFQ_REMOVE(&cd->buf_queue, bp); /* * If the device has become invalid, abort all the diff --git a/sys/dev/scsipi/cdvar.h b/sys/dev/scsipi/cdvar.h index d0c13430432..f8ce0cfdc7d 100644 --- a/sys/dev/scsipi/cdvar.h +++ b/sys/dev/scsipi/cdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdvar.h,v 1.11 1999/09/23 11:04:34 enami Exp $ */ +/* $NetBSD: cdvar.h,v 1.12 2000/01/21 23:40:00 thorpej Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. All rights reserved. @@ -48,7 +48,7 @@ struct cd_softc { int blksize; u_long disksize; /* total number sectors */ } params; - struct buf buf_queue; + struct buf_queue 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/sd.c b/sys/dev/scsipi/sd.c index 13712faf18a..ad4d78af701 100644 --- a/sys/dev/scsipi/sd.c +++ b/sys/dev/scsipi/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.154 1999/12/23 21:23:30 leo Exp $ */ +/* $NetBSD: sd.c,v 1.155 2000/01/21 23:40:00 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -137,6 +137,8 @@ sdattach(parent, sd, sc_link, ops) SC_DEBUG(sc_link, SDEV_DB2, ("sdattach: ")); + BUFQ_INIT(&sd->buf_queue); + /* * Store information needed to contact our base driver */ @@ -264,8 +266,8 @@ sddetach(self, flags) s = splbio(); /* Kill off any queued buffers. */ - while ((bp = sd->buf_queue.b_actf) != NULL) { - sd->buf_queue.b_actf = bp->b_actf; + while ((bp = BUFQ_FIRST(&sd->buf_queue)) != NULL) { + BUFQ_REMOVE(&sd->buf_queue, bp); bp->b_error = EIO; bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; @@ -597,7 +599,7 @@ sdstrategy(bp) /* * Place it in the queue of disk activities for this disk */ - disksort(&sd->buf_queue, bp); + disksort_blkno(&sd->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -642,7 +644,6 @@ sdstart(v) register struct scsipi_link *sc_link = sd->sc_link; struct disklabel *lp = sd->sc_dk.dk_label; struct buf *bp = 0; - struct buf *dp; struct scsipi_rw_big cmd_big; #if NSD_SCSIBUS > 0 struct scsi_rw cmd_small; @@ -670,10 +671,9 @@ sdstart(v) /* * See if there is a buf with work for us to do.. */ - dp = &sd->buf_queue; - if ((bp = dp->b_actf) == NULL) /* yes, an assign */ + if ((bp = BUFQ_FIRST(&sd->buf_queue)) == NULL) return; - dp->b_actf = bp->b_actf; + BUFQ_REMOVE(&sd->buf_queue, bp); /* * If the device has become invalid, abort all the diff --git a/sys/dev/scsipi/sdvar.h b/sys/dev/scsipi/sdvar.h index 731bc0d0f57..efe56acd35d 100644 --- a/sys/dev/scsipi/sdvar.h +++ b/sys/dev/scsipi/sdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sdvar.h,v 1.9 1999/09/11 21:42:58 thorpej Exp $ */ +/* $NetBSD: sdvar.h,v 1.10 2000/01/21 23:40:00 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ struct sd_softc { u_long disksize; /* total number sectors */ u_long rot_rate; /* rotational rate, in RPM */ } params; - struct buf buf_queue; + struct buf_queue buf_queue; u_int8_t type; char name[16]; /* product name, for default disklabel */ const struct sd_ops *sc_ops; /* our bus-dependent ops vector */ diff --git a/sys/dev/scsipi/ss.c b/sys/dev/scsipi/ss.c index 59328d9c8f4..8f497b6579e 100644 --- a/sys/dev/scsipi/ss.c +++ b/sys/dev/scsipi/ss.c @@ -1,4 +1,4 @@ -/* $NetBSD: ss.c,v 1.28 2000/01/19 01:00:07 abs Exp $ */ +/* $NetBSD: ss.c,v 1.29 2000/01/21 23:40:00 thorpej Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -159,9 +159,7 @@ ssattach(parent, self, aux) /* * Set up the buf queue for this device */ - ss->buf_queue.b_active = 0; - ss->buf_queue.b_actf = 0; - ss->buf_queue.b_actb = &ss->buf_queue.b_actf; + BUFQ_INIT(&ss->buf_queue); ss->flags &= ~SSF_AUTOCONF; } @@ -332,7 +330,6 @@ ssstrategy(bp) struct buf *bp; { struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)]; - struct buf *dp; int s; SC_DEBUG(ss->sc_link, SDEV_DB1, @@ -361,11 +358,7 @@ ssstrategy(bp) * at the end (a bit silly because we only have on user.. * (but it could fork())) */ - dp = &ss->buf_queue; - bp->b_actf = NULL; - bp->b_actb = dp->b_actb; - *dp->b_actb = bp; - dp->b_actb = &bp->b_actf; + BUFQ_INSERT_TAIL(&ss->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -405,7 +398,7 @@ ssstart(v) { struct ss_softc *ss = v; struct scsipi_link *sc_link = ss->sc_link; - register struct buf *bp, *dp; + register struct buf *bp; SC_DEBUG(sc_link, SDEV_DB2, ("ssstart ")); /* @@ -423,14 +416,9 @@ ssstart(v) /* * See if there is a buf with work for us to do.. */ - dp = &ss->buf_queue; - if ((bp = dp->b_actf) == NULL) + if ((bp = BUFQ_FIRST(&ss->buf_queue)) == NULL) return; - if ((dp = bp->b_actf) != NULL) - dp->b_actb = bp->b_actb; - else - ss->buf_queue.b_actb = bp->b_actb; - *bp->b_actb = dp; + 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 f4f4783dd58..6e0ad0d0a8c 100644 --- a/sys/dev/scsipi/ssvar.h +++ b/sys/dev/scsipi/ssvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ssvar.h,v 1.6 1998/04/22 19:44:19 pk Exp $ */ +/* $NetBSD: ssvar.h,v 1.7 2000/01/21 23:40:00 thorpej 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_link *sc_link; /* contains our targ, lun, etc. */ struct scan_io sio; - struct buf buf_queue; /* the queue of pending IO operations */ + struct buf_queue 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 2c730f704c0..6850044ca5b 100644 --- a/sys/dev/scsipi/st.c +++ b/sys/dev/scsipi/st.c @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.116 2000/01/13 00:18:27 nisimura Exp $ */ +/* $NetBSD: st.c,v 1.117 2000/01/21 23:40:00 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -335,7 +335,7 @@ struct st_softc { * additional sense data needed * for mode sense/select. */ - struct buf buf_queue; /* the queue of pending IO */ + struct buf_queue buf_queue; /* the queue of pending IO */ /* operations */ #if NRND > 0 rndsource_element_t rnd_source; @@ -493,9 +493,7 @@ stattach(parent, self, aux) /* * Set up the buf queue for this device */ - st->buf_queue.b_active = 0; - st->buf_queue.b_actf = 0; - st->buf_queue.b_actb = &st->buf_queue.b_actf; + BUFQ_INIT(&st->buf_queue); #if NRND > 0 rnd_attach_source(&st->rnd_source, st->sc_dev.dv_xname, @@ -1076,7 +1074,6 @@ ststrategy(bp) struct buf *bp; { struct st_softc *st = st_cd.cd_devs[STUNIT(bp->b_dev)]; - struct buf *dp; int s; SC_DEBUG(st->sc_link, SDEV_DB1, @@ -1121,11 +1118,7 @@ ststrategy(bp) * at the end (a bit silly because we only have on user.. * (but it could fork())) */ - dp = &st->buf_queue; - bp->b_actf = NULL; - bp->b_actb = dp->b_actb; - *dp->b_actb = bp; - dp->b_actb = &bp->b_actf; + BUFQ_INSERT_TAIL(&st->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -1167,7 +1160,7 @@ ststart(v) { struct st_softc *st = v; struct scsipi_link *sc_link = st->sc_link; - register struct buf *bp, *dp; + register struct buf *bp; struct scsi_rw_tape cmd; int flags, error; @@ -1184,14 +1177,9 @@ ststart(v) return; } - dp = &st->buf_queue; - if ((bp = dp->b_actf) == NULL) + if ((bp = BUFQ_FIRST(&st->buf_queue)) == NULL) return; - if ((dp = bp->b_actf) != NULL) - dp->b_actb = bp->b_actb; - else - st->buf_queue.b_actb = bp->b_actb; - *bp->b_actb = dp; + BUFQ_REMOVE(&st->buf_queue, bp); /* * if the device has been unmounted bye the user diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index cc705e3fe75..d36bb199e77 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.62 1999/11/17 09:34:03 fvdl Exp $ */ +/* $NetBSD: vnd.c,v 1.63 2000/01/21 23:39:57 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -134,8 +134,6 @@ int dovndcluster = 1; int vnddebug = 0x00; #endif -#define b_cylin b_resid - #define vndunit(x) DISKUNIT(x) struct vndxfer { @@ -183,20 +181,23 @@ void vndattach(num) int num; { + int i; char *mem; - register u_long size; if (num <= 0) return; - size = num * sizeof(struct vnd_softc); - mem = malloc(size, M_DEVBUF, M_NOWAIT); + i = num * sizeof(struct vnd_softc); + mem = malloc(i, M_DEVBUF, M_NOWAIT); if (mem == NULL) { printf("WARNING: no memory for vnode disks\n"); return; } - bzero(mem, size); + bzero(mem, i); vnd_softc = (struct vnd_softc *)mem; numvnd = num; + + for (i = 0; i < numvnd; i++) + BUFQ_INIT(&vnd_softc[i].sc_tab); } int @@ -472,7 +473,6 @@ vndstrategy(bp) /* * Just sort by block number */ - nbp->vb_buf.b_cylin = nbp->vb_buf.b_blkno; s = splbio(); if (vnx->vx_error != 0) { VND_PUTBUF(vnd, nbp); @@ -480,7 +480,7 @@ vndstrategy(bp) } vnx->vx_pending++; bgetvp(vp, &nbp->vb_buf); - disksort(&vnd->sc_tab, &nbp->vb_buf); + disksort_blkno(&vnd->sc_tab, &nbp->vb_buf); vndstart(vnd); splx(s); bn += sz; @@ -528,12 +528,12 @@ vndstart(vnd) vnd->sc_flags |= VNF_BUSY; - while (vnd->sc_tab.b_active < vnd->sc_maxactive) { - bp = vnd->sc_tab.b_actf; + while (vnd->sc_active < vnd->sc_maxactive) { + bp = BUFQ_FIRST(&vnd->sc_tab); if (bp == NULL) break; - vnd->sc_tab.b_actf = bp->b_actf; - vnd->sc_tab.b_active++; + BUFQ_REMOVE(&vnd->sc_tab, bp); + vnd->sc_active++; #ifdef DEBUG if (vnddebug & VDB_IO) printf("vndstart(%ld): bp %p vp %p blkno 0x%x addr %p cnt 0x%lx\n", @@ -623,7 +623,7 @@ vndiodone(bp) } } - vnd->sc_tab.b_active--; + vnd->sc_active--; vndstart(vnd); splx(s); } diff --git a/sys/dev/vndvar.h b/sys/dev/vndvar.h index dca02475f0f..cf7c024b46f 100644 --- a/sys/dev/vndvar.h +++ b/sys/dev/vndvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: vndvar.h,v 1.4 1998/07/31 02:24:26 thorpej Exp $ */ +/* $NetBSD: vndvar.h,v 1.5 2000/01/21 23:39:57 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -116,7 +116,8 @@ struct vnd_softc { struct vnode *sc_vp; /* vnode */ struct ucred *sc_cred; /* credentials */ int sc_maxactive; /* max # of active requests */ - struct buf sc_tab; /* transfer queue */ + struct buf_queue sc_tab; /* transfer queue */ + int sc_active; /* number of active transfers */ char sc_xname[8]; /* XXX external name */ struct disk sc_dkdev; /* generic disk device info */ struct vndgeom sc_geom; /* virtual geometry */ |
