Re: [PATCH] USB:UAS:return ENODEV when submit urbs fail with device not attached.

From: WeitaoWang-oc@xxxxxxxxxxx
Date: Thu Feb 22 2024 - 07:07:12 EST


On 2024/2/22 17:47, Oliver Neukum wrote:


On 22.02.24 17:54, Weitao Wang wrote:
In the scenario of entering hibernation with udisk in the system, if the
udisk was gone or resume fail in the thaw phase of hibernation. Its state
will be set to NOTATTACHED. However, usb_hub_wq was already freezed and
can't not handle disconnect event. Then, sync cache SCSI command will be
sent to this udisk on the poweroff phase of hibernation, that will cause

Wait, this seems like a contradiction. Are we in thaw or are we powering off?

This fail appear in poweroff phase of hibernation.

uas_submit_urbs to be called to submit URB to sense/data/cmd pipe. Then,
usb_submit_urb return value -ENODEV when device was set to NOTATTACHED
state. However, uas_submit_urbs always return "SCSI_MLQUEUE_DEVICE_BUSY"
regardless of the reason for submission failure.That will lead the SCSI
layer go into an ugly loop and system fail to go into hibernation.

The thing is that the SCSI documentation explicitly tells us to return
either SCSI_MLQUEUE_DEVICE_BUSY or SCSI_MLQUEUE_HOST_BUSY. Now, it makes
sense to tell the SCSI laer that a device or host is gone for good,
if we know that. But we cannot just introduce new error returns on our own.

This needs to be addressed. That means that the SCSI layer or at the
very least the documentation needs to be fixed. Frankly, this is not strictly
speaking a UAS issue. Any thing hotunpluggable should have this issue.


Maybe, my description was not accurate enough, here not add new return
value to scsi layer,it just add a case to tell device is gone in the uas
driver internal and the ENODEV error code not return to scsi layer.
Here just notify SCSI layer of device loss through flag DID_NO_CONNECT.
This is also hope to fix this issue in the uas driver internal.

Thanks and best regards,
weitao