From 3b29b68b1627781b5eecb581d3b9d5f0043a72f2 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 22 Feb 2011 09:53:41 -0500 Subject: USB: use "device number" instead of "address" The USB stack historically has conflated device numbers (i.e., the value of udev->devnum) with device addresses. This is understandable, because until recently the two values were always the same. But with USB-3.0 they aren't the same, so we should start calling these things by their correct names. This patch (as1449b) changes many of the references to "address" in the hub driver to "device number" or "devnum". The patch also removes some unnecessary or misleading comments. Signed-off-by: Alan Stern Reported-by: Luben Tuikov Reviewed-by: Sarah Sharp Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index d041c6826e4..c168121f9f9 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1499,6 +1499,13 @@ void usb_set_device_state(struct usb_device *udev, EXPORT_SYMBOL_GPL(usb_set_device_state); /* + * Choose a device number. + * + * Device numbers are used as filenames in usbfs. On USB-1.1 and + * USB-2.0 buses they are also used as device addresses, however on + * USB-3.0 buses the address is assigned by the controller hardware + * and it usually is not the same as the device number. + * * WUSB devices are simple: they have no hubs behind, so the mapping * device <-> virtual port number becomes 1:1. Why? to simplify the * life of the device connection logic in @@ -1520,7 +1527,7 @@ EXPORT_SYMBOL_GPL(usb_set_device_state); * the HCD must setup data structures before issuing a set address * command to the hardware. */ -static void choose_address(struct usb_device *udev) +static void choose_devnum(struct usb_device *udev) { int devnum; struct usb_bus *bus = udev->bus; @@ -1545,7 +1552,7 @@ static void choose_address(struct usb_device *udev) } } -static void release_address(struct usb_device *udev) +static void release_devnum(struct usb_device *udev) { if (udev->devnum > 0) { clear_bit(udev->devnum, udev->bus->devmap.devicemap); @@ -1553,7 +1560,7 @@ static void release_address(struct usb_device *udev) } } -static void update_address(struct usb_device *udev, int devnum) +static void update_devnum(struct usb_device *udev, int devnum) { /* The address for a WUSB device is managed by wusbcore. */ if (!udev->wusb) @@ -1600,7 +1607,8 @@ void usb_disconnect(struct usb_device **pdev) * this quiesces everyting except pending urbs. */ usb_set_device_state(udev, USB_STATE_NOTATTACHED); - dev_info (&udev->dev, "USB disconnect, address %d\n", udev->devnum); + dev_info(&udev->dev, "USB disconnect, device number %d\n", + udev->devnum); usb_lock_device(udev); @@ -1630,7 +1638,7 @@ void usb_disconnect(struct usb_device **pdev) /* Free the device number and delete the parent's children[] * (or root_hub) pointer. */ - release_address(udev); + release_devnum(udev); /* Avoid races with recursively_mark_NOTATTACHED() */ spin_lock_irq(&device_state_lock); @@ -2071,7 +2079,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1, case 0: /* TRSTRCY = 10 ms; plus some extra */ msleep(10 + 40); - update_address(udev, 0); + update_devnum(udev, 0); if (hcd->driver->reset_device) { status = hcd->driver->reset_device(hcd, udev); if (status < 0) { @@ -2634,7 +2642,7 @@ static int hub_set_address(struct usb_device *udev, int devnum) USB_REQ_SET_ADDRESS, 0, devnum, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); if (retval == 0) { - update_address(udev, devnum); + update_devnum(udev, devnum); /* Device now using proper address. */ usb_set_device_state(udev, USB_STATE_ADDRESS); usb_ep0_reinit(udev); @@ -2743,9 +2751,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, } if (udev->speed != USB_SPEED_SUPER) dev_info(&udev->dev, - "%s %s speed %sUSB device using %s and address %d\n", + "%s %s speed %sUSB device number %d using %s\n", (udev->config) ? "reset" : "new", speed, type, - udev->bus->controller->driver->name, devnum); + devnum, udev->bus->controller->driver->name); /* Set up TT records, if needed */ if (hdev->tt) { @@ -2775,10 +2783,6 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, * value. */ for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) { - /* - * An xHCI controller cannot send any packets to a device until - * a set address command successfully completes. - */ if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) { struct usb_device_descriptor *buf; int r = 0; @@ -2861,9 +2865,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, if (udev->speed == USB_SPEED_SUPER) { devnum = udev->devnum; dev_info(&udev->dev, - "%s SuperSpeed USB device using %s and address %d\n", + "%s SuperSpeed USB device number %d using %s\n", (udev->config) ? "reset" : "new", - udev->bus->controller->driver->name, devnum); + devnum, udev->bus->controller->driver->name); } /* cope with hardware quirkiness: @@ -2926,7 +2930,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, fail: if (retval) { hub_port_disable(hub, port1, 0); - update_address(udev, devnum); /* for disconnect processing */ + update_devnum(udev, devnum); /* for disconnect processing */ } mutex_unlock(&usb_address0_mutex); return retval; @@ -3135,15 +3139,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, else udev->speed = USB_SPEED_UNKNOWN; - /* - * Set the address. - * Note xHCI needs to issue an address device command later - * in the hub_port_init sequence for SS/HS/FS/LS devices, - * and xHC will assign an address to the device. But use - * kernel assigned address here, to avoid any address conflict - * issue. - */ - choose_address(udev); + choose_devnum(udev); if (udev->devnum <= 0) { status = -ENOTCONN; /* Don't retry */ goto loop; @@ -3235,7 +3231,7 @@ loop_disable: hub_port_disable(hub, port1, 1); loop: usb_ep0_reinit(udev); - release_address(udev); + release_devnum(udev); hub_free_dev(udev); usb_put_dev(udev); if ((status == -ENOTCONN) || (status == -ENOTSUPP)) -- cgit v1.2.3 From 6d42fcdb685e3b7af45c77181537db4bc1a715f9 Mon Sep 17 00:00:00 2001 From: "Justin P. Mattock" Date: Sat, 26 Feb 2011 20:33:56 -0800 Subject: usb: core: hub.c Remove one to many n's in a word. The Patch below removes one to many "n's" in a word.. Signed-off-by: Justin P. Mattock CC: Alan Stern CC: linux-usb@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index c168121f9f9..395754edd06 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -616,7 +616,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) } /* - * Disable a port and mark a logical connnect-change event, so that some + * Disable a port and mark a logical connect-change event, so that some * time later khubd will disconnect() any existing usb_device on the port * and will re-enumerate if there actually is a device attached. */ -- cgit v1.2.3 From 752d57a8b7b97423bffa3452638aa0fd3c3bb9d1 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Fri, 11 Mar 2011 18:03:52 +0100 Subject: USB: Only treat lasting over-current conditions as errors On a laptop I see these errors on (most) resumes: hub 3-0:1.0: over-current change on port 1 hub 3-0:1.0: over-current change on port 2 Since over-current conditions can disappear quite quickly it's better to downgrade that message to debug level, recheck for an over-current condition a little later and only print and over-current condition error if that condition (still) exists when it's rechecked. Add similar logic to hub over-current changes. (That code is untested, as those changes do not occur on this laptop.) Signed-off-by: Paul Bolle Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 395754edd06..b574f9131b4 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3408,12 +3408,19 @@ static void hub_events(void) } if (portchange & USB_PORT_STAT_C_OVERCURRENT) { - dev_err (hub_dev, - "over-current change on port %d\n", - i); + u16 status = 0; + u16 unused; + + dev_dbg(hub_dev, "over-current change on port " + "%d\n", i); clear_port_feature(hdev, i, USB_PORT_FEAT_C_OVER_CURRENT); + msleep(100); /* Cool down */ hub_power_on(hub, true); + hub_port_status(hub, i, &status, &unused); + if (status & USB_PORT_STAT_OVERCURRENT) + dev_err(hub_dev, "over-current " + "condition on port %d\n", i); } if (portchange & USB_PORT_STAT_C_RESET) { @@ -3445,10 +3452,17 @@ static void hub_events(void) hub->limited_power = 0; } if (hubchange & HUB_CHANGE_OVERCURRENT) { - dev_dbg (hub_dev, "overcurrent change\n"); - msleep(500); /* Cool down */ + u16 status = 0; + u16 unused; + + dev_dbg(hub_dev, "over-current change\n"); clear_hub_feature(hdev, C_HUB_OVER_CURRENT); + msleep(500); /* Cool down */ hub_power_on(hub, true); + hub_hub_status(hub, &status, &unused); + if (status & HUB_STATUS_OVERCURRENT) + dev_err(hub_dev, "over-current " + "condition\n"); } } -- cgit v1.2.3 From dbe79bbe9dcb22cb3651c46f18943477141ca452 Mon Sep 17 00:00:00 2001 From: John Youn Date: Mon, 17 Sep 2001 00:00:00 -0700 Subject: USB 3.0 Hub Changes Update the USB core to deal with USB 3.0 hubs. These hubs have a slightly different hub descriptor than USB 2.0 hubs, with a fixed (rather than variable length) size. Change the USB core's hub descriptor to have a union for the last fields that differ. Change the host controller drivers that access those last fields (DeviceRemovable and PortPowerCtrlMask) to use the union. Translate the new version of the hub port status field into the old version that khubd understands. (Note: we need to fix it to translate the roothub's port status once we stop converting it to USB 2.0 hub status internally.) Add new code to handle link state change status. Send out new control messages that are needed for USB 3.0 hubs, like Set Hub Depth. This patch is a modified version of the original patch submitted by John Youn. It's updated to reflect the removal of the "bitmap" #define, and change the hub descriptor accesses of a couple new host controller drivers. Signed-off-by: John Youn Signed-off-by: Sarah Sharp Cc: Nobuhiro Iwamatsu Cc: Inaky Perez-Gonzalez Cc: Tony Olech Cc: "Robert P. J. Day" Cc: Max Vozeler Cc: Tejun Heo Cc: Yoshihiro Shimoda Cc: Rodolfo Giometti Cc: Mike Frysinger Cc: Anton Vorontsov Cc: Sebastian Siewior Cc: Lothar Wassmann Cc: Olav Kongas Cc: Martin Fuzzey Cc: Alan Stern Cc: David Brownell --- drivers/usb/core/hub.c | 73 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 8 deletions(-) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index b574f9131b4..feb6e596c7c 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -82,6 +82,10 @@ struct usb_hub { void **port_owners; }; +static inline int hub_is_superspeed(struct usb_device *hdev) +{ + return (hdev->descriptor.bDeviceProtocol == 3); +} /* Protect struct usb_device->state and ->children members * Note: Both are also protected by ->dev.sem, except that ->state can @@ -172,14 +176,23 @@ static struct usb_hub *hdev_to_hub(struct usb_device *hdev) } /* USB 2.0 spec Section 11.24.4.5 */ -static int get_hub_descriptor(struct usb_device *hdev, void *data, int size) +static int get_hub_descriptor(struct usb_device *hdev, void *data) { - int i, ret; + int i, ret, size; + unsigned dtype; + + if (hub_is_superspeed(hdev)) { + dtype = USB_DT_SS_HUB; + size = USB_DT_SS_HUB_SIZE; + } else { + dtype = USB_DT_HUB; + size = sizeof(struct usb_hub_descriptor); + } for (i = 0; i < 3; i++) { ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB, - USB_DT_HUB << 8, 0, data, size, + dtype << 8, 0, data, size, USB_CTRL_GET_TIMEOUT); if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2)) return ret; @@ -365,6 +378,19 @@ static int hub_port_status(struct usb_hub *hub, int port1, } else { *status = le16_to_cpu(hub->status->port.wPortStatus); *change = le16_to_cpu(hub->status->port.wPortChange); + + if ((hub->hdev->parent != NULL) && + hub_is_superspeed(hub->hdev)) { + /* Translate the USB 3 port status */ + u16 tmp = *status & USB_SS_PORT_STAT_MASK; + if (*status & USB_SS_PORT_STAT_POWER) + tmp |= USB_PORT_STAT_POWER; + if ((*status & USB_SS_PORT_STAT_SPEED) == + USB_PORT_STAT_SPEED_5GBPS) + tmp |= USB_PORT_STAT_SUPER_SPEED; + *status = tmp; + } + ret = 0; } mutex_unlock(&hub->status_mutex); @@ -607,7 +633,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) if (hdev->children[port1-1] && set_state) usb_set_device_state(hdev->children[port1-1], USB_STATE_NOTATTACHED); - if (!hub->error) + if (!hub->error && !hub_is_superspeed(hub->hdev)) ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE); if (ret) dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", @@ -795,6 +821,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) clear_port_feature(hub->hdev, port1, USB_PORT_FEAT_C_ENABLE); } + if (portchange & USB_PORT_STAT_C_LINK_STATE) { + need_debounce_delay = true; + clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_PORT_LINK_STATE); + } /* We can forget about a "removed" device when there's a * physical disconnect or the connect status changes. @@ -964,12 +995,23 @@ static int hub_configure(struct usb_hub *hub, goto fail; } + if (hub_is_superspeed(hdev) && (hdev->parent != NULL)) { + ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), + HUB_SET_DEPTH, USB_RT_HUB, + hdev->level - 1, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + + if (ret < 0) { + message = "can't set hub depth"; + goto fail; + } + } + /* Request the entire hub descriptor. * hub->descriptor can handle USB_MAXCHILDREN ports, * but the hub can/will return fewer bytes here. */ - ret = get_hub_descriptor(hdev, hub->descriptor, - sizeof(*hub->descriptor)); + ret = get_hub_descriptor(hdev, hub->descriptor); if (ret < 0) { message = "can't read hub descriptor"; goto fail; @@ -991,12 +1033,14 @@ static int hub_configure(struct usb_hub *hub, wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); - if (wHubCharacteristics & HUB_CHAR_COMPOUND) { + /* FIXME for USB 3.0, skip for now */ + if ((wHubCharacteristics & HUB_CHAR_COMPOUND) && + !(hub_is_superspeed(hdev))) { int i; char portstr [USB_MAXCHILDREN + 1]; for (i = 0; i < hdev->maxchild; i++) - portstr[i] = hub->descriptor->DeviceRemovable + portstr[i] = hub->descriptor->u.hs.DeviceRemovable [((i + 1) / 8)] & (1 << ((i + 1) % 8)) ? 'F' : 'R'; portstr[hdev->maxchild] = 0; @@ -2029,6 +2073,8 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, udev->speed = USB_SPEED_HIGH; else if (portstatus & USB_PORT_STAT_LOW_SPEED) udev->speed = USB_SPEED_LOW; + else if (portstatus & USB_PORT_STAT_SUPER_SPEED) + udev->speed = USB_SPEED_SUPER; else udev->speed = USB_SPEED_FULL; return 0; @@ -3430,6 +3476,17 @@ static void hub_events(void) clear_port_feature(hdev, i, USB_PORT_FEAT_C_RESET); } + if (portchange & USB_PORT_STAT_C_LINK_STATE) { + clear_port_feature(hub->hdev, i, + USB_PORT_FEAT_C_PORT_LINK_STATE); + } + if (portchange & USB_PORT_STAT_C_CONFIG_ERROR) { + dev_warn(hub_dev, + "config error on port %d\n", + i); + clear_port_feature(hub->hdev, i, + USB_PORT_FEAT_C_PORT_CONFIG_ERROR); + } if (connect_change) hub_port_connect_change(hub, i, -- cgit v1.2.3 From c70615740996823580bb8fb58461347b7ffaad9a Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Mon, 6 Dec 2010 15:08:20 -0800 Subject: USB: Clear "warm" port reset change. In USB 3.0, there are two types of resets: a "hot" port reset and a "warm" port reset. The hot port reset is always tried first, and involves sending the reset signaling for a shorter amount of time. But sometimes devices don't respond to the hot reset, and a "Bigger Hammer" is needed. External hubs and roothubs will automatically try a warm reset when the hot reset fails, and they will set a status change bit to indicate when there is a "BH reset" change. Make sure the USB core clears that port status change bit, or we'll get lots of status change notifications on the interrupt endpoint of the USB 3.0 hub. (Side note: you may be confused why the USB 3.0 spec calls the same type of reset "warm reset" in some places and "BH reset" in other places. "BH" reset is supposed to stand for "Big Hammer" reset, but it also stands for "Brad Hosler". Brad died shortly after the USB 3.0 bus specification was started, and they decided to name the reset after him. The suggestion was made shortly before the spec was finalized, so the wording is a bit inconsistent.) Signed-off-by: Sarah Sharp --- drivers/usb/core/hub.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index feb6e596c7c..0eb27006f84 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3476,6 +3476,14 @@ static void hub_events(void) clear_port_feature(hdev, i, USB_PORT_FEAT_C_RESET); } + if ((portchange & USB_PORT_STAT_C_BH_RESET) && + hub_is_superspeed(hub->hdev)) { + dev_dbg(hub_dev, + "warm reset change on port %d\n", + i); + clear_port_feature(hdev, i, + USB_PORT_FEAT_C_BH_PORT_RESET); + } if (portchange & USB_PORT_STAT_C_LINK_STATE) { clear_port_feature(hub->hdev, i, USB_PORT_FEAT_C_PORT_LINK_STATE); -- cgit v1.2.3 From d673bfcbfffdeb56064a6b1ee047b85590bed76c Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Fri, 15 Oct 2010 08:55:24 -0700 Subject: usb: Change usb_hcd->bandwidth_mutex to a pointer. Change the bandwith_mutex in struct usb_hcd to a pointer. This will allow the pointer to be shared across usb_hcds for the upcoming work to split the xHCI driver roothub into a USB 2.0/1.1 and a USB 3.0 bus. Signed-off-by: Sarah Sharp --- drivers/usb/core/hub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 0eb27006f84..825d803720b 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3776,13 +3776,13 @@ static int usb_reset_and_verify_device(struct usb_device *udev) if (!udev->actconfig) goto done; - mutex_lock(&hcd->bandwidth_mutex); + mutex_lock(hcd->bandwidth_mutex); ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL); if (ret < 0) { dev_warn(&udev->dev, "Busted HC? Not enough HCD resources for " "old configuration.\n"); - mutex_unlock(&hcd->bandwidth_mutex); + mutex_unlock(hcd->bandwidth_mutex); goto re_enumerate; } ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -3793,10 +3793,10 @@ static int usb_reset_and_verify_device(struct usb_device *udev) dev_err(&udev->dev, "can't restore configuration #%d (error=%d)\n", udev->actconfig->desc.bConfigurationValue, ret); - mutex_unlock(&hcd->bandwidth_mutex); + mutex_unlock(hcd->bandwidth_mutex); goto re_enumerate; } - mutex_unlock(&hcd->bandwidth_mutex); + mutex_unlock(hcd->bandwidth_mutex); usb_set_device_state(udev, USB_STATE_CONFIGURED); /* Put interfaces back into the same altsettings as before. -- cgit v1.2.3 From 131dec344d5e41f01e4791aa4c80eb4bdb1e5274 Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Mon, 6 Dec 2010 21:00:19 -0800 Subject: USB: Remove bogus USB_PORT_STAT_SUPER_SPEED symbol. USB_PORT_STAT_SUPER_SPEED is a made up symbol that the USB core used to track whether USB ports had a SuperSpeed device attached. This is a linux-internal symbol that was used when SuperSpeed and non-SuperSpeed devices would show up under the same xHCI roothub. This particular port status is never returned by external USB 3.0 hubs. (Instead they have a USB_PORT_STAT_SPEED_5GBPS that uses a completely different speed mask.) Now that the xHCI driver registers two roothubs, USB 3.0 devices will only show up under USB 3.0 hubs. Rip out USB_PORT_STAT_SUPER_SPEED and replace it with calls to hub_is_superspeed(). Signed-off-by: Sarah Sharp --- drivers/usb/core/hub.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 825d803720b..13aafd1b45e 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -155,14 +155,14 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); static int usb_reset_and_verify_device(struct usb_device *udev); -static inline char *portspeed(int portstatus) +static inline char *portspeed(struct usb_hub *hub, int portstatus) { + if (hub_is_superspeed(hub->hdev)) + return "5.0 Gb/s"; if (portstatus & USB_PORT_STAT_HIGH_SPEED) return "480 Mb/s"; else if (portstatus & USB_PORT_STAT_LOW_SPEED) return "1.5 Mb/s"; - else if (portstatus & USB_PORT_STAT_SUPER_SPEED) - return "5.0 Gb/s"; else return "12 Mb/s"; } @@ -385,9 +385,6 @@ static int hub_port_status(struct usb_hub *hub, int port1, u16 tmp = *status & USB_SS_PORT_STAT_MASK; if (*status & USB_SS_PORT_STAT_POWER) tmp |= USB_PORT_STAT_POWER; - if ((*status & USB_SS_PORT_STAT_SPEED) == - USB_PORT_STAT_SPEED_5GBPS) - tmp |= USB_PORT_STAT_SUPER_SPEED; *status = tmp; } @@ -795,12 +792,8 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) * USB3 protocol ports will automatically transition * to Enabled state when detect an USB3.0 device attach. * Do not disable USB3 protocol ports. - * FIXME: USB3 root hub and external hubs are treated - * differently here. */ - if (hdev->descriptor.bDeviceProtocol != 3 || - (!hdev->parent && - !(portstatus & USB_PORT_STAT_SUPER_SPEED))) { + if (!hub_is_superspeed(hdev)) { clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE); portstatus &= ~USB_PORT_STAT_ENABLE; @@ -2067,14 +2060,12 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, (portstatus & USB_PORT_STAT_ENABLE)) { if (hub_is_wusb(hub)) udev->speed = USB_SPEED_WIRELESS; - else if (portstatus & USB_PORT_STAT_SUPER_SPEED) + else if (hub_is_superspeed(hub->hdev)) udev->speed = USB_SPEED_SUPER; else if (portstatus & USB_PORT_STAT_HIGH_SPEED) udev->speed = USB_SPEED_HIGH; else if (portstatus & USB_PORT_STAT_LOW_SPEED) udev->speed = USB_SPEED_LOW; - else if (portstatus & USB_PORT_STAT_SUPER_SPEED) - udev->speed = USB_SPEED_SUPER; else udev->speed = USB_SPEED_FULL; return 0; @@ -3067,7 +3058,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, dev_dbg (hub_dev, "port %d, status %04x, change %04x, %s\n", - port1, portstatus, portchange, portspeed (portstatus)); + port1, portstatus, portchange, portspeed(hub, portstatus)); if (hub->has_indicators) { set_port_led(hub, port1, HUB_LED_AUTO); @@ -3168,19 +3159,8 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, udev->level = hdev->level + 1; udev->wusb = hub_is_wusb(hub); - /* - * USB 3.0 devices are reset automatically before the connect - * port status change appears, and the root hub port status - * shows the correct speed. We also get port change - * notifications for USB 3.0 devices from the USB 3.0 portion of - * an external USB 3.0 hub, but this isn't handled correctly yet - * FIXME. - */ - - if (!(hcd->driver->flags & HCD_USB3)) - udev->speed = USB_SPEED_UNKNOWN; - else if ((hdev->parent == NULL) && - (portstatus & USB_PORT_STAT_SUPER_SPEED)) + /* Only USB 3.0 devices are connected to SuperSpeed hubs. */ + if (hub_is_superspeed(hub->hdev)) udev->speed = USB_SPEED_SUPER; else udev->speed = USB_SPEED_UNKNOWN; -- cgit v1.2.3 From 0c9ffe0f6286a02bf82f8d7fb7274aec2ad977f1 Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Thu, 30 Dec 2010 13:27:36 -0800 Subject: USB: Disable auto-suspend for USB 3.0 hubs. USB 3.0 devices have a slightly different suspend sequence than USB 2.0/1.1 devices. There isn't support for USB 3.0 device suspend yet, so make khubd leave autosuspend disabled for USB 3.0 hubs. Make sure that USB 3.0 roothubs still have autosuspend enabled, since that path in the xHCI driver works fine. Signed-off-by: Sarah Sharp --- drivers/usb/core/hub.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/usb/core/hub.c') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 13aafd1b45e..0968157f3be 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1290,8 +1290,14 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) desc = intf->cur_altsetting; hdev = interface_to_usbdev(intf); - /* Hubs have proper suspend/resume support */ - usb_enable_autosuspend(hdev); + /* Hubs have proper suspend/resume support. USB 3.0 device suspend is + * different from USB 2.0/1.1 device suspend, and unfortunately we + * don't support it yet. So leave autosuspend disabled for USB 3.0 + * external hubs for now. Enable autosuspend for USB 3.0 roothubs, + * since that isn't a "real" hub. + */ + if (!hub_is_superspeed(hdev) || !hdev->parent) + usb_enable_autosuspend(hdev); if (hdev->level == MAX_TOPO_LEVEL) { dev_err(&intf->dev, -- cgit v1.2.3