Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Change the way bustype_cmd is used. Rather t...



details:   https://anonhg.NetBSD.org/src/rev/cdb93953995b
branches:  trunk
changeset: 570022:cdb93953995b
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Fri Sep 17 23:30:22 2004 +0000

description:
Change the way bustype_cmd is used.  Rather than having it be responsible for
calling scsipi_make_xs() and scsipi_execute_xs(), instead push these into
scsipi_command.  Make bustype_cmd and PHOLD/PRELE be called from
scsipi_execute_xs().  This allows us to create a xfer structure -- possibly on
the stack -- and call scsipi_execute_xs() directly.

diffstat:

 sys/dev/scsipi/atapi_base.c  |  30 ++++++------------------------
 sys/dev/scsipi/atapiconf.h   |   6 ++----
 sys/dev/scsipi/scsi_base.c   |  31 ++++++-------------------------
 sys/dev/scsipi/scsiconf.h    |   8 +++-----
 sys/dev/scsipi/scsipi_base.c |  21 +++++++++++++++++++--
 sys/dev/scsipi/scsipiconf.c  |  28 ++++++++++++----------------
 sys/dev/scsipi/scsipiconf.h  |   6 ++----
 7 files changed, 50 insertions(+), 80 deletions(-)

diffs (292 lines):

diff -r 1f36f5bc6ff0 -r cdb93953995b sys/dev/scsipi/atapi_base.c
--- a/sys/dev/scsipi/atapi_base.c       Fri Sep 17 23:26:42 2004 +0000
+++ b/sys/dev/scsipi/atapi_base.c       Fri Sep 17 23:30:22 2004 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: atapi_base.c,v 1.22 2004/09/09 19:35:30 bouyer Exp $   */
+/*     $NetBSD: atapi_base.c,v 1.23 2004/09/17 23:30:22 mycroft Exp $  */
 
 /*-
- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapi_base.c,v 1.22 2004/09/09 19:35:30 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapi_base.c,v 1.23 2004/09/17 23:30:22 mycroft Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -212,30 +212,12 @@
  * long the data is supposed to be. If we have  a buf
  * to associate with the transfer, we need that too.
  */
-int
-atapi_scsipi_cmd(struct scsipi_periph *periph, struct scsipi_xfer *xs,
-    struct scsipi_generic *scsipi_cmd, int cmdlen, void *data, size_t datalen,
-    int retries, int timeout, struct buf *bp, int flags)
+void
+atapi_scsipi_cmd(struct scsipi_xfer *xs)
 {
-       int error;
+       struct scsipi_periph *periph = xs->xs_periph;
 
        SC_DEBUG(periph, SCSIPI_DB2, ("atapi_cmd\n"));
 
-#ifdef DIAGNOSTIC
-       if (bp != NULL && (flags & XS_CTL_ASYNC) == 0)
-               panic("atapi_scsipi_cmd: buffer without async");
-#endif
-       if (xs == NULL) {
-               if ((xs = scsipi_make_xs(periph, scsipi_cmd, cmdlen, data,
-                   datalen, retries, timeout, bp, flags)) == NULL) {
-                       /* let the caller deal with this */
-                       return (ENOMEM);
-               }
-       }
-
        xs->cmdlen = (periph->periph_cap & PERIPH_CAP_CMD16) ? 16 : 12;
-
-       if ((error = scsipi_execute_xs(xs)) == EJUSTRETURN)
-               return (0);
-       return (error);
 }
diff -r 1f36f5bc6ff0 -r cdb93953995b sys/dev/scsipi/atapiconf.h
--- a/sys/dev/scsipi/atapiconf.h        Fri Sep 17 23:26:42 2004 +0000
+++ b/sys/dev/scsipi/atapiconf.h        Fri Sep 17 23:30:22 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atapiconf.h,v 1.18 2004/09/09 19:35:30 bouyer Exp $    */
+/*     $NetBSD: atapiconf.h,v 1.19 2004/09/17 23:30:22 mycroft Exp $   */
 
 /*
  * Copyright (c) 1996, 2001 Manuel Bouyer.  All rights reserved.
@@ -57,8 +57,6 @@
 int    atapiprint(void *, const char *);
 void   atapi_print_addr(struct scsipi_periph *);
 int    atapi_interpret_sense(struct scsipi_xfer *);
-int    atapi_scsipi_cmd(struct scsipi_periph *, struct scsipi_xfer *,
-           struct scsipi_generic *, int, void *, size_t,
-           int, int, struct buf *, int);
+void   atapi_scsipi_cmd(struct scsipi_xfer *);
 
 #endif /* _DEV_SCSIPI_ATAPICONF_H */
diff -r 1f36f5bc6ff0 -r cdb93953995b sys/dev/scsipi/scsi_base.c
--- a/sys/dev/scsipi/scsi_base.c        Fri Sep 17 23:26:42 2004 +0000
+++ b/sys/dev/scsipi/scsi_base.c        Fri Sep 17 23:30:22 2004 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: scsi_base.c,v 1.81 2004/09/09 19:35:30 bouyer Exp $    */
+/*     $NetBSD: scsi_base.c,v 1.82 2004/09/17 23:30:22 mycroft Exp $   */
 
 /*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsi_base.c,v 1.81 2004/09/09 19:35:30 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsi_base.c,v 1.82 2004/09/17 23:30:22 mycroft Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -78,28 +78,13 @@
  * long the data is supposed to be. If we have  a buf
  * to associate with the transfer, we need that too.
  */
-int
-scsi_scsipi_cmd(struct scsipi_periph *periph, struct scsipi_xfer *xs,
-    struct scsipi_generic *scsipi_cmd, int cmdlen, void *data, size_t datalen,
-    int retries, int timeout, struct buf *bp, int flags)
+void
+scsi_scsipi_cmd(struct scsipi_xfer *xs)
 {
-       int error;
+       struct scsipi_periph *periph = xs->xs_periph;
 
        SC_DEBUG(periph, SCSIPI_DB2, ("scsi_scsipi_cmd\n"));
 
-#ifdef DIAGNOSTIC
-       if (bp != NULL && (flags & XS_CTL_ASYNC) == 0)
-               panic("scsi_scsipi_cmd: buffer without async");
-#endif
-
-       if (xs == NULL) {
-               if ((xs = scsipi_make_xs(periph, scsipi_cmd, cmdlen, data,
-                   datalen, retries, timeout, bp, flags)) == NULL) {
-                       /* let the caller deal with this */
-                       return (ENOMEM);
-               }
-       }
-
        /*
         * Set the LUN in the CDB if we have an older device.  We also
         * set it for more modern SCSI-2 devices "just in case".
@@ -108,10 +93,6 @@
                xs->cmd->bytes[0] |=
                    ((periph->periph_lun << SCSI_CMD_LUN_SHIFT) &
                        SCSI_CMD_LUN_MASK);
-
-       if ((error = scsipi_execute_xs(xs)) == EJUSTRETURN)
-               return (0);
-       return (error);
 }
 
 /*
diff -r 1f36f5bc6ff0 -r cdb93953995b sys/dev/scsipi/scsiconf.h
--- a/sys/dev/scsipi/scsiconf.h Fri Sep 17 23:26:42 2004 +0000
+++ b/sys/dev/scsipi/scsiconf.h Fri Sep 17 23:30:22 2004 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: scsiconf.h,v 1.52 2004/09/09 19:35:31 bouyer Exp $     */
+/*     $NetBSD: scsiconf.h,v 1.53 2004/09/17 23:30:22 mycroft Exp $    */
 
 /*-
- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -76,8 +76,6 @@
 void   scsi_kill_pending(struct scsipi_periph *);
 void   scsi_print_addr(struct scsipi_periph *);
 int    scsi_probe_bus(struct scsibus_softc *, int, int);
-int    scsi_scsipi_cmd(struct scsipi_periph *, struct scsipi_xfer *,
-           struct scsipi_generic *, int, void *, size_t,
-           int, int, struct buf *, int);
+void   scsi_scsipi_cmd(struct scsipi_xfer *);
 
 #endif /* _DEV_SCSIPI_SCSICONF_H_ */
diff -r 1f36f5bc6ff0 -r cdb93953995b sys/dev/scsipi/scsipi_base.c
--- a/sys/dev/scsipi/scsipi_base.c      Fri Sep 17 23:26:42 2004 +0000
+++ b/sys/dev/scsipi/scsipi_base.c      Fri Sep 17 23:30:22 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipi_base.c,v 1.113 2004/09/17 23:10:50 mycroft Exp $        */
+/*     $NetBSD: scsipi_base.c,v 1.114 2004/09/17 23:30:22 mycroft Exp $        */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.113 2004/09/17 23:10:50 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.114 2004/09/17 23:30:22 mycroft Exp $");
 
 #include "opt_scsi.h"
 
@@ -1896,6 +1896,21 @@
        struct scsipi_channel *chan = periph->periph_channel;
        int oasync, async, poll, retries, error, s;
 
+       (chan->chan_bustype->bustype_cmd)(xs);
+
+       if (xs->xs_control & XS_CTL_DATA_ONSTACK) {
+#if 1
+               if (xs->xs_control & XS_CTL_ASYNC)
+                       panic("scsipi_execute_xs: on stack and async");
+#endif
+               /*
+                * If the I/O buffer is allocated on stack, the
+                * process must NOT be swapped out, as the device will
+                * be accessing the stack.
+                */
+               PHOLD(curlwp);
+       }
+
        xs->xs_status &= ~XS_STS_DONE;
        xs->error = XS_NOERROR;
        xs->resid = xs->datalen;
@@ -2058,6 +2073,8 @@
         */
        scsipi_run_queue(chan);
 
+       if (xs->xs_control & XS_CTL_DATA_ONSTACK)
+               PRELE(curlwp);
        return (error);
 }
 
diff -r 1f36f5bc6ff0 -r cdb93953995b sys/dev/scsipi/scsipiconf.c
--- a/sys/dev/scsipi/scsipiconf.c       Fri Sep 17 23:26:42 2004 +0000
+++ b/sys/dev/scsipi/scsipiconf.c       Fri Sep 17 23:30:22 2004 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: scsipiconf.c,v 1.24 2004/09/09 19:35:31 bouyer Exp $   */
+/*     $NetBSD: scsipiconf.c,v 1.25 2004/09/17 23:30:22 mycroft Exp $  */
 
 /*-
- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipiconf.c,v 1.24 2004/09/09 19:35:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipiconf.c,v 1.25 2004/09/17 23:30:22 mycroft Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -67,6 +67,7 @@
 
 #include <dev/scsipi/scsipi_all.h>
 #include <dev/scsipi/scsipiconf.h>
+#include <dev/scsipi/scsipi_base.h>
 
 #define        STRVIS_ISWHITE(x) ((x) == ' ' || (x) == '\0' || (x) == (u_char)'\377')
 
@@ -75,21 +76,16 @@
     struct scsipi_generic *cmd, int cmdlen, u_char *data_addr, int datalen,
     int retries, int timeout, struct buf *bp, int flags)
 {
-       int error;
  
-       if ((flags & XS_CTL_DATA_ONSTACK) != 0) {
-               /*
-                * If the I/O buffer is allocated on stack, the
-                * process must NOT be swapped out, as the device will
-                * be accessing the stack.
-                */
-               PHOLD(curlwp);
+       if (xs == NULL) {
+               if ((xs = scsipi_make_xs(periph, cmd, cmdlen, data_addr,
+                   datalen, retries, timeout, bp, flags)) == NULL) {
+                       /* let the caller deal with this */
+                       return (ENOMEM);
+               }
        }
-       error = (*periph->periph_channel->chan_bustype->bustype_cmd)(periph,
-           xs, cmd, cmdlen, data_addr, datalen, retries, timeout, bp, flags);
-       if ((flags & XS_CTL_DATA_ONSTACK) != 0)
-               PRELE(curlwp);
-       return (error);
+
+       return (scsipi_execute_xs(xs));
 }
 
 /*
diff -r 1f36f5bc6ff0 -r cdb93953995b sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h       Fri Sep 17 23:26:42 2004 +0000
+++ b/sys/dev/scsipi/scsipiconf.h       Fri Sep 17 23:30:22 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipiconf.h,v 1.88 2004/09/17 23:10:50 mycroft Exp $  */
+/*     $NetBSD: scsipiconf.h,v 1.89 2004/09/17 23:30:22 mycroft Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc.
@@ -237,9 +237,7 @@
 struct scsipi_bustype {
        int     bustype_type;           /* symbolic name of type */
        
-       int     (*bustype_cmd)(struct scsipi_periph *, struct scsipi_xfer *,
-                   struct scsipi_generic *, int, void *, size_t, int,
-                   int, struct buf *, int);
+       void    (*bustype_cmd)(struct scsipi_xfer *);
        int     (*bustype_interpret_sense)(struct scsipi_xfer *);
        void    (*bustype_printaddr)(struct scsipi_periph *);
        void    (*bustype_kill_pending)(struct scsipi_periph *);



Home | Main Index | Thread Index | Old Index