RE: [PATCH] usb: uas: fix a plug & unplug racing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Oliver Neukum wrote:

> Am Dienstag, den 14.01.2020, 10:04 -0500 schrieb Alan Stern:
> >
> > No.  The discussion has gotten a little confused.  EJ's point is that
> > if SCSI scanning takes place in the context of the hub worker thread,
> > then that thread won't be available to process a disconnect
> > notification.  The device will be unplugged, but the kernel won't
> > realize it until the SCSI scanning is finished.
> 
> OK, I think we have two possible code paths at least
> 
> First:
> uas_queuecommand_lck() -> uas_submit_urbs() -> -ENODEV -> return
> SCSI_MLQUEUE_DEVICE_BUSY
> 
> That looks wrong to me.
> 
> Second:
> The submission actually works and we eventually terminate the URB with an
> error. In that case nothing happens and eventually SCSI core retries, times out
> and does error handling.
> 
Actually, the second case might happen when we connect uas disk directly to 
root hub. In this case, the root hub thread got stuck waiting for the completion
of the scsi command. It might not be able to handle the disconnection event
and set uas disk state to USB_STATE_NOTATTACHED accordingly.

So, the URB submission in uas driver works but nothing happens, and scsi layer
will time out this operation and retry it several times. Eventually the root hub 
thread will continue to run when it got the result from scsi layer. But the whole
process might take about 60 seconds.

That's another reason why I would like to run scsi_scan_host() asynchronously
and keep the hub thread free.

> > In my opinion, if scsi_scan_host() will be run asynchronously, this 
> > interface needs to be guarded against runtime PM between uas_probe() & uas_scan_work().
> Yes it does. But it has a child, the SCSI host, which has an elevated count. It is already guarded.

I just checked the code, and the reference count will be incremented in scsi_scan_host(), 
precisely speaking, in scsi_autopm_get_host().
So, I still think we need to manually add reference count of interface here.
Please correct me if there is anything wrong.

Thanks,
EJ
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux