Re: UAS support for hcd without sg support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Alan Stern | 2012-01-09 11:19:02 [-0500]:

>On Mon, 9 Jan 2012, Sebastian Andrzej Siewior wrote:
>
>> > Ok, and why would you want to run a UAS device on anything other than
>> > those controllers?
>> 
>> There is nothing wrong with adding UAS to a device which can do only
>> USB2.0. On the hand you could attach your USB3.0 UAS device to the ohci
>> controller because you have an old computer _or_ some other device
>> which has only musb for instance.
>
>But there's very little advantage to using UAS in those circumstances; 
>it will be only slightly faster than BOT.  Nobody is going to stop 
>supporting BOT any time soon -- not until UAS support is added to all 
>the old versions of Windows floating around!
>
>(Besides, we might as well add SG support to ohci-hcd.  Doing so will
>be fairly easy, and it's already present in uhci-hcd; you must have
>missed it.)

According to
|git grep sg_tablesize drivers/usb/
|drivers/usb/gadget/dummy_hcd.c: hcd->self.sg_tablesize = ~0;
|drivers/usb/host/ehci-hcd.c:            hcd->self.sg_tablesize = ~0;
|drivers/usb/host/whci/hcd.c:    usb_hcd->self.sg_tablesize = 2048; /* somewhat arbitrary */
|drivers/usb/host/xhci.c:        hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2;

Minus drivers/usb/image/ and drivers/usb/storage/
uhci is not here so usb_sg_init() does the wrong thing here. You want me
send a patch initializes sg_tablesize for uhci?

>> > Fix the UAS driver to not do a blocking call from interrupt context?
>> 
>> All this controllers are 2.0 or less. According to the protocol we
>> learn in the URB's completion that we have enqueue a new URB. So 
>> blocking here means a context switch into an UAS-thread/workqueue. This 
>> is no good.
>> So I propose (start of this thread) to change usb_sg_wait() so it does
>> not wait.
>
>You would also have to allocate a bunch of URBs using GFP_ATOMIC, which 
>is not desirable.

I see. So this:

>From dd8a38268880a7141b5b0cc2b6c4168b96a3024a Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Date: Mon, 9 Jan 2012 18:33:04 +0100
Subject: [PATCH] usb/uas: only bind if the hcd supports SG

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
 drivers/usb/storage/uas.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 9d40b98..d118e05 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -13,6 +13,7 @@
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/usb/hcd.h>
 #include <linux/usb/storage.h>
 
 #include <scsi/scsi.h>
@@ -626,22 +627,38 @@ static int uas_is_interface(struct usb_host_interface *intf)
 		intf->desc.bInterfaceProtocol == USB_PR_UAS);
 }
 
+static int uas_isnt_supported(struct usb_device *udev)
+{
+	struct usb_hcd *hcd = bus_to_hcd(udev->bus);
+
+	pr_err("USB controller %s does not support sg. Can't use UAS.\n",
+			hcd->driver->description);
+	return -EINVAL;
+}
+
 static int uas_switch_interface(struct usb_device *udev,
 						struct usb_interface *intf)
 {
 	int i;
+	int sg_supported = udev->bus->sg_tablesize != 0;
 
-	if (uas_is_interface(intf->cur_altsetting))
-		return 0;
+	if (uas_is_interface(intf->cur_altsetting)) {
+		if (sg_supported)
+			return 0;
+		return uas_isnt_supported(udev);
+	}
 
 	for (i = 0; i < intf->num_altsetting; i++) {
 		struct usb_host_interface *alt = &intf->altsetting[i];
 		if (alt == intf->cur_altsetting)
 			continue;
-		if (uas_is_interface(alt))
+		if (uas_is_interface(alt)) {
+			if (!sg_supported)
+				return uas_isnt_supported(udev);
 			return usb_set_interface(udev,
 						alt->desc.bInterfaceNumber,
 						alt->desc.bAlternateSetting);
+		}
 	}
 
 	return -ENODEV;

or making a non-blocking version of usb_sg_wait()? Since it we should
have BOT and UAS we could fallback to BOT, print a message and implement
sg support if one complains.

This patch was tested on an UAS-only device as I don't (yet) have BOT working:
| usb 2-1: configuration #1 chosen from 1 choice
|  gadget: super-speed config #1: Linux UASP Storage
| usb 2-1: adding 2-1:1.0 (config #1, interface 0)
| usb-storage 2-1:1.0: usb_probe_interface
| usb-storage 2-1:1.0: usb_probe_interface - got id
| usb-storage 2-1:1.0: Quirks match for vid 0525 pid a4a5: 10000
| hub 2-0:1.0: state 7 ports 1 chg 0000 evt 0002
| uas 2-1:1.0: usb_probe_interface
| uas 2-1:1.0: usb_probe_interface - got id
| USB controller dummy_hcd does not support sg. Can't use UAS.
| usbcore: registered new interface driver uas

>Alan Stern

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux