Re: [PATCH v3] usb: uas: wait for pending commands before unbinding

From: Oliver Neukum

Date: Tue Oct 27 2026 - 10:39:08 EST


Hi,

On 27.10.26 14:14, Jiayi Li wrote:
USB core normally disables interface endpoints before calling
uas_disconnect(), cancelling URBs while the device may still be
processing the associated commands. Some storage bridges may then
fail to recover after a driver rebind and require a disconnect and
reconnect.

[..]

I regret torturing you again, but there is a simple issue left.

static void uas_disconnect(struct usb_interface *intf)
{
struct Scsi_Host *shost = usb_get_intfdata(intf);
struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata;
unsigned long flags;
+ cancel_work(&devinfo->scan_work);

No _sync
+ spin_lock_irqsave(&shost->host_lock, flags);
+ scsi_block_requests(shost);
+ spin_unlock_irqrestore(&shost->host_lock, flags);
+
+ uas_pre_disconnect(intf);
+
spin_lock_irqsave(&devinfo->lock, flags);
devinfo->resetting = 1;
spin_unlock_irqrestore(&devinfo->lock, flags);
+ scsi_unblock_requests(shost);
+
cancel_work_sync(&devinfo->work);

With _sync

I'd say both ought to use cancel_work_sync()

Regards
Oliver