Module Name: src Committed By: skrll Date: Mon Nov 21 08:27:30 UTC 2016
Modified Files: src/sys/dev/usb: umass.c umass_scsipi.c Log Message: No need to take the kernel lock in umass(4) anymore To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/sys/dev/usb/umass.c cvs rdiff -u -r1.53 -r1.54 src/sys/dev/usb/umass_scsipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/umass.c diff -u src/sys/dev/usb/umass.c:1.156 src/sys/dev/usb/umass.c:1.157 --- src/sys/dev/usb/umass.c:1.156 Thu Jul 7 06:55:42 2016 +++ src/sys/dev/usb/umass.c Mon Nov 21 08:27:30 2016 @@ -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 @@ umass_attach(device_t parent, device_t s 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 @@ umass_attach(device_t parent, device_t s 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 @@ umass_attach(device_t parent, device_t s "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]); Index: src/sys/dev/usb/umass_scsipi.c diff -u src/sys/dev/usb/umass_scsipi.c:1.53 src/sys/dev/usb/umass_scsipi.c:1.54 --- src/sys/dev/usb/umass_scsipi.c:1.53 Sun Jul 3 07:27:37 2016 +++ src/sys/dev/usb/umass_scsipi.c Mon Nov 21 08:27:30 2016 @@ -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 @@ umass_scsipi_setup(struct umass_softc *s 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 @@ umass_scsipi_request(struct scsipi_chann /* 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 @@ umass_scsipi_cb(struct umass_softc *sc, 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 @@ umass_scsipi_cb(struct umass_softc *sc, 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 @@ umass_scsipi_sense_cb(struct umass_softc { 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 @@ umass_scsipi_sense_cb(struct umass_softc 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 @@ umass_atapi_probe_device(struct atapibus 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 @@ umass_atapi_probe_device(struct atapibus /* 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 @@ umass_atapi_probe_device(struct atapibus atapi_probe_device(atapi, target, periph, &sa); /* atapi_probe_device() frees the periph when there is no device.*/ - - KERNEL_UNLOCK_ONE(curlwp); } #endif