diff mbox series

scsi: core: Do not query the IO hints for a particular USB device

Message ID 20240607011651.1618706-1-bvanassche@acm.org (mailing list archive)
State Changes Requested
Headers show
Series scsi: core: Do not query the IO hints for a particular USB device | expand

Commit Message

Bart Van Assche June 7, 2024, 1:16 a.m. UTC
Recently it was reported that Kingston DataTraveler G2 USB devices are
unusable with 6.9.x kernels. Hence this patch that skips reading the IO
hints VPD page for these USB devices.

Cc: Joao Machado <jocrismachado@gmail.com>
Cc: stable@vger.kernel.org
Fixes: 4f53138fffc2 ("scsi: sd: Translate data lifetime information")
Reported-by: Joao Machado <jocrismachado@gmail.com>
Closes: https://lore.kernel.org/linux-scsi/CACLx9VdpUanftfPo2jVAqXdcWe8Y43MsDeZmMPooTzVaVJAh2w@mail.gmail.com/
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_devinfo.c | 1 +
 drivers/scsi/sd.c           | 4 ++++
 include/scsi/scsi_devinfo.h | 4 +++-
 3 files changed, 8 insertions(+), 1 deletion(-)

Comments

Avri Altman June 7, 2024, 6:29 a.m. UTC | #1
> Recently it was reported that Kingston DataTraveler G2 USB devices are unusable
> with 6.9.x kernels. Hence this patch that skips reading the IO hints VPD page for
> these USB devices.
> 
> Cc: Joao Machado <jocrismachado@gmail.com>
> Cc: stable@vger.kernel.org
> Fixes: 4f53138fffc2 ("scsi: sd: Translate data lifetime information")
> Reported-by: Joao Machado <jocrismachado@gmail.com>
> Closes: https://lore.kernel.org/linux-
> scsi/CACLx9VdpUanftfPo2jVAqXdcWe8Y43MsDeZmMPooTzVaVJAh2w@mail.gmai
> l.com/
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/scsi_devinfo.c | 1 +
>  drivers/scsi/sd.c           | 4 ++++
>  include/scsi/scsi_devinfo.h | 4 +++-
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index
> a7071e71389e..85111e14c53b 100644
> --- a/drivers/scsi/scsi_devinfo.c
> +++ b/drivers/scsi/scsi_devinfo.c
> @@ -197,6 +197,7 @@ static struct {
>         {"INSITE", "I325VM", NULL, BLIST_KEY},
>         {"Intel", "Multi-Flex", NULL, BLIST_NO_RSOC},
>         {"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE |
> BLIST_INQUIRY_36},
> +       {"Kingston", "DataTraveler G2", NULL, BLIST_SKIP_IO_HINTS},
>         {"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN},
>         {"Marvell", "Console", NULL, BLIST_SKIP_VPD_PAGES},
>         {"Marvell", "91xx Config", "1.01", BLIST_SKIP_VPD_PAGES}, diff --git
The comment above __initdata say:
"...
* Do not add to this list, use the command line or proc interface to add
 * to the scsi_dev_info_list. This table will eventually go away.
..."

Thanks,
Avri

> a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3a43e2209751..fcf3d7730466
> 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -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); diff --git
> a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h index
> 6b548dc2c496..fa8721e49dec 100644
> --- a/include/scsi/scsi_devinfo.h
> +++ b/include/scsi/scsi_devinfo.h
> @@ -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 read the I/O hints 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) \
Bart Van Assche June 7, 2024, 9:29 p.m. UTC | #2
On 6/7/24 00:29, Avri Altman wrote:
> The comment above __initdata say:
> "...
> * Do not add to this list, use the command line or proc interface to add
>   * to the scsi_dev_info_list. This table will eventually go away.
> ..."

Is that comment perhaps incorrect? That comment was added before 2005 (I do
not have access to the kernel history before 2005). Since 2005, 84 entries
have been added in the scsi_dev_info_list:

$ git log -p 1da177e4c3f4.. drivers/scsi/scsi_devinfo.c | grep '^+.*, BLIST_' | wc
84

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index a7071e71389e..85111e14c53b 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -197,6 +197,7 @@  static struct {
 	{"INSITE", "I325VM", NULL, BLIST_KEY},
 	{"Intel", "Multi-Flex", NULL, BLIST_NO_RSOC},
 	{"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
+	{"Kingston", "DataTraveler G2", NULL, BLIST_SKIP_IO_HINTS},
 	{"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN},
 	{"Marvell", "Console", NULL, BLIST_SKIP_VPD_PAGES},
 	{"Marvell", "91xx Config", "1.01", BLIST_SKIP_VPD_PAGES},
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3a43e2209751..fcf3d7730466 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -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);
diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index 6b548dc2c496..fa8721e49dec 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -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 read the I/O hints 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) \