linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* usb: uas: unconditionally bring back host after reset
@ 2018-01-11 10:59 Oliver Neukum
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Neukum @ 2018-01-11 10:59 UTC (permalink / raw)
  To: gregKH, linux-usb; +Cc: Oliver Neukum, stable

Quoting Hans:

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.

ENDQUOTE

However, if we do that we better drop any unconditional execution
and report to the SCSI subsystem that we have undergone a reset
but we are not operational now.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reported-by: Hans de Goede <hdegoede@redhat.com>
CC: stable@vger.kernel.org
---
 Makefile                  | 2 +-
 drivers/usb/storage/uas.c | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 7e02f951b284..5025bac05cdb 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 VERSION = 4
 PATCHLEVEL = 15
 SUBLEVEL = 0
-EXTRAVERSION = -rc4
+EXTRAVERSION = -rc4bs0108a
 NAME = Fearless Coyote
 
 # *DOCUMENTATION*
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 5d04c40ee40a..3b1b9695177a 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1076,20 +1076,19 @@ static int uas_post_reset(struct usb_interface *intf)
 		return 0;
 
 	err = uas_configure_endpoints(devinfo);
-	if (err) {
+	if (err && err != ENODEV)
 		shost_printk(KERN_ERR, shost,
 			     "%s: alloc streams error %d after reset",
 			     __func__, err);
-		return 1;
-	}
 
+	/* we must unblock the host in every case lest we deadlock */
 	spin_lock_irqsave(shost->host_lock, flags);
 	scsi_report_bus_reset(shost, 0);
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
 	scsi_unblock_requests(shost);
 
-	return 0;
+	return err ? 1 : 0;
 }
 
 static int uas_suspend(struct usb_interface *intf, pm_message_t message)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* usb: uas: unconditionally bring back host after reset
@ 2018-01-11 11:22 Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2018-01-11 11:22 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: linux-usb, stable

On Thu, Jan 11, 2018 at 11:59:54AM +0100, Oliver Neukum wrote:
> Quoting Hans:
> 
> 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.
> 
> ENDQUOTE
> 
> However, if we do that we better drop any unconditional execution
> and report to the SCSI subsystem that we have undergone a reset
> but we are not operational now.
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> Reported-by: Hans de Goede <hdegoede@redhat.com>
> CC: stable@vger.kernel.org
> ---
>  Makefile                  | 2 +-

I don't think you want me to patch this file :)
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* usb: uas: unconditionally bring back host after reset
@ 2018-01-11 12:10 Oliver Neukum
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Neukum @ 2018-01-11 12:10 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-usb, stable

Am Donnerstag, den 11.01.2018, 12:22 +0100 schrieb Greg KH:
> On Thu, Jan 11, 2018 at 11:59:54AM +0100, Oliver Neukum wrote:
> > 
> > Quoting Hans:
> > 
> > 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.
> > 
> > ENDQUOTE
> > 
> > However, if we do that we better drop any unconditional execution
> > and report to the SCSI subsystem that we have undergone a reset
> > but we are not operational now.
> > 
> > Signed-off-by: Oliver Neukum <oneukum@suse.com>
> > Reported-by: Hans de Goede <hdegoede@redhat.com>
> > CC: stable@vger.kernel.org
> > ---
> >  Makefile                  | 2 +-
> 
> I don't think you want me to patch this file :)

Hi,

sorry, yes, I do not want you to do that.

	Sorry
		Oliver
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* usb: uas: unconditionally bring back host after reset
@ 2018-01-11 12:10 Oliver Neukum
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Neukum @ 2018-01-11 12:10 UTC (permalink / raw)
  To: gregKH, linux-usb; +Cc: Oliver Neukum, stable

Quoting Hans:

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.

ENDQUOTE

However, if we do that we better drop any unconditional execution
and report to the SCSI subsystem that we have undergone a reset
but we are not operational now.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reported-by: Hans de Goede <hdegoede@redhat.com>
CC: stable@vger.kernel.org
---
 drivers/usb/storage/uas.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 5d04c40ee40a..3b1b9695177a 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1076,20 +1076,19 @@ static int uas_post_reset(struct usb_interface *intf)
 		return 0;
 
 	err = uas_configure_endpoints(devinfo);
-	if (err) {
+	if (err && err != ENODEV)
 		shost_printk(KERN_ERR, shost,
 			     "%s: alloc streams error %d after reset",
 			     __func__, err);
-		return 1;
-	}
 
+	/* we must unblock the host in every case lest we deadlock */
 	spin_lock_irqsave(shost->host_lock, flags);
 	scsi_report_bus_reset(shost, 0);
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
 	scsi_unblock_requests(shost);
 
-	return 0;
+	return err ? 1 : 0;
 }
 
 static int uas_suspend(struct usb_interface *intf, pm_message_t message)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-11 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-11 11:22 usb: uas: unconditionally bring back host after reset Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2018-01-11 12:10 Oliver Neukum
2018-01-11 12:10 Oliver Neukum
2018-01-11 10:59 Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).