From 21e4fb692d9b6c19f81e6976630066344d23b7a3 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 15 Mar 2004 05:45:19 +0000 Subject: [PATCH] When detaching UMASS, abort all the pipes before detaching the sim. Note sim detachment path is: umass_cam_detach_sim -> xpt_bus_deregister -> cam_sim_free. If there is anything pending as of the cam_sim_free() bad things will happen. --- sys/dev/usbmisc/umass/umass.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/dev/usbmisc/umass/umass.c b/sys/dev/usbmisc/umass/umass.c index 45e8bf18f5..9e144f2d38 100644 --- a/sys/dev/usbmisc/umass/umass.c +++ b/sys/dev/usbmisc/umass/umass.c @@ -26,7 +26,7 @@ * * $NetBSD: umass.c,v 1.28 2000/04/02 23:46:53 augustss Exp $ * $FreeBSD: src/sys/dev/usb/umass.c,v 1.96 2003/12/19 12:19:11 sanpei Exp $ - * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.10 2004/03/15 02:27:57 dillon Exp $ + * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.11 2004/03/15 05:45:19 dillon Exp $ */ /* @@ -1070,18 +1070,32 @@ USB_DETACH(umass) DPRINTF(UDMASS_USB, ("%s: detached\n", USBDEVNAME(sc->sc_dev))); + /* + * Set UMASS_FLAGS_GONE to prevent any new transfers from being + * queued, and abort any transfers in progress to ensure that + * pending requests (e.g. from CAM's bus scan) are terminated. + */ sc->flags |= UMASS_FLAGS_GONE; + if (sc->bulkout_pipe) + usbd_abort_pipe(sc->bulkout_pipe); + if (sc->bulkin_pipe) + usbd_abort_pipe(sc->bulkin_pipe); + if (sc->intrin_pipe) + usbd_abort_pipe(sc->intrin_pipe); + if ((sc->proto & UMASS_PROTO_SCSI) || (sc->proto & UMASS_PROTO_ATAPI) || (sc->proto & UMASS_PROTO_UFI) || - (sc->proto & UMASS_PROTO_RBC)) + (sc->proto & UMASS_PROTO_RBC)) { /* detach the SCSI host controller (SIM) */ err = umass_cam_detach_sim(sc); + } - for (i = 0; i < XFER_NR; i++) + for (i = 0; i < XFER_NR; i++) { if (sc->transfer_xfer[i]) usbd_free_xfer(sc->transfer_xfer[i]); + } /* remove all the pipes */ if (sc->bulkout_pipe) -- 2.41.0