From: Oliver Neukum <oneukum@suse.com>
To: Jiayi Li <lijiayi@kylinos.cn>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Michal Pecio <michal.pecio@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-scsi@vger.kernel.org,
usb-storage@lists.one-eyed-alien.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] usb: uas: wait for pending commands before unbinding
Date: Mon, 26 Oct 2026 13:56:54 +0100 [thread overview]
Message-ID: <e6009e1b-2d95-4350-8374-d5930200ed24@suse.com> (raw)
In-Reply-To: <20261023013931.388916-1-lijiayi@kylinos.cn>
Hi,
On 23.10.26 03:39, Jiayi Li wrote:
> USB core normally disables interface endpoints before calling
> uas_disconnect(). This cancels pending URBs while the device may still
> be processing the associated commands. Some storage bridges then stop
> responding after a driver rebind and need a disconnect and reconnect
> to recover.
I am afraid there are some issues left. Let me address them inline
to the code.
> +static void uas_pre_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 start_time;
> +
> + start_time = jiffies;
> + for (;;) {
> + if (READ_ONCE(devinfo->udev->state) == USB_STATE_NOTATTACHED)
> + return;
> +
> + flush_work(&devinfo->work);
This raises two questions:
1. If an error happens while disconnect is running, why do we want to schedule
work?
2. Why only this and not also scan_work?
> + if (!usb_wait_anchor_empty_timeout(&devinfo->sense_urbs, 5000))
> + break;
Some commands run longer
> + if (!usb_wait_anchor_empty_timeout(&devinfo->data_urbs, 500))
> + break;
> +
> + if (time_after(jiffies, start_time + 5 * HZ))
> + break;
> + if (uas_cmnd_list_empty(devinfo))
> + return;
> +
> + msleep(20);
> + }
> +
> + shost_printk(KERN_ERR, shost, "%s: timed out\n", __func__);
> +}
> +
> 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;
>
> + 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);
Is the resetting flag even needed anymore?
If it is needed, why set it so late?
Regards
Oliver
prev parent reply other threads:[~2026-10-26 12:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 1:39 Jiayi Li
2026-10-26 12:56 ` Oliver Neukum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e6009e1b-2d95-4350-8374-d5930200ed24@suse.com \
--to=oneukum@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=lijiayi@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michal.pecio@gmail.com \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®