Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Call ADAPTER_REQ_GROW_RESOURCES from the comp...



details:   https://anonhg.NetBSD.org/src/rev/26e9751df762
branches:  trunk
changeset: 516064:26e9751df762
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Oct 14 20:31:24 2001 +0000

description:
Call ADAPTER_REQ_GROW_RESOURCES from the completion thread, if possible.
This allows HBA drivers to call bus_dmamem_map() safely.

diffstat:

 sys/dev/scsipi/scsipi_base.c |  32 +++++++++++++++++++++++++-------
 sys/dev/scsipi/scsipiconf.h  |   3 ++-
 2 files changed, 27 insertions(+), 8 deletions(-)

diffs (77 lines):

diff -r 863221178797 -r 26e9751df762 sys/dev/scsipi/scsipi_base.c
--- a/sys/dev/scsipi/scsipi_base.c      Sun Oct 14 20:13:31 2001 +0000
+++ b/sys/dev/scsipi/scsipi_base.c      Sun Oct 14 20:31:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipi_base.c,v 1.59 2001/10/14 19:03:43 bouyer Exp $  */
+/*     $NetBSD: scsipi_base.c,v 1.60 2001/10/14 20:31:24 bouyer Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -269,8 +269,19 @@
 {
 
        if (chan->chan_flags & SCSIPI_CHAN_CANGROW) {
-               scsipi_adapter_request(chan, ADAPTER_REQ_GROW_RESOURCES, NULL);
-               return (scsipi_get_resource(chan));
+               if ((chan->chan_flags & SCSIPI_CHAN_TACTIVE) == 0) {
+                       scsipi_adapter_request(chan,
+                           ADAPTER_REQ_GROW_RESOURCES, NULL);
+                       return (scsipi_get_resource(chan));
+               }
+               /*
+                * ask the channel thread to do it. It'll have to thaw the
+                * queue
+                */
+               scsipi_channel_freeze(chan, 1);
+               chan->chan_tflags |= SCSIPI_CHANT_GROWRES;
+               wakeup(&chan->chan_complete);
+               return (0);
        }
 
        return (0);
@@ -1967,10 +1978,8 @@
        for (;;) {
                s = splbio();
                xs = TAILQ_FIRST(&chan->chan_complete);
-               if (xs == NULL &&
-                   (chan->chan_tflags &
-                    (SCSIPI_CHANT_SHUTDOWN | SCSIPI_CHANT_CALLBACK |
-                    SCSIPI_CHANT_KICK)) == 0) {
+               if (xs == NULL && chan->chan_tflags  == 0) {
+                       /* nothing to do; wait */
                        (void) tsleep(&chan->chan_complete, PRIBIO,
                            "sccomp", 0);
                        splx(s);
@@ -1983,6 +1992,15 @@
                        splx(s);
                        continue;
                }
+               if (chan->chan_tflags & SCSIPI_CHANT_GROWRES) {
+                       /* attempt to get more openings for this channel */
+                       chan->chan_tflags &= ~SCSIPI_CHANT_GROWRES;
+                       scsipi_adapter_request(chan,
+                           ADAPTER_REQ_GROW_RESOURCES, NULL);
+                       scsipi_channel_thaw(chan, 1);
+                       splx(s);
+                       continue;
+               }
                if (chan->chan_tflags & SCSIPI_CHANT_KICK) {
                        /* explicitly run the queues for this channel */
                        chan->chan_tflags &= ~SCSIPI_CHANT_KICK;
diff -r 863221178797 -r 26e9751df762 sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h       Sun Oct 14 20:13:31 2001 +0000
+++ b/sys/dev/scsipi/scsipiconf.h       Sun Oct 14 20:31:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipiconf.h,v 1.61 2001/10/14 19:03:44 bouyer Exp $   */
+/*     $NetBSD: scsipiconf.h,v 1.62 2001/10/14 20:31:24 bouyer Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -310,6 +310,7 @@
 #define        SCSIPI_CHANT_SHUTDOWN   0x01    /* channel is shutting down */
 #define        SCSIPI_CHANT_CALLBACK   0x02    /* has to call chan_callback() */
 #define        SCSIPI_CHANT_KICK       0x04    /* need to run queues */
+#define        SCSIPI_CHANT_GROWRES    0x08    /* call ADAPTER_REQ_GROW_RESOURCES */
 
 #define        SCSIPI_CHAN_MAX_PERIPH(chan)                                    \
        (((chan)->chan_flags & SCSIPI_CHAN_OPENINGS) ?                  \



Home | Main Index | Thread Index | Old Index