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
The following reply was made to PR kern/51129; it has been noted by GNATS.
From: Nick Hudson <skrll%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost, kern-bug-people%netbsd.org@localhost,
gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Cc:
Subject: Re: kern/51129: Disconnecting USB SD card without umount causes file
operations to hang
Date: Sat, 22 Apr 2017 06:37:50 +0100
This is a multi-part message in MIME format.
--------------050605020508030409040902
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
Does this patch fix things for you?
Thanks,
Nick
--------------050605020508030409040902
Content-Type: text/x-patch;
name="pr51129.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="pr51129.diff"
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 *);
--------------050605020508030409040902--
Home |
Main Index |
Thread Index |
Old Index