Skip to contentSkip to conversation

USB: UAS: introduce a quirk to set no_write_same

PATCH Superseded Oliver Neukum 3 participants 3 messages Dec 9, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Oliver Neukum

author maintainer
#0 lore raw

PATCH 1/1 USB: UAS: introduce a quirk to set no_write_same

UAS does not share the pessimistic assumption storage is making that devices cannot deal with WRITE_SAME. A few devices supported by UAS, are reported to not deal well with WRITE_SAME. Those need a quirk.

Add it to the device that needs it.

---
 drivers/usb/storage/uas.c         | 3 +++
 drivers/usb/storage/unusual_uas.h | 7 +++++--
 drivers/usb/storage/usb.c         | 3 +++
 include/linux/usb_usual.h         | 2 ++
 4 files changed, 13 insertions(+), 2 deletions(-)
drivers/usb/storage/uas.c +3 -0
index 56422c4b4ff3..bef89c6bd1d7 100644
@@ -868,6 +868,9 @@ static int uas_slave_configure(struct scsi_device *sdev)
 	if (devinfo->flags & US_FL_NO_READ_CAPACITY_16)
 		sdev->no_read_capacity_16 = 1;
 
+	/* Some disks cannot handle WRITE_SAME */
+	if (devinfo->flags & US_FL_NO_SAME)
+		sdev->no_write_same = 1;
 	/*
 	 * Some disks return the total number of blocks in response
 	 * to READ CAPACITY rather than the highest block number.
drivers/usb/storage/unusual_uas.h +5 -2
index 711ab240058c..870e9cf3d5dc 100644
@@ -35,12 +35,15 @@ UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999,
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_NO_REPORT_OPCODES),
 
-/* Reported-by: Julian Groß <[email protected]> */
+/*
+ *  Initially Reported-by: Julian Groß <[email protected]>
+ *  Further reports David C. Partridge <[email protected]>
+ */
 UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
 		"LaCie",
 		"2Big Quadra USB3",
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-		US_FL_NO_REPORT_OPCODES),
+		US_FL_NO_REPORT_OPCODES | US_FL_NO_SAME),
 
 /*
  * Apricorn USB3 dongle sometimes returns "USBSUSBSUSBS" in response to SCSI
drivers/usb/storage/usb.c +3 -0
index 94a64729dc27..90aa9c12ffac 100644
@@ -541,6 +541,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
 		case 'j':
 			f |= US_FL_NO_REPORT_LUNS;
 			break;
+		case 'k':
+			f |= US_FL_NO_SAME;
+			break;
 		case 'l':
 			f |= US_FL_NOT_LOCKABLE;
 			break;
include/linux/usb_usual.h +2 -0
index 4a19ac3f24d0..6b03fdd69d27 100644
@@ -84,6 +84,8 @@
 		/* Cannot handle REPORT_LUNS */			\
 	US_FLAG(ALWAYS_SYNC, 0x20000000)			\
 		/* lies about caching, so always sync */	\
+	US_FLAG(NO_SAME, 0x40000000)				\
+		/* Cannot handle WRITE_SAME */			\
 
 #define US_FLAG(name, value)	US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 57 lines · Oliver Neukum

UAS does not share the pessimistic assumption storage is making that devices cannot deal with WRITE_SAME. A few devices supported by UAS, are reported to not deal well with WRITE_SAME. Those need a quirk.

Add it to the device that needs it.

---
 drivers/usb/storage/uas.c         | 3 +++
 drivers/usb/storage/unusual_uas.h | 7 +++++--
 drivers/usb/storage/usb.c         | 3 +++
 include/linux/usb_usual.h         | 2 ++
 4 files changed, 13 insertions(+), 2 deletions(-)
drivers/usb/storage/uas.c +3 -0
index 56422c4b4ff3..bef89c6bd1d7 100644
@@ -868,6 +868,9 @@ static int uas_slave_configure(struct scsi_device *sdev)
 	if (devinfo->flags & US_FL_NO_READ_CAPACITY_16)
 		sdev->no_read_capacity_16 = 1;
 
+	/* Some disks cannot handle WRITE_SAME */
+	if (devinfo->flags & US_FL_NO_SAME)
+		sdev->no_write_same = 1;
 	/*
 	 * Some disks return the total number of blocks in response
 	 * to READ CAPACITY rather than the highest block number.
drivers/usb/storage/unusual_uas.h +5 -2
index 711ab240058c..870e9cf3d5dc 100644
@@ -35,12 +35,15 @@ UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999,
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_NO_REPORT_OPCODES),
 
-/* Reported-by: Julian Groß <[email protected]> */
+/*
+ *  Initially Reported-by: Julian Groß <[email protected]>
+ *  Further reports David C. Partridge <[email protected]>
+ */
 UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
 		"LaCie",
 		"2Big Quadra USB3",
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-		US_FL_NO_REPORT_OPCODES),
+		US_FL_NO_REPORT_OPCODES | US_FL_NO_SAME),
 
 /*
  * Apricorn USB3 dongle sometimes returns "USBSUSBSUSBS" in response to SCSI
drivers/usb/storage/usb.c +0 -0
index 94a64729dc27..90aa9c12ffac 100644

drivers/usb/storage/usb.c void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags) · line 546

Quoted 6 lines
drivers/usb/storage/usb.c +3 -0
@@ -541,6 +541,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
 		case 'j':
 			f |= US_FL_NO_REPORT_LUNS;
 			break;
+		case 'k':
+			f |= US_FL_NO_SAME;
+			break;

Shouldn't this new flag be documented somewhere?

thanks,

greg k-h

#2 lore raw

Probably here:

https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

in the usb-storage.quirks section?

I assume there's also a header file that defines all this stuff?

David

-----Original Message-----
From: Greg KH <[email protected]>
Sent: 09 December 2020 12:04
To: Oliver Neukum <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] USB: UAS: introduce a quirk to set no_write_same

drivers/usb/storage/uas.c static int uas_slave_configure(struct scsi_device

Quoted 21 lines · Oliver Neukum

UAS does not share the pessimistic assumption storage is making that devices cannot deal with WRITE_SAME. A few devices supported by UAS, are reported to not deal well with WRITE_SAME. Those need a quirk.

Add it to the device that needs it.

---
 drivers/usb/storage/uas.c         | 3 +++
 drivers/usb/storage/unusual_uas.h | 7 +++++--
 drivers/usb/storage/usb.c         | 3 +++
 include/linux/usb_usual.h         | 2 ++
 4 files changed, 13 insertions(+), 2 deletions(-)
drivers/usb/storage/uas.c +0 -0
index 56422c4b4ff3..bef89c6bd1d7 100644
@@ -868,6 +868,9 @@ static int uas_slave_configure(struct scsi_device

*sdev)

Review

Quoted 10 lines
drivers/usb/storage/uas.c +3 -0
 	if (devinfo->flags & US_FL_NO_READ_CAPACITY_16)
 		sdev->no_read_capacity_16 = 1;
 
+	/* Some disks cannot handle WRITE_SAME */
+	if (devinfo->flags & US_FL_NO_SAME)
+		sdev->no_write_same = 1;
 	/*
 	 * Some disks return the total number of blocks in response
 	 * to READ CAPACITY rather than the highest block number.
(quoted diff) +0 -0

b/drivers/usb/storage/unusual_uas.h

Quoted 11 lines

index 711ab240058c..870e9cf3d5dc 100644

drivers/usb/storage/unusual_uas.h +3 -1
@@ -35,12 +35,15 @@ UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999,
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_NO_REPORT_OPCODES),
 
-/* Reported-by: Julian Groß <[email protected]> */
+/*
+ *  Initially Reported-by: Julian Groß <[email protected]>
+ *  Further reports David C. Partridge <[email protected]>

drivers/usb/storage/unusual_uas.h UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999, · line 49

Quoted 10 lines
drivers/usb/storage/unusual_uas.h +2 -1
+ */
 UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
 		"LaCie",
 		"2Big Quadra USB3",
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-		US_FL_NO_REPORT_OPCODES),
+		US_FL_NO_REPORT_OPCODES | US_FL_NO_SAME),
 
 /*
  * Apricorn USB3 dongle sometimes returns "USBSUSBSUSBS" in response to

SCSI

drivers/usb/storage/usb.c void usb_stor_adjust_quirks(struct usb_device *udev,

Quoted 5 lines
drivers/usb/storage/usb.c +0 -0
index 94a64729dc27..90aa9c12ffac 100644
@@ -541,6 +541,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev,

unsigned long *fflags)

drivers/usb/storage/usb.c void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags) · line 546

Quoted 6 lines
drivers/usb/storage/usb.c +3 -0
 		case 'j':
 			f |= US_FL_NO_REPORT_LUNS;
 			break;
+		case 'k':
+			f |= US_FL_NO_SAME;
+			break;

Shouldn't this new flag be documented somewhere?

thanks,

greg k-h