diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2013-03-04 00:41:55 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2013-03-04 00:41:55 +0000 |
commit | 29a80cd705d8115ee7184b10f9bf9ad0517db5f7 (patch) | |
tree | 13e7dc96b48b17b488e0f0781113be5c3ee1f3d7 /sys | |
parent | b35e4e9d51085c1fb612c880cd22af8297c31392 (diff) |
replace the LIST_ENTRY in scsi_xfer with a SIMPLEQ_ENTRY. the things that
use it want something they can add to the end of they do horrible things
to be able to do that with the LIST_ENTRY.
this makes those horrible things a bit less horrible, and makes it easier
to use lists of scsi_xfers in other things.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/gdt_common.c | 32 | ||||
-rw-r--r-- | sys/dev/ic/gdtvar.h | 5 | ||||
-rw-r--r-- | sys/dev/ic/isp_openbsd.c | 74 | ||||
-rw-r--r-- | sys/dev/ic/isp_openbsd.h | 4 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 5 |
5 files changed, 47 insertions, 73 deletions
diff --git a/sys/dev/ic/gdt_common.c b/sys/dev/ic/gdt_common.c index e1bf90095bd..86b86b2bd9f 100644 --- a/sys/dev/ic/gdt_common.c +++ b/sys/dev/ic/gdt_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt_common.c,v 1.61 2012/08/15 02:38:14 jsg Exp $ */ +/* $OpenBSD: gdt_common.c,v 1.62 2013/03/04 00:41:54 dlg Exp $ */ /* * Copyright (c) 1999, 2000, 2003 Niklas Hallqvist. All rights reserved. @@ -129,7 +129,7 @@ gdt_attach(struct gdt_softc *sc) TAILQ_INIT(&sc->sc_free_ccb); TAILQ_INIT(&sc->sc_ccbq); TAILQ_INIT(&sc->sc_ucmdq); - LIST_INIT(&sc->sc_queue); + SIMPLEQ_INIT(&sc->sc_queue); mtx_init(&sc->sc_ccb_mtx, IPL_BIO); scsi_iopool_init(&sc->sc_iopool, sc, gdt_ccb_alloc, gdt_ccb_free); @@ -517,14 +517,10 @@ gdt_eval_mapping(u_int32_t size, int *cyls, int *heads, int *secs) void gdt_enqueue(struct gdt_softc *sc, struct scsi_xfer *xs, int infront) { - if (infront || LIST_FIRST(&sc->sc_queue) == NULL) { - if (LIST_FIRST(&sc->sc_queue) == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; + if (infront) + SIMPLEQ_INSERT_HEAD(&sc->sc_queue, xs, xfer_list); + else + SIMPLEQ_INSERT_TAIL(&sc->sc_queue, xs, xfer_list); } /* @@ -535,13 +531,9 @@ gdt_dequeue(struct gdt_softc *sc) { struct scsi_xfer *xs; - xs = LIST_FIRST(&sc->sc_queue); - if (xs == NULL) - return (NULL); - LIST_REMOVE(xs, free_list); - - if (LIST_FIRST(&sc->sc_queue) == NULL) - sc->sc_queuelast = NULL; + xs = SIMPLEQ_FIRST(&sc->sc_queue); + if (xs != NULL) + SIMPLEQ_REMOVE_HEAD(&sc->sc_queue, xfer_list); return (xs); } @@ -584,7 +576,7 @@ gdt_scsi_cmd(struct scsi_xfer *xs) } /* Don't double enqueue if we came from gdt_chain. */ - if (xs != LIST_FIRST(&sc->sc_queue)) + if (xs != SIMPLEQ_FIRST(&sc->sc_queue)) gdt_enqueue(sc, xs, 0); while ((xs = gdt_dequeue(sc)) != NULL) { @@ -1307,8 +1299,8 @@ gdt_chain(struct gdt_softc *sc) { GDT_DPRINTF(GDT_D_INTR, ("gdt_chain(%p) ", sc)); - if (LIST_FIRST(&sc->sc_queue)) - gdt_scsi_cmd(LIST_FIRST(&sc->sc_queue)); + if (!SIMPLEQ_EMPTY(&sc->sc_queue)) + gdt_scsi_cmd(SIMPLEQ_FIRST(&sc->sc_queue)); } void diff --git a/sys/dev/ic/gdtvar.h b/sys/dev/ic/gdtvar.h index add7ee19dbf..ba50513e2c8 100644 --- a/sys/dev/ic/gdtvar.h +++ b/sys/dev/ic/gdtvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gdtvar.h,v 1.21 2012/08/15 02:38:14 jsg Exp $ */ +/* $OpenBSD: gdtvar.h,v 1.22 2013/03/04 00:41:54 dlg Exp $ */ /* * Copyright (c) 1999, 2000 Niklas Hallqvist. All rights reserved. @@ -131,8 +131,7 @@ struct gdt_softc { struct gdt_ccb sc_ccbs[GDT_MAXCMDS]; TAILQ_HEAD(, gdt_ccb) sc_free_ccb, sc_ccbq; TAILQ_HEAD(, gdt_ucmd) sc_ucmdq; - LIST_HEAD(, scsi_xfer) sc_queue; - struct scsi_xfer *sc_queuelast; + struct scsi_xfer_list sc_queue; struct mutex sc_ccb_mtx; struct scsi_iopool sc_iopool; diff --git a/sys/dev/ic/isp_openbsd.c b/sys/dev/ic/isp_openbsd.c index 089d12bf9b4..b2b3c802462 100644 --- a/sys/dev/ic/isp_openbsd.c +++ b/sys/dev/ic/isp_openbsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isp_openbsd.c,v 1.47 2011/10/22 19:34:06 miod Exp $ */ +/* $OpenBSD: isp_openbsd.c,v 1.48 2013/03/04 00:41:54 dlg Exp $ */ /* * Platform (OpenBSD) dependent common attachment code for QLogic adapters. * @@ -103,7 +103,7 @@ isp_attach(struct ispsoftc *isp) * We only manage a single wait queues for dual bus controllers. * This is arguably broken. */ - isp->isp_osinfo.wqf = isp->isp_osinfo.wqt = NULL; + SIMPLEQ_INIT(&isp->isp_osinfo.wq); lptr->adapter_softc = isp; lptr->adapter = &isp->isp_osinfo._adapter; @@ -276,13 +276,7 @@ ispcmd_slow(XS_T *xs) void isp_add2_blocked_queue(struct ispsoftc *isp, XS_T *xs) { - if (isp->isp_osinfo.wqf != NULL) { - isp->isp_osinfo.wqt->free_list.le_next = xs; - } else { - isp->isp_osinfo.wqf = xs; - } - isp->isp_osinfo.wqt = xs; - xs->free_list.le_next = NULL; + SIMPLEQ_INSERT_TAIL(&isp->isp_osinfo.wq, xs, xfer_list); } int @@ -665,53 +659,41 @@ void isp_trestart(void *arg) { struct ispsoftc *isp = arg; - struct scsi_xfer *list; + struct scsi_xfer *xs; + struct scsi_xfer_list list; ISP_LOCK(isp); isp->isp_osinfo.rtpend = 0; - list = isp->isp_osinfo.wqf; - if (isp->isp_osinfo.blocked == 0 && list != NULL) { - int nrestarted = 0; - - isp->isp_osinfo.wqf = NULL; - ISP_UNLOCK(isp); - do { - struct scsi_xfer *xs = list; - list = xs->free_list.le_next; - xs->free_list.le_next = NULL; - isp_requeue(xs); - if (isp->isp_osinfo.wqf == NULL) - nrestarted++; - } while (list != NULL); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "requeued %d commands", nrestarted); -#endif - } else { + if (isp->isp_osinfo.blocked) { ISP_UNLOCK(isp); + return; + } + + list = isp->isp_osinfo.wq; + SIMPLEQ_INIT(&isp->isp_osinfo.wq); + ISP_UNLOCK(isp); + + while ((xs = SIMPLEQ_FIRST(&list)) != NULL) { + SIMPLEQ_REMOVE_HEAD(&list, xfer_list); + isp_requeue(xs); } } void isp_restart(struct ispsoftc *isp) { - struct scsi_xfer *list; - - list = isp->isp_osinfo.wqf; - if (isp->isp_osinfo.blocked == 0 && list != NULL) { - int nrestarted = 0; - - isp->isp_osinfo.wqf = NULL; - do { - struct scsi_xfer *xs = list; - list = xs->free_list.le_next; - xs->free_list.le_next = NULL; - isp_requeue(xs); - if (isp->isp_osinfo.wqf == NULL) - nrestarted++; - } while (list != NULL); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "requeued %d commands", nrestarted); -#endif + struct scsi_xfer *xs; + struct scsi_xfer_list list; + + if (isp->isp_osinfo.blocked) + return; + + list = isp->isp_osinfo.wq; + SIMPLEQ_INIT(&isp->isp_osinfo.wq); + + while ((xs = SIMPLEQ_FIRST(&list)) != NULL) { + SIMPLEQ_REMOVE_HEAD(&list, xfer_list); + isp_requeue(xs); } } diff --git a/sys/dev/ic/isp_openbsd.h b/sys/dev/ic/isp_openbsd.h index a6d627c7af9..71279c4c7bc 100644 --- a/sys/dev/ic/isp_openbsd.h +++ b/sys/dev/ic/isp_openbsd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: isp_openbsd.h,v 1.34 2011/03/06 16:59:42 miod Exp $ */ +/* $OpenBSD: isp_openbsd.h,v 1.35 2013/03/04 00:41:54 dlg Exp $ */ /* * OpenBSD Specific definitions for the QLogic ISP Host Adapter */ @@ -103,7 +103,7 @@ struct isposinfo { u_int16_t _discovered[2]; } un; #define discovered un._discovered - struct scsi_xfer *wqf, *wqt; + struct scsi_xfer_list wq; struct timeout rqt; }; #define MUST_POLL(isp) \ diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index 8fd472b4401..bf8a5683125 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.150 2012/07/01 01:41:13 krw Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.151 2013/03/04 00:41:54 dlg Exp $ */ /* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */ /* @@ -390,7 +390,7 @@ struct scsi_attach_args { * (via the scsi_link structure) */ struct scsi_xfer { - LIST_ENTRY(scsi_xfer) free_list; + SIMPLEQ_ENTRY(scsi_xfer) xfer_list; int flags; struct scsi_link *sc_link; /* all about our device and adapter */ int retries; /* the number of times to retry */ @@ -414,6 +414,7 @@ struct scsi_xfer { void *io; /* adapter io resource */ }; +SIMPLEQ_HEAD(scsi_xfer_list, scsi_xfer); /* * Per-request Flag values |