Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb No need to take the kernel lock in umass(4) anymore



details:   https://anonhg.NetBSD.org/src/rev/ea8d705db685
branches:  trunk
changeset: 349042:ea8d705db685
user:      skrll <skrll%NetBSD.org@localhost>
date:      Mon Nov 21 08:27:30 2016 +0000

description:
No need to take the kernel lock in umass(4) anymore

diffstat:

 sys/dev/usb/umass.c        |  11 +++++------
 sys/dev/usb/umass_scsipi.c |  24 +++---------------------
 2 files changed, 8 insertions(+), 27 deletions(-)

diffs (156 lines):

diff -r e5e319956314 -r ea8d705db685 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c       Mon Nov 21 08:09:54 2016 +0000
+++ b/sys/dev/usb/umass.c       Mon Nov 21 08:27:30 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass.c,v 1.156 2016/07/07 06:55:42 msaitoh Exp $      */
+/*     $NetBSD: umass.c,v 1.157 2016/11/21 08:27:30 skrll Exp $        */
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.156 2016/07/07 06:55:42 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.157 2016/11/21 08:27:30 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -527,8 +527,7 @@
        DPRINTFM(UDMASS_USB, "sc %p: opening iface %p epaddr %d for BULKOUT",
            sc, sc->sc_iface, sc->sc_epaddr[UMASS_BULKOUT], 0);
        err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_BULKOUT],
-                               USBD_EXCLUSIVE_USE,
-                               &sc->sc_pipe[UMASS_BULKOUT]);
+           USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->sc_pipe[UMASS_BULKOUT]);
        if (err) {
                aprint_error_dev(self, "cannot open %u-out pipe (bulk)\n",
                    sc->sc_epaddr[UMASS_BULKOUT]);
@@ -538,7 +537,7 @@
        DPRINTFM(UDMASS_USB, "sc %p: opening iface %p epaddr %d for BULKIN",
            sc, sc->sc_iface, sc->sc_epaddr[UMASS_BULKIN], 0);
        err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_BULKIN],
-           USBD_EXCLUSIVE_USE, &sc->sc_pipe[UMASS_BULKIN]);
+           USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->sc_pipe[UMASS_BULKIN]);
        if (err) {
                aprint_error_dev(self, "could not open %u-in pipe (bulk)\n",
                    sc->sc_epaddr[UMASS_BULKIN]);
@@ -562,7 +561,7 @@
                    "sc %p: opening iface %p epaddr %d for INTRIN",
                    sc, sc->sc_iface, sc->sc_epaddr[UMASS_INTRIN], 0);
                err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_INTRIN],
-                               USBD_EXCLUSIVE_USE, &sc->sc_pipe[UMASS_INTRIN]);
+                   USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->sc_pipe[UMASS_INTRIN]);
                if (err) {
                        aprint_error_dev(self, "couldn't open %u-in (intr)\n",
                            sc->sc_epaddr[UMASS_INTRIN]);
diff -r e5e319956314 -r ea8d705db685 sys/dev/usb/umass_scsipi.c
--- a/sys/dev/usb/umass_scsipi.c        Mon Nov 21 08:09:54 2016 +0000
+++ b/sys/dev/usb/umass_scsipi.c        Mon Nov 21 08:27:30 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass_scsipi.c,v 1.53 2016/07/03 07:27:37 skrll Exp $  */
+/*     $NetBSD: umass_scsipi.c,v 1.54 2016/11/21 08:27:30 skrll Exp $  */
 
 /*
  * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.53 2016/07/03 07:27:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.54 2016/11/21 08:27:30 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -194,6 +194,7 @@
        scbus->sc_adapter.adapt_minphys = umass_scsipi_minphys;
        scbus->sc_adapter.adapt_ioctl = umass_scsipi_ioctl;
        scbus->sc_adapter.adapt_getgeom = umass_scsipi_getgeom;
+       scbus->sc_adapter.adapt_flags = SCSIPI_ADAPT_MPSAFE;
 
        /* Fill in the channel. */
        memset(&scbus->sc_channel, 0, sizeof(scbus->sc_channel));
@@ -316,9 +317,7 @@
 
                /* Return if command finishes early. */
  done:
-               KERNEL_LOCK(1, curlwp);
                scsipi_done(xs);
-               KERNEL_UNLOCK_ONE(curlwp);
                return;
        default:
                /* Not supported, nothing to do. */
@@ -397,7 +396,6 @@
        struct scsipi_xfer *xs = priv;
        struct scsipi_periph *periph = xs->xs_periph;
        int cmdlen, senselen;
-       int s;
 #ifdef UMASS_DEBUG
        struct timeval tv;
        u_int delta;
@@ -454,11 +452,7 @@
        DPRINTFM(UDMASS_CMD, "return xs->error=%d, xs->xs_status=0x%x"
            " xs->resid=%d", xs->error, xs->xs_status, xs->resid, 0);
 
-       s = splbio();
-       KERNEL_LOCK(1, curlwp);
        scsipi_done(xs);
-       KERNEL_UNLOCK_ONE(curlwp);
-       splx(s);
 }
 
 /*
@@ -470,7 +464,6 @@
 {
        UMASSHIST_FUNC(); UMASSHIST_CALLED();
        struct scsipi_xfer *xs = priv;
-       int s;
 
        DPRINTFM(UDMASS_CMD, "sc %p: xs=%p residue=%d status=%d", sc, xs,
            residue, status);
@@ -495,11 +488,7 @@
        DPRINTFM(UDMASS_CMD, "return xs->error=%d, xs->xs_status=0x%x"
            " xs->resid=%d", xs->error, xs->xs_status, xs->resid, 0);
 
-       s = splbio();
-       KERNEL_LOCK(1, curlwp);
        scsipi_done(xs);
-       KERNEL_UNLOCK_ONE(curlwp);
-       splx(s);
 }
 
 #if NATAPIBUS > 0
@@ -518,17 +507,13 @@
        if (target != UMASS_ATAPI_DRIVE)        /* only probe drive 0 */
                return;
 
-       KERNEL_LOCK(1, curlwp);
-
        /* skip if already attached */
        if (scsipi_lookup_periph(chan, target, 0) != NULL) {
-               KERNEL_UNLOCK_ONE(curlwp);
                return;
        }
 
        periph = scsipi_alloc_periph(M_NOWAIT);
        if (periph == NULL) {
-               KERNEL_UNLOCK_ONE(curlwp);
                aprint_error_dev(atapi->sc_dev,
                    "can't allocate link for drive %d\n", target);
                return;
@@ -544,7 +529,6 @@
        /* Now go ask the device all about itself. */
        memset(&inqbuf, 0, sizeof(inqbuf));
        if (scsipi_inquire(periph, &inqbuf, XS_CTL_DISCOVERY) != 0) {
-               KERNEL_UNLOCK_ONE(curlwp);
                DPRINTFM(UDMASS_SCSI, "scsipi_inquire failed", 0, 0, 0, 0);
                free(periph, M_DEVBUF);
                return;
@@ -570,7 +554,5 @@
 
        atapi_probe_device(atapi, target, periph, &sa);
        /* atapi_probe_device() frees the periph when there is no device.*/
-
-       KERNEL_UNLOCK_ONE(curlwp);
 }
 #endif



Home | Main Index | Thread Index | Old Index