NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/51129: Disconnecting USB SD card without umount causes file operations to hang
Does this patch fix things for you?
Thanks,
Nick
Index: sys/dev/usb/umass.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umass.c,v
retrieving revision 1.157
diff -u -p -w -b -r1.157 umass.c
--- sys/dev/usb/umass.c 21 Nov 2016 08:27:30 -0000 1.157
+++ sys/dev/usb/umass.c 22 Apr 2017 05:34:54 -0000
@@ -796,6 +796,10 @@ umass_detach(device_t self, int flags)
DPRINTFM(UDMASS_USB, "sc %p detached", sc, 0, 0, 0);
+ mutex_enter(&sc->sc_lock);
+ sc->sc_dying = true;
+ mutex_exit(&sc->sc_lock);
+
pmf_device_deregister(self);
/* Abort the pipes to wake up any waiting processes. */
@@ -1156,9 +1160,6 @@ umass_bbb_state(struct usbd_xfer *xfer,
"sc->sc_wire == 0x%02x wrong for umass_bbb_state\n",
sc->sc_wire);
- if (sc->sc_dying)
- return;
-
/*
* State handling for BBB transfers.
*
@@ -1173,6 +1174,18 @@ umass_bbb_state(struct usbd_xfer *xfer,
DPRINTFM(UDMASS_BBB, "sc %p xfer %p, transfer_state %d dir %d", sc,
xfer, sc->transfer_state, sc->transfer_dir);
+ if (err == USBD_CANCELLED) {
+ DPRINTFM(UDMASS_BBB, "sc %p xfer %p cancelled", sc,
+ xfer, 0, 0);
+
+ sc->transfer_state = TSTATE_IDLE;
+ sc->transfer_cb(sc, sc->transfer_priv, 0, STATUS_TIMEOUT);
+ return;
+ }
+
+ if (sc->sc_dying)
+ return;
+
switch (sc->transfer_state) {
/***** Bulk Transfer *****/
@@ -1609,6 +1622,13 @@ umass_cbi_state(struct usbd_xfer *xfer,
"sc->sc_wire == 0x%02x wrong for umass_cbi_state\n",
sc->sc_wire);
+ if (err == USBD_CANCELLED) {
+ DPRINTFM(UDMASS_BBB, "sc %p xfer %p cancelled", sc, xfer, 0, 0);
+ sc->transfer_state = TSTATE_IDLE;
+ sc->transfer_cb(sc, sc->transfer_priv, 0, STATUS_TIMEOUT);
+ return;
+ }
+
if (sc->sc_dying)
return;
Index: sys/dev/usb/umass_scsipi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umass_scsipi.c,v
retrieving revision 1.54
diff -u -p -w -b -r1.54 umass_scsipi.c
--- sys/dev/usb/umass_scsipi.c 21 Nov 2016 08:27:30 -0000 1.54
+++ sys/dev/usb/umass_scsipi.c 22 Apr 2017 05:34:54 -0000
@@ -444,6 +444,10 @@ umass_scsipi_cb(struct umass_softc *sc,
xs->error = XS_RESET;
break;
+ case STATUS_TIMEOUT:
+ xs->error = XS_TIMEOUT;
+ break;
+
default:
panic("%s: Unknown status %d in umass_scsipi_cb",
device_xname(sc->sc_dev), status);
Index: sys/dev/usb/umassvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umassvar.h,v
retrieving revision 1.38
diff -u -p -w -b -r1.38 umassvar.h
--- sys/dev/usb/umassvar.h 3 Jul 2016 07:27:37 -0000 1.38
+++ sys/dev/usb/umassvar.h 22 Apr 2017 05:34:54 -0000
@@ -135,6 +135,7 @@ typedef void (*umass_callback)(struct um
#define STATUS_CMD_UNKNOWN 1 /* will have to fetch sense */
#define STATUS_CMD_FAILED 2 /* transfer was ok, command failed */
#define STATUS_WIRE_FAILED 3 /* couldn't even get command across */
+#define STATUS_TIMEOUT 4 /* transfer aborted */
typedef void (*umass_wire_xfer)(struct umass_softc *, int, void *, int, void *,
int, int, u_int, int, umass_callback, void *);
Home |
Main Index |
Thread Index |
Old Index