Index: sys/dev/usb/umass.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/umass.c,v retrieving revision 1.156 diff -u -p -r1.156 umass.c --- sys/dev/usb/umass.c 7 Jul 2016 06:55:42 -0000 1.156 +++ sys/dev/usb/umass.c 19 Nov 2016 12:27:34 -0000 @@ -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: sys/dev/usb/umass_scsipi.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/umass_scsipi.c,v retrieving revision 1.53 diff -u -p -r1.53 umass_scsipi.c --- sys/dev/usb/umass_scsipi.c 3 Jul 2016 07:27:37 -0000 1.53 +++ sys/dev/usb/umass_scsipi.c 19 Nov 2016 12:27:34 -0000 @@ -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,7 @@ umass_scsipi_cb(struct umass_softc *sc, struct scsipi_xfer *xs = priv; struct scsipi_periph *periph = xs->xs_periph; int cmdlen, senselen; - int s; + // int s; #ifdef UMASS_DEBUG struct timeval tv; u_int delta; @@ -454,11 +453,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 +465,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 +489,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 +508,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 +530,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 +555,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