Re: [PATCH] USB: Warn about USB3 devices plugged into USB2 hub.

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

 



* Sarah Sharp | 2012-01-09 15:07:40 [-0800]:

>When a SuperSpeed device is plugged into a high speed hub or
>an EHCI port, it will show up as a high speed device with a BCD of
>0x0210 and it will contain a SuperSpeed Capabilities BOS descriptor.  If
>we see such a high speed device, warn the user that they should plug
>their device into a USB 3.0 hub or xHCI root port.
>
>Signed-off-by: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
>---
>
>Ok, this version actually compiles and doesn't cause kernel oopses.
>I'll queue this up to my for-usb-next branch for 3.4 if no one objects.
>
> drivers/usb/core/hub.c |   11 +++++++++++
> 1 files changed, 11 insertions(+), 0 deletions(-)
>
>diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
>index 79d339e..15da2d5 100644
>--- a/drivers/usb/core/hub.c
>+++ b/drivers/usb/core/hub.c
>@@ -3142,6 +3142,16 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
> 	kfree(qual);
> }
> 
>+static void check_superspeed(struct usb_hub *hub, struct usb_device *udev,
>+		int port1)
>+{
>+	/* BOS descriptor should have already been fetched by now. */

Either it is there or it isn't and according to the code flow it is. The
comment isn't required.

>+	if (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300 &&
>+			udev->bos && udev->bos->ss_cap)

ss_cap should only be provided by SS devices. Not sure how much sense it
makes to manufactor a device which does not have the USB_5GBPS_OPERATION
bit set.

>+		dev_info(&udev->dev, "not running at top speed; "
>+			"connect to a SuperSpeed hub or host\n");
>+}
>+

If you add soemthing like:

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 79d339e..54b579e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3142,6 +3142,20 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
 	kfree(qual);
 }
 
+static bool have_usb3_controller;
+
+void usb3_controller_available(void)
+{
+	have_usb3_controller = true;
+}
+EXPORT_SYMBOL_GPL(usb3_controller_available);
+
+bool is_usb3_controller_available(void)
+{
+	return have_usb3_controller;
+}
+EXPORT_SYMBOL_GPL(is_usb3_controller_available);
+
 static unsigned
 hub_power_remaining (struct usb_hub *hub)
 {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6bbe3c3..c80b088 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3960,6 +3960,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
 	u32			temp;
 
 	hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2;
+	usb3_controller_available();
 
 	if (usb_hcd_is_primary_hcd(hcd)) {
 		xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index b2f62f3..8aa1c62 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -473,6 +473,8 @@ struct usb_tt_clear {
 
 extern int usb_hub_clear_tt_buffer(struct urb *urb);
 extern void usb_ep0_reinit(struct usb_device *);
+extern void usb3_controller_available(void);
+extern bool is_usb3_controller_available(void);
 
 /* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
 #define DeviceRequest \

Then you would not print this message unless we have such a controller.
This could be extended to usb2 in 1.1 port but I guess this is no longer
required :)

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