diff mbox

uas: Unblock scsi-requests on failure to alloc streams in post_reset

Message ID 20180110071323.3183-1-hdegoede@redhat.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Hans de Goede Jan. 10, 2018, 7:13 a.m. UTC
If we return 1 from our post_reset handler, then our disconnect handler
will be called immediately afterwards. Since pre_reset blocks all scsi
requests our disconnect handler will then hang in the scsi_remove_host
call.

This is esp. bad because our disconnect handler hanging for ever also
stops the USB subsys from enumerating any new USB devices, causes commands
like lsusb to hang, etc.

In practice this happens when unplugging some uas devices because the hub
code may see the device as needing a warm-reset and calls usb_reset_device
before seeing the disconnect. In this case uas_configure_endpoints fails
with -ENODEV. We do not want to print an error for this, so this commit
also silences the shost_printk for -ENODEV.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1531966
Cc: stable@vger.kernel.org
Fixes: 8d51444cdd06 ("uas: Not being able to alloc streams ... is an error")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/usb/storage/uas.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 5d04c40ee40a..5471422aa1ab 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1077,9 +1077,13 @@  static int uas_post_reset(struct usb_interface *intf)
 
 	err = uas_configure_endpoints(devinfo);
 	if (err) {
-		shost_printk(KERN_ERR, shost,
-			     "%s: alloc streams error %d after reset",
-			     __func__, err);
+		if (err != -ENODEV) {
+			shost_printk(KERN_ERR, shost,
+				     "%s: alloc streams error %d after reset",
+				     __func__, err);
+		}
+		/* So that scsi_remove_host in uas_disconnect does not hang */
+		scsi_unblock_requests(shost);
 		return 1;
 	}