Skip to contentSkip to conversation

usb: storage: skip only when uas driver is loaded

PATCH In review JC Kuo 3 participants 13 messages Jul 1, 2019 – Jul 2, 2019

Subsystems (2)
lore
Share & tools
lore

JC Kuo

author
#0 lore raw

PATCH 1/1 usb: storage: skip only when uas driver is loaded

When usb-storage driver detects a UAS capable device, it ignores the device if CONFIG_USB_UAS is enabled. usb-storage driver assumes uas driver certainly will be loaded. However, it's possible that uas driver will not be loaded, for example, uas kernel module is not installed properly or it is in modprobe blacklist.

In case of uas driver not being loaded, the UAS capable device will not fallback to work at Bulk-only-transfer mode. The device just disappears without any notification to user/userspace.

This commit changes usb-storage driver to skip UAS capable device only when uas driver is already loaded to make sure the device will at least work with Bulk protocol.

---
 drivers/usb/core/driver.c | 1 +
 drivers/usb/storage/usb.c | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/usb/core/driver.c +1 -0
index ebcadaad89d1..265c5dd490d2 100644
@@ -1923,3 +1923,4 @@ struct bus_type usb_bus_type = {
 	.uevent =	usb_uevent,
 	.need_parent_lock =	true,
 };
+EXPORT_SYMBOL_GPL(usb_bus_type);
drivers/usb/storage/usb.c +3 -2
index 9a79cd9762f3..d8f64e808783 100644
@@ -1097,9 +1097,10 @@ static int storage_probe(struct usb_interface *intf,
 	int result;
 	int size;
 
-	/* If uas is enabled and this device can do uas then ignore it. */
+	/* If uas driver is loaded and this device can do uas then ignore it. */
 #if IS_ENABLED(CONFIG_USB_UAS)
-	if (uas_use_uas_driver(intf, id, NULL))
+	if (driver_find("uas", &usb_bus_type) &&
+		uas_use_uas_driver(intf, id, NULL))
 		return -ENXIO;
 #endif
 
Signature · 9 lines
2.17.1


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
maintainer
#1 lore raw
Quoted 6 lines · JC Kuo

When usb-storage driver detects a UAS capable device, it ignores the device if CONFIG_USB_UAS is enabled. usb-storage driver assumes uas driver certainly will be loaded. However, it's possible that uas driver will not be loaded, for example, uas kernel module is not installed properly or it is in modprobe blacklist.

Quoted 7 lines

In case of uas driver not being loaded, the UAS capable device will not fallback to work at Bulk-only-transfer mode. The device just disappears without any notification to user/userspace.

This commit changes usb-storage driver to skip UAS capable device only when uas driver is already loaded to make sure the device will at least work with Bulk protocol.

But what happens if the driver is loaded afterward, because 'modprobe' was called by the driver core (or it should have been, because this is a device that supports that protocol)?

I think you just broke working systems :(

Why wouldn't the UAS driver get loaded automatically if it is configured in the system as it is today?

thanks,

greg k-h

author
#2 lore raw
Quoted 11 lines · Greg KH
Quoted 10 lines · JC Kuo

When usb-storage driver detects a UAS capable device, it ignores the device if CONFIG_USB_UAS is enabled. usb-storage driver assumes uas driver certainly will be loaded. However, it's possible that uas driver will not be loaded, for example, uas kernel module is not installed properly or it is in modprobe blacklist.

In case of uas driver not being loaded, the UAS capable device will not fallback to work at Bulk-only-transfer mode. The device just disappears without any notification to user/userspace.

Quoted 7 lines
Quoted 3 lines

This commit changes usb-storage driver to skip UAS capable device only when uas driver is already loaded to make sure the device will at least work with Bulk protocol.

But what happens if the driver is loaded afterward, because 'modprobe' was called by the driver core (or it should have been, because this is a device that supports that protocol)?

If uas driver is loaded after usb-storage driver probed the device, the device will still work with Bulk-only protocol, though it can't make uses of streams.

Quoted 5 lines

I think you just broke working systems :(

Why wouldn't the UAS driver get loaded automatically if it is configured in the system as it is today?

An user might want to completely disable uas for some reason so he/she adds "blacklist uas" to modprobe conf file. I think in case of this, usb-storage driver has to enable this device with the legacy Bulk-only protocol instead of ignoring the device.

As an alternative to this patch, I thought I could get uas driver loaded before usb-storage driver so I tried moving the functions in drivers/usb/storage/uas-detect.h into uas.c and letting usb-storage links uas_use_uas_driver() of uas.ko. However, that didn't work because uas driver actually depends on usb-storage driver for usb_stor_adjust_quirks(). There will be a recursive dependency.

Please let me know if there is better approach to avoid the issue.

Thanks,
JC

Quoted 5 lines

thanks,

greg k-h

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

maintainer
#3 lore raw
Quoted 16 lines · JC Kuo
Quoted 15 lines · Greg KH
Quoted 13 lines · JC Kuo

When usb-storage driver detects a UAS capable device, it ignores the device if CONFIG_USB_UAS is enabled. usb-storage driver assumes uas driver certainly will be loaded. However, it's possible that uas driver will not be loaded, for example, uas kernel module is not installed properly or it is in modprobe blacklist.

In case of uas driver not being loaded, the UAS capable device will not fallback to work at Bulk-only-transfer mode. The device just disappears without any notification to user/userspace.

This commit changes usb-storage driver to skip UAS capable device only when uas driver is already loaded to make sure the device will at least work with Bulk protocol.

Quoted 6 lines
Quoted 3 lines

But what happens if the driver is loaded afterward, because 'modprobe' was called by the driver core (or it should have been, because this is a device that supports that protocol)?

If uas driver is loaded after usb-storage driver probed the device, the device will still work with Bulk-only protocol, though it can't make uses of streams.

Which is not a good thing, and is what the original code was there to prevent happening.

Quoted 8 lines
Quoted 4 lines

I think you just broke working systems :(

Why wouldn't the UAS driver get loaded automatically if it is configured in the system as it is today?

An user might want to completely disable uas for some reason so he/she adds "blacklist uas" to modprobe conf file. I think in case of this, usb-storage driver has to enable this device with the legacy Bulk-only protocol instead of ignoring the device.

Why would they want to do that? Where are people doing this in ways that breaks their systems?

Quoted 8 lines

As an alternative to this patch, I thought I could get uas driver loaded before usb-storage driver so I tried moving the functions in drivers/usb/storage/uas-detect.h into uas.c and letting usb-storage links uas_use_uas_driver() of uas.ko. However, that didn't work because uas driver actually depends on usb-storage driver for usb_stor_adjust_quirks(). There will be a recursive dependency.

Please let me know if there is better approach to avoid the issue.

If users blacklist the uas driver, that's their choice and they should rebuild their kernel :)

Or better yet, talk to us to get the issue fixed for why they would want to blacklist such a driver.

As it is, this patch is not acceptable.

thanks,

greg k-h

author
#4 lore raw
Quoted 31 lines · Greg KH
Quoted 16 lines · JC Kuo
Quoted 15 lines · Greg KH
Quoted 13 lines · JC Kuo

When usb-storage driver detects a UAS capable device, it ignores the device if CONFIG_USB_UAS is enabled. usb-storage driver assumes uas driver certainly will be loaded. However, it's possible that uas driver will not be loaded, for example, uas kernel module is not installed properly or it is in modprobe blacklist.

In case of uas driver not being loaded, the UAS capable device will not fallback to work at Bulk-only-transfer mode. The device just disappears without any notification to user/userspace.

This commit changes usb-storage driver to skip UAS capable device only when uas driver is already loaded to make sure the device will at least work with Bulk protocol.

Quoted 6 lines
Quoted 3 lines

But what happens if the driver is loaded afterward, because 'modprobe' was called by the driver core (or it should have been, because this is a device that supports that protocol)?

If uas driver is loaded after usb-storage driver probed the device, the device will still work with Bulk-only protocol, though it can't make uses of streams.

Which is not a good thing, and is what the original code was there to prevent happening.

Quoted 4 lines
Quoted 4 lines

I think you just broke working systems :(

Why wouldn't the UAS driver get loaded automatically if it is configured in the system as it is today?

Quoted 7 lines
Quoted 4 lines

An user might want to completely disable uas for some reason so he/she adds "blacklist uas" to modprobe conf file. I think in case of this, usb-storage driver has to enable this device with the legacy Bulk-only protocol instead of ignoring the device.

Why would they want to do that? Where are people doing this in ways that breaks their systems?

I think that could be because user sees issues with UAS but he/she is not aware of the quirks parameter that usb-storage module offers to disable UAS for any particular device.

IMHO, blacklisting uas driver should not break the system because the UAS devices are supposed to be working fine with legacy Bulk-only protocol if system software doesn't have UAS support.

Quoted 8 lines
Quoted 8 lines

As an alternative to this patch, I thought I could get uas driver loaded before usb-storage driver so I tried moving the functions in drivers/usb/storage/uas-detect.h into uas.c and letting usb-storage links uas_use_uas_driver() of uas.ko. However, that didn't work because uas driver actually depends on usb-storage driver for usb_stor_adjust_quirks(). There will be a recursive dependency.

Quoted 7 lines
Quoted 1 line

Please let me know if there is better approach to avoid the issue.

If users blacklist the uas driver, that's their choice and they should rebuild their kernel :)

Or better yet, talk to us to get the issue fixed for why they would want to blacklist such a driver.

Agree. :)

Quoted 2 lines

As it is, this patch is not acceptable.

Understood. Thanks for the comments. I will drop this patch.

Thanks,
JC

Quoted 5 lines

thanks,

greg k-h

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

author
#5 lore raw
Quoted 67 lines · JC Kuo
Quoted 31 lines · Greg KH
Quoted 16 lines · JC Kuo
Quoted 15 lines · Greg KH
Quoted 13 lines · JC Kuo

When usb-storage driver detects a UAS capable device, it ignores the device if CONFIG_USB_UAS is enabled. usb-storage driver assumes uas driver certainly will be loaded. However, it's possible that uas driver will not be loaded, for example, uas kernel module is not installed properly or it is in modprobe blacklist.

In case of uas driver not being loaded, the UAS capable device will not fallback to work at Bulk-only-transfer mode. The device just disappears without any notification to user/userspace.

This commit changes usb-storage driver to skip UAS capable device only when uas driver is already loaded to make sure the device will at least work with Bulk protocol.

Quoted 6 lines
Quoted 3 lines

But what happens if the driver is loaded afterward, because 'modprobe' was called by the driver core (or it should have been, because this is a device that supports that protocol)?

If uas driver is loaded after usb-storage driver probed the device, the device will still work with Bulk-only protocol, though it can't make uses of streams.

Which is not a good thing, and is what the original code was there to prevent happening.

Quoted 4 lines
Quoted 4 lines

I think you just broke working systems :(

Why wouldn't the UAS driver get loaded automatically if it is configured in the system as it is today?

Quoted 7 lines
Quoted 4 lines

An user might want to completely disable uas for some reason so he/she adds "blacklist uas" to modprobe conf file. I think in case of this, usb-storage driver has to enable this device with the legacy Bulk-only protocol instead of ignoring the device.

Why would they want to do that? Where are people doing this in ways that breaks their systems?

I think that could be because user sees issues with UAS but he/she is not aware of the quirks parameter that usb-storage module offers to disable UAS for any particular device.

IMHO, blacklisting uas driver should not break the system because the UAS devices are supposed to be working fine with legacy Bulk-only protocol if system software doesn't have UAS support.

Quoted 8 lines
Quoted 8 lines

As an alternative to this patch, I thought I could get uas driver loaded before usb-storage driver so I tried moving the functions in drivers/usb/storage/uas-detect.h into uas.c and letting usb-storage links uas_use_uas_driver() of uas.ko. However, that didn't work because uas driver actually depends on usb-storage driver for usb_stor_adjust_quirks(). There will be a recursive dependency.

Quoted 7 lines
Quoted 1 line

Please let me know if there is better approach to avoid the issue.

If users blacklist the uas driver, that's their choice and they should rebuild their kernel :)

Or better yet, talk to us to get the issue fixed for why they would want to blacklist such a driver.

Agree. :)

Quoted 1 line
Quoted 12 lines
Quoted 1 line

As it is, this patch is not acceptable.

Understood. Thanks for the comments. I will drop this patch.

Thanks,
JC

Quoted 5 lines

thanks,

greg k-h

Hi Greg,
Since blacklisting uas kernel module is not a good idea and could break UAS capable storage functionality, do we consider forbidding making uas driver as module? That means to make CONFIG_USB_UAS a bool option.

Thanks,
JC

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

maintainer
#6 lore raw
Quoted 6 lines · JC Kuo

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

Footers like this are not allowed on public mailing lists, and forbid me to respond to...

author
#7 lore raw
Quoted 4 lines · Greg KH

Footers like this are not allowed on public mailing lists, and forbid me to respond to...

Hi Greg,
I am truly sorry for that. I have just figured out how to tell mail server not to add the footer. Please allow me to query again.

Since blacklisting uas kernel module is not a good idea and could break UAS capable storage functionality, although user-space should be blamed for the improper configuration, do we consider forbidding making uas driver as module? That means to make CONFIG_USB_UAS a bool option.

Thanks,
JC

maintainer
#8 lore raw
Quoted 6 lines · JC Kuo
Quoted 4 lines · Greg KH

Footers like this are not allowed on public mailing lists, and forbid me to respond to...

Quoted 8 lines

Hi Greg,
I am truly sorry for that. I have just figured out how to tell mail server not to add the footer. Please allow me to query again.

Since blacklisting uas kernel module is not a good idea and could break UAS capable storage functionality, although user-space should be blamed for the improper configuration, do we consider forbidding making uas driver as module? That means to make CONFIG_USB_UAS a bool option.

Step back and try to describe the real problem that you are having here.

Why is the kernel responsible for fixing a broken userspace configuration? What UAS devices are not working with Linux that could cause someone to want to blacklist the uas driver and who is telling them to do that?

Also see Oliver's response.

thanks,

greg k-h

#9 lore raw
In reply to JC Kuo

Am Dienstag, den 02.07.2019, 14:56 +0800 schrieb JC Kuo:

Quoted 2 lines

Since blacklisting uas kernel module is not a good idea and could break UAS

Then don't do it. If you don't want a driver loaded for a device blacklisting the driver must not magically assign another driver.

Quoted 2 lines

capable storage functionality, do we consider forbidding making uas driver as module? That means to make CONFIG_USB_UAS a bool option.

No. Absolutely not. We cannot force people to build UAS into their kernel or not use it. Building either driver not at all, modular or statically are all valid use cases. Just not building UAS must trigger a fallback. And we must have a flag to override the kernel's decision

Making driver assignments depend on module loading order is a very bad idea. We also have the necessary quirk in one way. I would accept a patch adding a flag to force usage of UAS, but other than that, the existing code is as it must be.

Regards
Oliver

author
#10 lore raw
Quoted 16 lines · Oliver Neukum

Am Dienstag, den 02.07.2019, 14:56 +0800 schrieb JC Kuo:

Quoted 2 lines

Since blacklisting uas kernel module is not a good idea and could break UAS

Then don't do it. If you don't want a driver loaded for a device blacklisting the driver must not magically assign another driver.

Quoted 2 lines

capable storage functionality, do we consider forbidding making uas driver as module? That means to make CONFIG_USB_UAS a bool option.

No. Absolutely not. We cannot force people to build UAS into their kernel or not use it. Building either driver not at all, modular or statically are all valid use cases. Just not building UAS must trigger a fallback. And we must have a flag to override the kernel's decision

Quoted 8 lines

Making driver assignments depend on module loading order is a very bad idea. We also have the necessary quirk in one way. I would accept a patch adding a flag to force usage of UAS, but other than that, the existing code is as it must be.

Regards
Oliver

Hi Greg and Oliver,
Thank you so much for your time and guidance. I understood that we can make use of usb-storage quirks parameter to blacklist any UAS capable device.

I don't see the uas issue myself. I was trying to describe a situation that user having issue with UAS storage and would like to blacklist uas module when the user is not aware of the usb-storage quirks parameter.

https://marc.info/?l=linux-usb&m=143385909823645&w=2

UAS capable devices are backward-compatible with legacy Bulk-only protocol. Therefore, IMHO, ideally if system software doesn't have UAS support, system software should enable the UAS device with Bulk-only protocol, unless usb-storage driver is not there as well.

Now the only valid way to disable UAS support for all UAS devices is to disable CONFIG_USB_UAS option and rebuild kernel. Blacklisting uas driver is intuitive, however it doesn't really disable UAS support but actually prevents UAS devices to be functional even though usb-storage driver is there and the devices indeed support Bulk-only protocol.

Thanks,
JC

#11 lore raw

Am Dienstag, den 02.07.2019, 22:05 +0800 schrieb JC Kuo:

Hi,

Quoted 5 lines

I don't see the uas issue myself. I was trying to describe a situation that user having issue with UAS storage and would like to blacklist uas module when the user is not aware of the usb-storage quirks parameter.

https://marc.info/?l=linux-usb&m=143385909823645&w=2

So we are not meeting the expectations of some users. Ideally we would. Yet there are things we cannot do.

Quoted 2 lines

UAS capable devices are backward-compatible with legacy Bulk-only protocol. Therefore, IMHO, ideally if system software doesn't have UAS support, system

Exact. At compilation time this is a valid consideration.

Quoted 2 lines

software should enable the UAS device with Bulk-only protocol, unless usb-storage driver is not there as well.

What you could do, if we cannot change what the kernel does, is improving documentation. We can at least tell users how it is done correctly.

Regards
Oliver

#12 lore raw
In reply to JC Kuo

Am Dienstag, den 02.07.2019, 10:36 +0800 schrieb JC Kuo:

Quoted 5 lines

An user might want to completely disable uas for some reason so he/she adds "blacklist uas" to modprobe conf file. I think in case of this, usb-storage driver has to enable this device with the legacy Bulk-only protocol instead of ignoring the device.

As an alternative to this patch, I thought I could get uas driver loaded before usb-storage driver so I tried moving the functions in drivers/usb/storage/uas-detect.h into uas.c and letting usb-storage links uas_use_uas_driver() of uas.ko. However, that didn't work because uas driver actually depends on usb-storage driver for usb_stor_adjust_quirks(). There will be a recursive dependency.

Please let me know if there is better approach to avoid the issue.

Use US_FL_IGNORE_UAS. You can trigger this with a module parameter. We cannot just use another driver because the user block a module load.

Regards
Oliver