linux-stable/drivers/usb/storage
Martin K. Petersen 321da3dc1f scsi: sd: usb_storage: uas: Access media prior to querying device properties
It has been observed that some USB/UAS devices return generic properties
hardcoded in firmware for mode pages for a period of time after a device
has been discovered. The reported properties are either garbage or they do
not accurately reflect the characteristics of the physical storage device
attached in the case of a bridge.

Prior to commit 1e029397d1 ("scsi: sd: Reorganize DIF/DIX code to
avoid calling revalidate twice") we would call revalidate several
times during device discovery. As a result, incorrect values would
eventually get replaced with ones accurately describing the attached
storage. When we did away with the redundant revalidate pass, several
cases were reported where devices reported nonsensical values or would
end up in write-protected state.

An initial attempt at addressing this issue involved introducing a
delayed second revalidate invocation. However, this approach still
left some devices reporting incorrect characteristics.

Tasos Sahanidis debugged the problem further and identified that
introducing a READ operation prior to MODE SENSE fixed the problem and that
it wasn't a timing issue. Issuing a READ appears to cause the devices to
update their state to reflect the actual properties of the storage
media. Device properties like vendor, model, and storage capacity appear to
be correctly reported from the get-go. It is unclear why these devices
defer populating the remaining characteristics.

Match the behavior of a well known commercial operating system and
trigger a READ operation prior to querying device characteristics to
force the device to populate the mode pages.

The additional READ is triggered by a flag set in the USB storage and
UAS drivers. We avoid issuing the READ for other transport classes
since some storage devices identify Linux through our particular
discovery command sequence.

Link: https://lore.kernel.org/r/20240213143306.2194237-1-martin.petersen@oracle.com
Fixes: 1e029397d1 ("scsi: sd: Reorganize DIF/DIX code to avoid calling revalidate twice")
Cc: stable@vger.kernel.org
Reported-by: Tasos Sahanidis <tasos@tasossah.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Tasos Sahanidis <tasos@tasossah.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-14 12:46:47 -05:00
..
alauda.c usb-storage: alauda: Fix uninit-value in alauda_check_media() 2023-08-04 14:57:16 +02:00
cypress_atacb.c scsi: core: Remove the cmd field from struct scsi_request 2022-03-01 22:21:49 -05:00
datafab.c
debug.c scsi: Remove drivers/scsi/scsi.h 2022-02-22 21:11:02 -05:00
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-storage: isd200: fix initFunction error return 2022-04-21 19:02:42 +02:00
jumpshot.c
karma.c USB: storage: karma: fix rio_karma_init return 2022-04-21 19:03:26 +02:00
Kconfig
Makefile
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 USB: storage: ums-realtek: fix error code in rts51x_read_mem() 2022-03-15 18:21:25 +01:00
scsiglue.c scsi: sd: usb_storage: uas: Access media prior to querying device properties 2024-02-14 12:46:47 -05:00
scsiglue.h
sddr09.c
sddr55.c
shuttle_usbat.c usb-storage: shuttle_usbat: fix initFunction error return 2022-04-21 19:02:40 +02:00
sierra_ms.c usb: storage: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() 2023-12-15 13:55:30 +01:00
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,uas: make internal quirks flags 64bit 2023-10-21 12:45:14 +02:00
uas.c scsi: sd: usb_storage: uas: Access media prior to querying device properties 2024-02-14 12:46:47 -05:00
unusual_alauda.h
unusual_cypress.h usb: storage: set 1.50 as the lower bcdDevice for older "Super Top" compatibility 2023-10-28 12:23:41 +02:00
unusual_datafab.h
unusual_devs.h usb-storage: Add quirk for incorrect WP on Kingston DT Ultimate 3.0 G3 2023-12-15 14:00:58 +01: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 usb-storage,uas: make internal quirks flags 64bit 2023-10-21 12:45:14 +02:00
usb.h usb-storage,uas: make internal quirks flags 64bit 2023-10-21 12:45:14 +02:00
usual-tables.c usb-storage,uas: make internal quirks flags 64bit 2023-10-21 12:45:14 +02:00