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

From: Jiayi Li

Date: Wed Oct 28 2026 - 05:27:25 EST


Hi,

On Wed, 28 Oct 2026 at 09:48:15 +0100, Oliver Neukum wrote:
> Why? What is it waiting for? And why do you think we can skip
> that wait safely?

The wait is not skipped; it is deferred until after the command
cleanup.

uas_scan_work() calls scsi_scan_host(). In the synchronous scan path,
it may be blocked in scsi_execute_cmd() waiting for the current scan
command, such as INQUIRY or REPORT LUNS, to complete.

On a physical disconnect, USB core disables the interface before
calling uas_disconnect(). The status URB may then complete with
-ESHUTDOWN, and uas_stat_cmplt() exits without clearing
COMMAND_INFLIGHT or completing the SCSI command.

Waiting for scan_work before reaching that cleanup can leave the scan
waiting for SCSI timeout/EH instead.

The first cancel_work() only prevents scan_work from starting if it is
still pending. If scan_work is already running, disconnect proceeds to
cancel the URBs and call uas_zap_pending(), which completes the
remaining command with DID_NO_CONNECT.

The existing cancel_work_sync() is then called after that cleanup and
before scsi_remove_host() and resource release. Therefore the running
scan is still synchronized; the wait is moved after the operation
which allows the scan command to finish, rather than omitted.

Thanks,
Jiayi