Do not read the IO hints VPD page from USB storage devices
Subsystems (5)
v3 cover Do not read the IO hints VPD page from USB storage devices
Hi Martin,
Recently it was reported that reading the IO hints VPD page makes at least two USB storage devices crash. Hence this patch series that disables reading the IO hints VPD page from USB storage devices. Please consider this patch series for your scsi-fixes branch.
Thanks,
Bart.
Changes compared to v2:
- Changed "IO hints VPD page" into "IO Advice Hints Grouping mode page".
- Changed "scsi: core: " prefix for patch 2/2 into "usb: ".
- Removed redundant Cc-tags.
Changes compared to v1:
- Also set the BLIST_SKIP_IO_HINTS for USB Attached SCSI devices.
Bart Van Assche (2):
scsi: core: Introduce the BLIST_SKIP_IO_HINTS flag
usb: Do not query the IO advice hints grouping mode page for USB
devices
drivers/scsi/sd.c | 4 ++++ drivers/usb/storage/scsiglue.c | 6 ++++++ drivers/usb/storage/uas.c | 7 +++++++ include/scsi/scsi_devinfo.h | 4 +++- 4 files changed, 20 insertions(+), 1 deletion(-)
PATCH v3 1/2 scsi: core: Introduce the BLIST_SKIP_IO_HINTS flag
Prepare for skipping the IO advice hints grouping mode page for USB storage devices.
--- drivers/scsi/sd.c | 4 ++++ include/scsi/scsi_devinfo.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +4 -0
@@ -63,6 +63,7 @@#include <scsi/scsi_cmnd.h> #include <scsi/scsi_dbg.h> #include <scsi/scsi_device.h> +#include <scsi/scsi_devinfo.h> #include <scsi/scsi_driver.h> #include <scsi/scsi_eh.h> #include <scsi/scsi_host.h>
@@ -3117,6 +3118,9 @@ static void sd_read_io_hints(struct scsi_disk *sdkp, unsigned char *buffer)struct scsi_mode_data data;int res; +if (sdp->sdev_bflags &BLIST_SKIP_IO_HINTS ) +return ; + res =scsi_mode_sense (sdp,/*dbd=*/ 0x8 ,/*modepage=*/ 0x0a ,/*subpage=*/ 0x05 , buffer,SD_BUF_SIZE ,SD_TIMEOUT , sdkp->max_retries, &data, &sshdr);
include/scsi/scsi_devinfo.h +3 -1
@@ -69,8 +69,10 @@#define BLIST_RETRY_ITF ((__force blist_flags_t)(1ULL << 32))/* Always retry ABORTED_COMMAND with ASC 0xc1 */ #define BLIST_RETRY_ASC_C1 ((__force blist_flags_t)(1ULL << 33)) +/* Do not query the IO advice hints grouping mode page */ +#define BLIST_SKIP_IO_HINTS ((__force blist_flags_t)(1ULL << 34)) -#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1 +#define __BLIST_LAST_USED BLIST_SKIP_IO_HINTS#define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \ (__force blist_flags_t) \
PATCH v3 2/2 usb: Do not query the IO advice hints grouping mode page for USB devices
In reply to Bart Van AsscheRecently it was reported that the following USB storage devices are unusable with Linux kernel 6.9:
* Kingston DataTraveler G2
* Garmin FR35
This is because attempting to read the IO advice hints grouping mode page causes these devices to reset. Hence do not read the IO advice hints grouping mode page from USB storage devices.
--- drivers/usb/storage/scsiglue.c | 6 ++++++ drivers/usb/storage/uas.c | 7 +++++++ 2 files changed, 13 insertions(+)
drivers/usb/storage/scsiglue.c +6 -0
@@ -79,6 +79,12 @@ static int slave_alloc (struct scsi_device *sdev)if (us->protocol ==USB_PR_BULK && us->max_lun >0 ) sdev->sdev_bflags |=BLIST_FORCELUN ; +/* +* Some USB storage devices reset if the IO advice hints grouping mode +* page is queried. Hence skip that mode page. +*/ + sdev->sdev_bflags |=BLIST_SKIP_IO_HINTS ; +return 0 ; }
drivers/usb/storage/uas.c +7 -0
@@ -21,6 +21,7 @@#include <scsi/scsi.h> #include <scsi/scsi_eh.h> #include <scsi/scsi_dbg.h> +#include <scsi/scsi_devinfo.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_device.h> #include <scsi/scsi_host.h>
@@ -820,6 +821,12 @@ static int uas_slave_alloc(struct scsi_device *sdev)struct uas_dev_info *devinfo = (struct uas_dev_info *)sdev->host->hostdata; +/* +* Some USB storage devices reset if the IO advice hints grouping mode +* page is queried. Hence skip that mode page. +*/ + sdev->sdev_bflags |=BLIST_SKIP_IO_HINTS ; + sdev->hostdata = devinfo;return 0 ; }
Martin K. Petersen
AppliedQuoted 8 lines · Bart Van Assche
Recently it was reported that reading the IO hints VPD page makes at least two USB storage devices crash. Hence this patch series that disables reading the IO hints VPD page from USB storage devices. Please consider this patch series for your scsi-fixes branch.
Thanks,
[...]
Applied to 6.10/scsi-fixes, thanks!
[1/2] scsi: core: Introduce the BLIST_SKIP_IO_HINTS flag
https://git.kernel.org/mkp/scsi/c/633aeefafc9c [2/2] usb: Do not query the IO advice hints grouping mode page for USB devices https://git.kernel.org/mkp/scsi/c/57619f3cdeb5
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering