aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/hub.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2013-12-05 20:07:27 -0500
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2013-12-10 16:54:37 -0500
commit48fc7dbd52c0559647291f33a10ccdc6cdbe4c72 (patch)
tree4a2403420a69b2d40e38a53302771ec3d3eb6b66 /drivers/usb/core/hub.c
parent40fcd88b8d49fd911518190c985112097d3a8a17 (diff)
usb: xhci: change enumeration scheme to 'new scheme' by default
Change the default enumeration scheme for xhci attached non-SuperSpeed devices from: Reset SetAddress [xhci address-device BSR = 0] GetDescriptor(8) GetDescriptor(18) ...to: Reset [xhci address-device BSR = 1] GetDescriptor(64) Reset SetAddress [xhci address-device BSR = 0] GetDescriptor(18) ...as some devices misbehave when encountering a SetAddress command prior to GetDescriptor. There are known legacy devices that require this scheme, but testing has found at least one USB3 device that fails enumeration when presented with this ordering. For now, follow the ehci case and enable 'new scheme' by default for non-SuperSpeed devices. To support this enumeration scheme on xhci the AddressDevice operation needs to be performed twice. The first instance of the command enables the HC's device and slot context info for the device, but omits sending the device a SetAddress command (BSR == block set address request). Then, after GetDescriptor completes, follow up with the full AddressDevice+SetAddress operation. As mentioned before, this ordering of events with USB3 devices causes an extra state transition to be exposed to xhci. Previously USB3 devices would transition directly from 'enabled' to 'addressed' and never need to underrun responses to 'get descriptor'. We do see the 64-byte descriptor fetch the correct data, but the following 18-byte descriptor read after the reset gets: bLength = 0 bDescriptorType = 0 bcdUSB = 0 bDeviceClass = 0 bDeviceSubClass = 0 bDeviceProtocol = 0 bMaxPacketSize0 = 9 instead of: bLength = 12 bDescriptorType = 1 bcdUSB = 300 bDeviceClass = 0 bDeviceSubClass = 0 bDeviceProtocol = 0 bMaxPacketSize0 = 9 which results in the discovery process looping until falling back to 'old scheme' enumeration. Acked-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: David Moore <david.moore@gmail.com> Suggested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/core/hub.c')
-rw-r--r--drivers/usb/core/hub.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 32e1035d4f59..6a11eff74d3c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2498,6 +2498,21 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
2498#define HUB_LONG_RESET_TIME 200 2498#define HUB_LONG_RESET_TIME 200
2499#define HUB_RESET_TIMEOUT 800 2499#define HUB_RESET_TIMEOUT 800
2500 2500
2501/*
2502 * "New scheme" enumeration causes an extra state transition to be
2503 * exposed to an xhci host and causes USB3 devices to receive control
2504 * commands in the default state. This has been seen to cause
2505 * enumeration failures, so disable this enumeration scheme for USB3
2506 * devices.
2507 */
2508static bool use_new_scheme(struct usb_device *udev, int retry)
2509{
2510 if (udev->speed == USB_SPEED_SUPER)
2511 return false;
2512
2513 return USE_NEW_SCHEME(retry);
2514}
2515
2501static int hub_port_reset(struct usb_hub *hub, int port1, 2516static int hub_port_reset(struct usb_hub *hub, int port1,
2502 struct usb_device *udev, unsigned int delay, bool warm); 2517 struct usb_device *udev, unsigned int delay, bool warm);
2503 2518
@@ -3956,6 +3971,20 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
3956 } 3971 }
3957} 3972}
3958 3973
3974static int hub_enable_device(struct usb_device *udev)
3975{
3976 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3977
3978 if (!hcd->driver->enable_device)
3979 return 0;
3980 if (udev->state == USB_STATE_ADDRESS)
3981 return 0;
3982 if (udev->state != USB_STATE_DEFAULT)
3983 return -EINVAL;
3984
3985 return hcd->driver->enable_device(hcd, udev);
3986}
3987
3959/* Reset device, (re)assign address, get device descriptor. 3988/* Reset device, (re)assign address, get device descriptor.
3960 * Device connection must be stable, no more debouncing needed. 3989 * Device connection must be stable, no more debouncing needed.
3961 * Returns device in USB_STATE_ADDRESS, except on error. 3990 * Returns device in USB_STATE_ADDRESS, except on error.
@@ -4068,7 +4097,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4068 * this area, and this is how Linux has done it for ages. 4097 * this area, and this is how Linux has done it for ages.
4069 * Change it cautiously. 4098 * Change it cautiously.
4070 * 4099 *
4071 * NOTE: If USE_NEW_SCHEME() is true we will start by issuing 4100 * NOTE: If use_new_scheme() is true we will start by issuing
4072 * a 64-byte GET_DESCRIPTOR request. This is what Windows does, 4101 * a 64-byte GET_DESCRIPTOR request. This is what Windows does,
4073 * so it may help with some non-standards-compliant devices. 4102 * so it may help with some non-standards-compliant devices.
4074 * Otherwise we start with SET_ADDRESS and then try to read the 4103 * Otherwise we start with SET_ADDRESS and then try to read the
@@ -4076,10 +4105,17 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4076 * value. 4105 * value.
4077 */ 4106 */
4078 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) { 4107 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
4079 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) { 4108 bool did_new_scheme = false;
4109
4110 if (use_new_scheme(udev, retry_counter)) {
4080 struct usb_device_descriptor *buf; 4111 struct usb_device_descriptor *buf;
4081 int r = 0; 4112 int r = 0;
4082 4113
4114 did_new_scheme = true;
4115 retval = hub_enable_device(udev);
4116 if (retval < 0)
4117 goto fail;
4118
4083#define GET_DESCRIPTOR_BUFSIZE 64 4119#define GET_DESCRIPTOR_BUFSIZE 64
4084 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO); 4120 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO);
4085 if (!buf) { 4121 if (!buf) {
@@ -4168,7 +4204,11 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4168 * - read ep0 maxpacket even for high and low speed, 4204 * - read ep0 maxpacket even for high and low speed,
4169 */ 4205 */
4170 msleep(10); 4206 msleep(10);
4171 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) 4207 /* use_new_scheme() checks the speed which may have
4208 * changed since the initial look so we cache the result
4209 * in did_new_scheme
4210 */
4211 if (did_new_scheme)
4172 break; 4212 break;
4173 } 4213 }
4174 4214