Skip to contentSkip to conversation

usb: uas: expose US_FL_NO_ATA_1X in sysfs as ata_passthrough_disabled

PATCH In review Mateusz Jończyk 4 participants 8 messages Nov 21 – Nov 23

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 usb: uas: expose US_FL_NO_ATA_1X in sysfs as ata_passthrough_disabled

The uas driver blocks access to ATA passthrough commands for some devices it considers buggy. However, it does not expose any meaningful information whether the command was disabled by the driver or is genuinly not supported by the hardware. This creates a problem for the smartmontools program and makes it difficult for it to provide a useful error message.

---

v2:
- rename the attribute to ata_passthrough_disabled (to match others),
- add a proper documentation,
- add the ABI documentation for scsi to MAINTAINERS as appropriate,
- add a second patch to expose the information also for the usb-storage driver,

---
 .../ABI/testing/sysfs-class-scsi_device       | 10 ++++++++++
 MAINTAINERS                                   |  1 +
 drivers/usb/storage/uas.c                     | 20 +++++++++++++++++++
 3 files changed, 31 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-scsi_device
Documentation/ABI/testing/sysfs-class-scsi_device new file +10 -0
new file mode 100644
index 000000000000..4dc8645bf59b
@@ -0,0 +1,10 @@
+What:		/sys/class/scsi_device/*/device/ata_passthrough_disabled
+Date:		Nov, 2026
+KernelVersion:	v7.5
+Contact:	[email protected]
+Description:	(RO) Indicates whether the driver blocks access from userspace
+		to ATA passthrough commands. Contains a value of '1' when such
+		commands are denied as the hardware is considered buggy and they
+		might interfere with a correct operation of the drive. Note that
+		a value of '0' does not necessarily mean that ATA passthrough is
+		available as it may not be supported by the hardware at all.
MAINTAINERS +1 -0
index ccbcdc0799b9..d056984f4998 100644
@@ -25293,6 +25293,7 @@ S:	Maintained
 Q:	https://patchwork.kernel.org/project/linux-scsi/list/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+F:	Documentation/ABI/testing/sysfs-class-scsi_*
 F:	Documentation/devicetree/bindings/scsi/
 F:	drivers/scsi/
 F:	drivers/ufs/
drivers/usb/storage/uas.c +20 -0
index 8655edbd66b1..49481bfca34c 100644
@@ -910,6 +910,25 @@ static int uas_sdev_configure(struct scsi_device *sdev,
 	return 0;
 }
 
+/* Sysfs interface */
+static ssize_t ata_passthrough_disabled_show(struct device *dev, struct device_attribute *attr,
+					     char *buf)
+{
+	struct scsi_device *sdev = to_scsi_device(dev);
+	struct uas_dev_info *devinfo = sdev->hostdata;
+
+	return sysfs_emit(buf, "%d\n", !!(devinfo->flags & US_FL_NO_ATA_1X));
+}
+
+static DEVICE_ATTR_RO(ata_passthrough_disabled);
+
+static struct attribute *uas_sdev_attrs[] = {
+	&dev_attr_ata_passthrough_disabled.attr,
+	NULL,
+};
+
+ATTRIBUTE_GROUPS(uas_sdev);
+
 static const struct scsi_host_template uas_host_template = {
 	.module = THIS_MODULE,
 	.name = "uas",
@@ -929,6 +948,7 @@ static const struct scsi_host_template uas_host_template = {
 	.dma_alignment = 511,
 	.dma_boundary = PAGE_SIZE - 1,
 	.cmd_size = sizeof(struct uas_cmd_info),
+	.sdev_groups = uas_sdev_groups,
 };
 
 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
Signature · 1 line
2.47.3
#1 lore raw

PATCH 2/2 usb: mass storage: expose ata_passthrough_disabled in sysfs

The mass storage driver blocks access to ATA passthrough commands for some devices it considers buggy. As in the case of the uas driver, indicate this in sysfs.

---

v2:
- add this patch to the series

---
 drivers/usb/storage/scsiglue.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/usb/storage/scsiglue.c +13 -0
index 97de28e85562..43198888449e 100644
@@ -572,6 +572,18 @@ US_DO_ALL_FLAGS
  * Sysfs interface
  ***********************************************************************/
 
+/* Output routine for the sysfs ata_passthrough_disabled file */
+static ssize_t ata_passthrough_disabled_show(struct device *dev, struct device_attribute *attr,
+					     char *buf)
+{
+	struct scsi_device *sdev = to_scsi_device(dev);
+	struct us_data *us = host_to_us(sdev->host);
+
+	return sysfs_emit(buf, "%d\n", !!(us->fflags & US_FL_NO_ATA_1X));
+}
+
+static DEVICE_ATTR_RO(ata_passthrough_disabled);
+
 /* Output routine for the sysfs max_sectors file */
 static ssize_t max_sectors_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -602,6 +614,7 @@ static ssize_t max_sectors_store(struct device *dev, struct device_attribute *at
 static DEVICE_ATTR_RW(max_sectors);
 
 static struct attribute *usb_sdev_attrs[] = {
+	&dev_attr_ata_passthrough_disabled.attr,
 	&dev_attr_max_sectors.attr,
 	NULL,
 };
Signature · 1 line
2.47.3
maintainer
#3 lore raw
In reply to Mateusz Jończyk
Quoted 6 lines · Mateusz Jończyk

The uas driver blocks access to ATA passthrough commands for some devices it considers buggy. However, it does not expose any meaningful information whether the command was disabled by the driver or is genuinly not supported by the hardware. This creates a problem for the smartmontools program and makes it difficult for it to provide a useful error message.

Hi,

thank you for handling this. One thing though. This requires putting the emit code into every driver. Can we centralize that somehow?

Regards
Oliver

#4 lore raw

W dniu 23.11.2026 o 09:27, Oliver Neukum pisze:

Quoted 11 lines · Mateusz Jończyk
Quoted 6 lines

The uas driver blocks access to ATA passthrough commands for some devices it considers buggy. However, it does not expose any meaningful information whether the command was disabled by the driver or is genuinly not supported by the hardware. This creates a problem for the smartmontools program and makes it difficult for it to provide a useful error message.

Hi,

thank you for handling this. One thing though. This requires putting the emit code into every driver. Can we centralize that somehow?

Not really, short of moving the handling of the ata_passthrough_disabled attribute into the middle SCSI layer (which would also likely involve moving the whole of US_FL_NO_ATA_1X logic from uas_queuecommand_lck() there). Is this what you mean?

This attribute is really specific to the USB drivers, but it lives in different fields in the UAS and mass storage drivers.

Greetings,
Mateusz

maintainer
#5 lore raw
Quoted 9 lines · Mateusz Jończyk

W dniu 23.11.2026 o 09:27, Oliver Neukum pisze:

Quoted 2 lines

thank you for handling this. One thing though. This requires putting the emit code into every driver. Can we centralize that somehow?

Not really, short of moving the handling of the ata_passthrough_disabled attribute into the middle SCSI layer (which would also likely involve moving the whole of US_FL_NO_ATA_1X logic from uas_queuecommand_lck() there). Is this what you mean?

Now that you mention it, shouldn't that be where it ought to be anyway? Usually the SCSI layer generates or filters commands, while the LLDD determine what command sets a device will accept and reports that.

Regards
Oliver

#6 lore raw

W dniu 23.11.2026 o 12:41, Oliver Neukum pisze:

Quoted 8 lines · Mateusz Jończyk
Quoted 5 lines

W dniu 23.11.2026 o 09:27, Oliver Neukum pisze:

 > thank you for handling this. One thing though. This requires putting > the emit code into every driver. Can we centralize that somehow?

Quoted 9 lines
Quoted 4 lines

Not really, short of moving the handling of the ata_passthrough_disabled attribute into the middle SCSI layer (which would also likely involve moving the whole of US_FL_NO_ATA_1X logic from uas_queuecommand_lck() there). Is this what you mean?

Now that you mention it, shouldn't that be where it ought to be anyway? Usually the SCSI layer generates or filters commands, while the LLDD determine what command sets a device will accept and reports that.

OK, I will prepare a patch series as appropriate and report back.

Greetings,

Mateusz

#7 lore raw
In reply to Mateusz Jończyk
Quoted 9 lines · Mateusz Jończyk

The uas driver blocks access to ATA passthrough commands for some devices it considers buggy. However, it does not expose any meaningful information whether the command was disabled by the driver or is genuinly not supported by the hardware. This creates a problem for the smartmontools program and makes it difficult for it to provide a useful error message.

[...]

Quoted 6 lines
Documentation/ABI/testing/sysfs-class-scsi_device new file +0 -0
new file mode 100644
index 000000000000..4dc8645bf59b

Documentation/ABI/testing/sysfs-class-scsi_device line 10

Quoted 10 lines
Documentation/ABI/testing/sysfs-class-scsi_device new file +10 -0
@@ -0,0 +1,10 @@
+What:		/sys/class/scsi_device/*/device/ata_passthrough_disabled
+Date:		Nov, 2026
+KernelVersion:	v7.5
+Contact:	[email protected]
+Description:	(RO) Indicates whether the driver blocks access from userspace
+		to ATA passthrough commands. Contains a value of '1' when such
+		commands are denied as the hardware is considered buggy and they
+		might interfere with a correct operation of the drive. Note that
+		a value of '0' does not necessarily mean that ATA passthrough is
+		available as it may not be supported by the hardware at all.

Would it make sense to explicitly mention something about "USB quirk flag US_FL_NO_ATA_1X" in this documentation entry?

Nathan