Index: usb/umass_scsipi.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/umass_scsipi.c,v retrieving revision 1.38 diff -p -r1.38 umass_scsipi.c *** usb/umass_scsipi.c 24 Aug 2011 11:28:50 -0000 1.38 --- usb/umass_scsipi.c 20 Feb 2012 04:59:47 -0000 *************** umass_scsipi_request(struct scsipi_chann *** 317,323 **** --- 317,325 ---- /* Return if command finishes early. */ done: + KERNEL_LOCK(1, curlwp); scsipi_done(xs); + KERNEL_UNLOCK_ONE(curlwp); return; default: /* Not supported, nothing to do. */ *************** umass_scsipi_cb(struct umass_softc *sc, *** 451,457 **** --- 453,461 ---- xs->error, xs->xs_status, xs->resid)); s = splbio(); + KERNEL_LOCK(1, curlwp); scsipi_done(xs); + KERNEL_UNLOCK_ONE(curlwp); splx(s); } *************** umass_scsipi_sense_cb(struct umass_softc *** 490,496 **** --- 494,502 ---- xs->resid)); s = splbio(); + KERNEL_LOCK(1, curlwp); scsipi_done(xs); + KERNEL_UNLOCK_ONE(curlwp); splx(s); } *************** umass_atapi_probe_device(struct atapibus *** 510,521 **** if (target != UMASS_ATAPI_DRIVE) /* only probe drive 0 */ return; /* skip if already attached */ ! if (scsipi_lookup_periph(chan, target, 0) != NULL) return; periph = scsipi_alloc_periph(M_NOWAIT); if (periph == NULL) { aprint_error_dev(atapi->sc_dev, "can't allocate link for drive %d\n", target); return; --- 516,532 ---- 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; *************** umass_atapi_probe_device(struct atapibus *** 531,536 **** --- 542,548 ---- /* 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); DPRINTF(UDMASS_SCSI, ("umass_atapi_probe_device: " "scsipi_inquire failed\n")); free(periph, M_DEVBUF); *************** umass_atapi_probe_device(struct atapibus *** 556,560 **** --- 568,574 ---- "'%s' '%s' '%s'\n", vendor, product, revision)); atapi_probe_device(atapi, target, periph, &sa); /* atapi_probe_device() frees the periph when there is no device.*/ + + KERNEL_UNLOCK_ONE(curlwp); } #endif Index: usb/usscanner.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/usscanner.c,v retrieving revision 1.32 diff -p -r1.32 usscanner.c *** usb/usscanner.c 23 Dec 2011 00:51:49 -0000 1.32 --- usb/usscanner.c 20 Feb 2012 04:59:47 -0000 *************** usscanner_intr_cb(usbd_xfer_handle xfer, *** 482,488 **** --- 482,490 ---- sc->sc_state = UAS_IDLE; s = splbio(); + KERNEL_LOCK(1, curlwp); scsipi_done(sc->sc_xs); + KERNEL_UNLOCK_ONE(curlwp); splx(s); } *************** usscanner_scsipi_request(struct scsipi_c *** 760,766 **** --- 762,770 ---- done: sc->sc_state = UAS_IDLE; + KERNEL_LOCK(1, curlwp); scsipi_done(xs); + KERNEL_UNLOCK_ONE(curlwp); return; case ADAPTER_REQ_GROW_RESOURCES: Index: scsipi/scsipi_base.c =================================================================== RCS file: /cvsroot/src/sys/dev/scsipi/scsipi_base.c,v retrieving revision 1.155 diff -p -r1.155 scsipi_base.c *** scsipi/scsipi_base.c 13 Nov 2010 13:52:11 -0000 1.155 --- scsipi/scsipi_base.c 20 Feb 2012 04:59:47 -0000 *************** scsipi_lookup_periph(struct scsipi_chann *** 218,223 **** --- 218,225 ---- uint32_t hash; int s; + KASSERT(KERNEL_LOCKED_P()); + if (target >= chan->chan_ntargets || lun >= chan->chan_nluns) return (NULL); *************** scsipi_done(struct scsipi_xfer *xs) *** 1261,1266 **** --- 1263,1270 ---- struct scsipi_channel *chan = periph->periph_channel; int s, freezecnt; + KASSERT(KERNEL_LOCKED_P()); + SC_DEBUG(periph, SCSIPI_DB2, ("scsipi_done\n")); #ifdef SCSIPI_DEBUG if (periph->periph_dbflags & SCSIPI_DB1) *************** scsipi_execute_xs(struct scsipi_xfer *xs *** 1860,1865 **** --- 1864,1870 ---- int oasync, async, poll, error, s; KASSERT(!cold); + KASSERT(KERNEL_LOCKED_P()); (chan->chan_bustype->bustype_cmd)(xs);