OpenCloudOS-Kernel/drivers/usb/storage
Weitao Wang ce748df0d5 USB: UAS: return ENODEV when submit urbs fail with device not attached
commit cd5432c712351a3d5f82512908f5febfca946ca6 upstream.

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. At this point, usb_hub_wq was already freezed
and can't not handle disconnect event. Next, in the poweroff phase of
hibernation, SYNCHRONIZE_CACHE SCSI command will be sent to this udisk
when poweroff this scsi device, which will cause uas_submit_urbs to be
called to submit URB for sense/data/cmd pipe. However, these URBs will
submit fail as device was set to NOTATTACHED state. Then, uas_submit_urbs
will return a value SCSI_MLQUEUE_DEVICE_BUSY to the caller. That will lead
the SCSI layer go into an ugly loop and system fail to go into hibernation.

On the other hand, when we specially check for -ENODEV in function
uas_queuecommand_lck, returning DID_ERROR to SCSI layer will cause device
poweroff fail and system shutdown instead of entering hibernation.

To fix this issue, let uas_submit_urbs to return original generic error
when submitting URB failed. At the same time, we need to translate -ENODEV
to DID_NOT_CONNECT for the SCSI layer.

Suggested-by: Oliver Neukum <oneukum@suse.com>
Cc: stable@vger.kernel.org
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Link: https://lore.kernel.org/r/20240306180814.4897-1-WeitaoWang-oc@zhaoxin.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-03 15:28:58 +02:00
..
Kconfig
Makefile
alauda.c usb-storage: alauda: Fix uninit-value in alauda_check_media() 2023-08-04 14:57:16 +02:00
cypress_atacb.c
datafab.c
debug.c
debug.h
ene_ub6250.c USB: ene_usb6250: Allocate enough memory for full object 2023-02-06 13:46:42 +01:00
freecom.c
initializers.c
initializers.h
isd200.c USB: usb-storage: Prevent divide-by-0 error in isd200_ata_command 2024-04-03 15:28:42 +02:00
jumpshot.c
karma.c
onetouch.c usb: move from strlcpy with unused retval to strscpy 2022-08-19 11:08:54 +02:00
option_ms.c
option_ms.h
protocol.c
protocol.h
realtek_cr.c
scsiglue.c scsi: sd: usb_storage: uas: Access media prior to querying device properties 2024-03-01 13:34:59 +01:00
scsiglue.h
sddr09.c
sddr55.c
shuttle_usbat.c
sierra_ms.c
sierra_ms.h
transport.c USB: storage: Fix typo in comment 2022-06-21 16:39:42 +02:00
transport.h
uas-detect.h usb-storage: apply IGNORE_UAS only for HIKSEMI MD202 on RTL9210 2023-01-17 16:37:04 +01:00
uas.c USB: UAS: return ENODEV when submit urbs fail with device not attached 2024-04-03 15:28:58 +02:00
unusual_alauda.h
unusual_cypress.h usb: storage: set 1.50 as the lower bcdDevice for older "Super Top" compatibility 2023-11-08 11:56:22 +01:00
unusual_datafab.h
unusual_devs.h usb-storage: Add quirk for incorrect WP on Kingston DT Ultimate 3.0 G3 2024-01-01 12:42:38 +00:00
unusual_ene_ub6250.h
unusual_freecom.h
unusual_isd200.h
unusual_jumpshot.h
unusual_karma.h
unusual_onetouch.h
unusual_realtek.h
unusual_sddr09.h
unusual_sddr55.h
unusual_uas.h uas: Add US_FL_NO_REPORT_OPCODES for JMicron JMS583Gen 2 2023-03-16 12:44:17 +01:00
unusual_usbat.h
usb.c scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
usb.h scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
usual-tables.c