All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: UAS: don't unbind and rebind the driver during usb_reset_device
@ 2021-02-21  8:51 Hui Wang
  2021-02-21 10:20 ` Hans de Goede
  0 siblings, 1 reply; 9+ messages in thread
From: Hui Wang @ 2021-02-21  8:51 UTC (permalink / raw)
  To: linux-usb, hdegoede, oneukum, gregkh; +Cc: hui.wang

Once pre_reset() or post_reset() returns non-zero, the disconnect()
and probe() of the usb_driver will be called. In the disconnect(),
the scsi_host will be removed and be freed after scsi_host_put(), in
the probe(), the new scsi_host and uas_dev_info will be created.

If the usb_reset_device() is triggered by eh_device_reset_handler(),
and pre_reset()/post_reset() returns non-zero, the disconnect() and
probe() will be called, then returns to the eh_device_reset_handler(),
it still accesses old scsi related variables and uas_dev_info, and so
do its caller functions.

Here change the pre_reset() and post_reset() to let them only return
0, after this change, the usb_reset_device() will only reset this
usb devcie from its hub port, will not execute unbind and rebind
usb_driver during reset.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 drivers/usb/storage/uas.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index bef89c6bd1d7..c66287448e34 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1121,7 +1121,6 @@ static int uas_pre_reset(struct usb_interface *intf)
 	if (uas_wait_for_pending_cmnds(devinfo) != 0) {
 		shost_printk(KERN_ERR, shost, "%s: timed out\n", __func__);
 		scsi_unblock_requests(shost);
-		return 1;
 	}
 
 	uas_free_streams(devinfo);
@@ -1152,7 +1151,7 @@ static int uas_post_reset(struct usb_interface *intf)
 
 	scsi_unblock_requests(shost);
 
-	return err ? 1 : 0;
+	return 0;
 }
 
 static int uas_suspend(struct usb_interface *intf, pm_message_t message)
-- 
2.25.1


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

end of thread, other threads:[~2021-02-22 15:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-21  8:51 [PATCH] USB: UAS: don't unbind and rebind the driver during usb_reset_device Hui Wang
2021-02-21 10:20 ` Hans de Goede
2021-02-21 13:23   ` Hui Wang
2021-02-22  7:59   ` Oliver Neukum
2021-02-22 12:40     ` Hui Wang
2021-02-22 12:51       ` Oliver Neukum
2021-02-22 13:02         ` Hui Wang
2021-02-22 13:50           ` Oliver Neukum
2021-02-22 15:14             ` Hui Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.