Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/thorpej_scsipi]: src/sys/dev Eliminate sleeping from adapter routines.



details:   https://anonhg.NetBSD.org/src/rev/aa34e420653f
branches:  thorpej_scsipi
changeset: 477294:aa34e420653f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Oct 20 20:42:10 1999 +0000

description:
Eliminate sleeping from adapter routines.

diffstat:

 sys/dev/eisa/ahb.c    |  73 ++++++++++++++---------------------------
 sys/dev/isa/wds.c     |  88 ++++++++++++++------------------------------------
 sys/dev/pci/isp_pci.c |  15 ++++++--
 sys/dev/pci/ncr.c     |  17 ++-------
 sys/dev/pci/pcscp.c   |  20 +++++++----
 5 files changed, 78 insertions(+), 135 deletions(-)

diffs (truncated from 396 to 300 lines):

diff -r f88ee77df169 -r aa34e420653f sys/dev/eisa/ahb.c
--- a/sys/dev/eisa/ahb.c        Wed Oct 20 20:41:27 1999 +0000
+++ b/sys/dev/eisa/ahb.c        Wed Oct 20 20:42:10 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahb.c,v 1.28.2.1 1999/10/19 17:44:55 thorpej Exp $     */
+/*     $NetBSD: ahb.c,v 1.28.2.2 1999/10/20 20:42:42 thorpej Exp $     */
 
 #include "opt_ddb.h"
 
@@ -130,7 +130,7 @@
 void   ahb_send_immed __P((struct ahb_softc *, u_long, struct ahb_ecb *));
 int    ahbintr __P((void *));
 void   ahb_free_ecb __P((struct ahb_softc *, struct ahb_ecb *));
-struct ahb_ecb *ahb_get_ecb __P((struct ahb_softc *, int));
+struct ahb_ecb *ahb_get_ecb __P((struct ahb_softc *));
 struct ahb_ecb *ahb_ecb_phys_kv __P((struct ahb_softc *, physaddr));
 void   ahb_done __P((struct ahb_softc *, struct ahb_ecb *));
 int    ahb_find __P((bus_space_tag_t, bus_space_handle_t, struct ahb_probe_data *));
@@ -452,17 +452,8 @@
        int s;
 
        s = splbio();
-
        ahb_reset_ecb(sc, ecb);
        TAILQ_INSERT_HEAD(&sc->sc_free_ecb, ecb, chain);
-
-       /*
-        * If there were none, wake anybody waiting for one to come free,
-        * starting with queued entries.
-        */
-       if (ecb->chain.tqe_next == 0)
-               wakeup(&sc->sc_free_ecb);
-
        splx(s);
 }
 
@@ -531,35 +522,20 @@
  * hash table too otherwise either return an error or sleep.
  */
 struct ahb_ecb *
-ahb_get_ecb(sc, flags)
+ahb_get_ecb(sc)
        struct ahb_softc *sc;
-       int flags;
 {
        struct ahb_ecb *ecb;
        int s;
 
        s = splbio();
-
-       /*
-        * If we can and have to, sleep waiting for one to come free
-        * but only if we can't allocate a new one.
-        */
-       for (;;) {
-               ecb = sc->sc_free_ecb.tqh_first;
-               if (ecb) {
-                       TAILQ_REMOVE(&sc->sc_free_ecb, ecb, chain);
-                       break;
-               }
-               if ((flags & XS_CTL_NOSLEEP) != 0)
-                       goto out;
-               tsleep(&sc->sc_free_ecb, PRIBIO, "ahbecb", 0);
+       ecb = TAILQ_FIRST(&sc->sc_free_ecb);
+       if (ecb != NULL) {
+               TAILQ_REMOVE(&sc->sc_free_ecb, ecb, chain);
+               ecb->flags |= ECB_ALLOC;
        }
-
-       ecb->flags |= ECB_ALLOC;
-
-out:
        splx(s);
-       return ecb;
+       return (ecb);
 }
 
 /*
@@ -852,7 +828,7 @@
                SC_DEBUG(sc_link, SDEV_DB2, ("ahb_scsipi_request\n"));
 
                /* Get an ECB to use. */
-               ecb = ahb_get_ecb(sc, flags);
+               ecb = ahb_get_ecb(sc);
 #ifdef DIAGNOSTIC
                /*
                 * This should never happen as we track the resources
@@ -923,29 +899,30 @@
                        if (flags & XS_CTL_DATA_UIO) {
                                error = bus_dmamap_load_uio(sc->sc_dmat,
                                    ecb->dmamap_xfer, (struct uio *)xs->data,
-                                   (flags & XS_CTL_NOSLEEP) ? BUS_DMA_NOWAIT :
-                                   BUS_DMA_WAITOK);
+                                   BUS_DMA_NOWAIT);
                        } else
 #endif /* TFS */
                        {
                                error = bus_dmamap_load(sc->sc_dmat,
                                    ecb->dmamap_xfer, xs->data, xs->datalen,
-                                   NULL, (flags & XS_CTL_NOSLEEP) ?
-                                   BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
+                                   NULL, BUS_DMA_NOWAIT);
                        }
 
-                       if (error) {
-                               if (error == EFBIG) {
-                                       printf("%s: ahb_scsipi_request, more "
-                                           "than %d dma segments\n",
-                                           sc->sc_dev.dv_xname, AHB_NSEG);
-                               } else {
-                                       printf("%s: ahb_scsipi_request, error "
-                                           "%d loading dma map\n",
-                                           sc->sc_dev.dv_xname, error);
-                               }
+                       switch (error) {
+                       case 0:
+                               break;
+
+                       case ENOMEM:
+                       case EAGAIN:
+                               xs->error = XS_RESOURCE_SHORTAGE;
+                               goto out_bad;
+
+                       default:
+                               xs->error = XS_DRIVER_STUFFUP;
+                               printf("%s: error %d loading DMA map\n",
+                                   sc->sc_dev.dv_xname, error);
+ out_bad:
                                ahb_free_ecb(sc, ecb);
-                               xs->error = XS_DRIVER_STUFFUP;
                                scsipi_done(xs);
                                return;
                        }
diff -r f88ee77df169 -r aa34e420653f sys/dev/isa/wds.c
--- a/sys/dev/isa/wds.c Wed Oct 20 20:41:27 1999 +0000
+++ b/sys/dev/isa/wds.c Wed Oct 20 20:42:10 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wds.c,v 1.39.2.1 1999/10/19 17:49:05 thorpej Exp $     */
+/*     $NetBSD: wds.c,v 1.39.2.2 1999/10/20 20:42:10 thorpej Exp $     */
 
 #include "opt_ddb.h"
 
@@ -185,7 +185,7 @@
 integrate void wds_reset_scb __P((struct wds_softc *, struct wds_scb *));
 void    wds_free_scb __P((struct wds_softc *, struct wds_scb *));
 integrate int wds_init_scb __P((struct wds_softc *, struct wds_scb *));
-struct wds_scb *wds_get_scb __P((struct wds_softc *, int));
+struct wds_scb *wds_get_scb __P((struct wds_softc *));
 struct wds_scb *wds_scb_phys_kv __P((struct wds_softc *, u_long));
 void   wds_queue_scb __P((struct wds_softc *, struct wds_scb *));
 void   wds_collect_mbo __P((struct wds_softc *));
@@ -522,17 +522,8 @@
        int s;
 
        s = splbio();
-
        wds_reset_scb(sc, scb);
        TAILQ_INSERT_HEAD(&sc->sc_free_scb, scb, chain);
-
-       /*
-        * If there were none, wake anybody waiting for one to come free,
-        * starting with queued entries.
-        */
-       if (scb->chain.tqe_next == 0)
-               wakeup(&sc->sc_free_scb);
-
        splx(s);
 }
 
@@ -658,47 +649,18 @@
  * the hash table too otherwise either return an error or sleep.
  */
 struct wds_scb *
-wds_get_scb(sc, flags)
+wds_get_scb(sc)
        struct wds_softc *sc;
-       int flags;
 {
        struct wds_scb *scb;
        int s;
 
        s = splbio();
-
-       /*
-        * If we can and have to, sleep waiting for one to come free
-        * but only if we can't allocate a new one.
-        */
-       for (;;) {
-               scb = sc->sc_free_scb.tqh_first;
-               if (scb) {
-                       TAILQ_REMOVE(&sc->sc_free_scb, scb, chain);
-                       break;
-               }
-               if (sc->sc_numscbs < WDS_SCB_MAX) {
-                       /*
-                        * wds_create_scbs() might have managed to create
-                        * one before it failed.  If so, don't abort,
-                        * just grab it and continue to hobble along.
-                        */
-                       if (wds_create_scbs(sc, NULL, 0) != 0 &&
-                           sc->sc_free_scb.tqh_first == NULL) {
-                               printf("%s: can't allocate scbs\n",
-                                   sc->sc_dev.dv_xname);
-                               goto out;
-                       }
-                       continue;
-               }
-               if ((flags & XS_CTL_NOSLEEP) != 0)
-                       goto out;
-               tsleep(&sc->sc_free_scb, PRIBIO, "wdsscb", 0);
+       scb = TAILQ_FIRST(&sc->sc_free_scb);
+       if (scb != NULL) {
+               TAILQ_REMOVE(&sc->sc_free_scb, scb, chain);
+               scb->flags |= SCB_ALLOC;
        }
-
-       scb->flags |= SCB_ALLOC;
-
-out:
        splx(s);
        return (scb);
 }
@@ -1086,7 +1048,7 @@
 
        sc->sc_maxsegs = 1;
 
-       scb = wds_get_scb(sc, XS_CTL_NOSLEEP);
+       scb = wds_get_scb(sc);
        if (scb == 0)
                panic("wds_inquire_setup_information: no scb available");
 
@@ -1190,7 +1152,7 @@
                flags = xs->xs_control;
 
                /* Get an SCB to use. */
-               scb = wds_get_scb(sc, flags);
+               scb = wds_get_scb(sc);
 #ifdef DIAGNOSTIC
                /*
                 * This should never happen as we track the resources
@@ -1230,30 +1192,30 @@
                        if (flags & XS_CTL_DATA_UIO) {
                                error = bus_dmamap_load_uio(dmat,
                                    scb->dmamap_xfer, (struct uio *)xs->data,
-                                   (flags & XS_CTL_NOSLEEP) ? BUS_DMA_NOWAIT :
-                                   BUS_DMA_WAITOK);
+                                   BUS_DMA_NOWAIT);
                        } else
 #endif /* TFS */
                        {
                                error = bus_dmamap_load(dmat,
                                    scb->dmamap_xfer, xs->data, xs->datalen,
-                                   NULL, (flags & XS_CTL_NOSLEEP) ?
-                                   BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
+                                   NULL, BUS_DMA_NOWAIT);
                        }
 
-                       if (error) {
-                               if (error == EFBIG) {
-                                       printf("%s: wds_scsi_cmd, more than %d"
-                                           " dma segments\n",
-                                           sc->sc_dev.dv_xname,
-                                           sc->sc_maxsegs);
-                               } else {
-                                       printf("%s: wds_scsi_cmd, error %d "
-                                           "loading dma map\n",
-                                           sc->sc_dev.dv_xname, error);
-                               }
+                       switch (error) {
+                       case 0:
+                               break;
+
+                       case ENOMEM:
+                       case EAGAIN:
+                               xs->error = XS_RESOURCE_SHORTAGE;
+                               goto out_bad;
+
+                       default:
+                               xs->error = XS_DRIVER_STUFFUP;
+                               printf("%s: error %d loading DMA map\n",
+                                   sc->sc_dev.dv_xname, error);
+ out_bad:
                                wds_free_scb(sc, scb);
-                               xs->error = XS_DRIVER_STUFFUP;
                                scsipi_done(xs);
                                return;
                        }
diff -r f88ee77df169 -r aa34e420653f sys/dev/pci/isp_pci.c
--- a/sys/dev/pci/isp_pci.c     Wed Oct 20 20:41:27 1999 +0000
+++ b/sys/dev/pci/isp_pci.c     Wed Oct 20 20:42:10 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_pci.c,v 1.45 1999/10/17 02:40:26 mjacob Exp $ */
+/* $NetBSD: isp_pci.c,v 1.45.2.1 1999/10/20 20:43:20 thorpej Exp $ */
 /*
  * PCI specific probe and attach routines for Qlogic ISP SCSI adapters.
  * Matthew Jacob (mjacob%nas.nasa.gov@localhost)
@@ -687,9 +687,16 @@
                rq->req_flags |= drq;
        }
        error = bus_dmamap_load(pci->pci_dmat, dmap, xs->data, xs->datalen,



Home | Main Index | Thread Index | Old Index