Commit 2d2a3167 authored by Lu Baolu's avatar Lu Baolu Committed by Greg Kroah-Hartman

usb: core: lpm: set lpm_capable for root hub device

Commit 25cd2882 ("usb/xhci: Change how we indicate a host supports
Link PM.") removed the code to set lpm_capable for USB 3.0 super-speed
root hub. The intention of that change was to avoid touching usb core
internal field, a.k.a. lpm_capable, and let usb core to set it by
checking U1 and U2 exit latency values in the descriptor.

Usb core checks and sets lpm_capable in hub_port_init(). Unfortunately,
root hub is a special usb device as it has no parent. Hub_port_init()
will never be called for a root hub device. That means lpm_capable will
by no means be set for the root hub. As the result, lpm isn't functional
at all in Linux kernel.

This patch add the code to check and set lpm_capable when registering a
root hub device. It could be back-ported to kernels as old as v3.15,
that contains the Commit 25cd2882 ("usb/xhci: Change how we indicate
a host supports Link PM.").

Cc: stable@vger.kernel.org # 3.15
Reported-by: default avatarKevin Strasser <kevin.strasser@linux.intel.com>
Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7021deae
...@@ -1022,9 +1022,12 @@ static int register_root_hub(struct usb_hcd *hcd) ...@@ -1022,9 +1022,12 @@ static int register_root_hub(struct usb_hcd *hcd)
dev_name(&usb_dev->dev), retval); dev_name(&usb_dev->dev), retval);
return (retval < 0) ? retval : -EMSGSIZE; return (retval < 0) ? retval : -EMSGSIZE;
} }
if (usb_dev->speed == USB_SPEED_SUPER) {
if (le16_to_cpu(usb_dev->descriptor.bcdUSB) >= 0x0201) {
retval = usb_get_bos_descriptor(usb_dev); retval = usb_get_bos_descriptor(usb_dev);
if (retval < 0) { if (!retval) {
usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev);
} else if (usb_dev->speed == USB_SPEED_SUPER) {
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock);
dev_dbg(parent_dev, "can't read %s bos descriptor %d\n", dev_dbg(parent_dev, "can't read %s bos descriptor %d\n",
dev_name(&usb_dev->dev), retval); dev_name(&usb_dev->dev), retval);
......
...@@ -122,7 +122,7 @@ struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev) ...@@ -122,7 +122,7 @@ struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev)
return usb_get_intfdata(hdev->actconfig->interface[0]); return usb_get_intfdata(hdev->actconfig->interface[0]);
} }
static int usb_device_supports_lpm(struct usb_device *udev) int usb_device_supports_lpm(struct usb_device *udev)
{ {
/* USB 2.1 (and greater) devices indicate LPM support through /* USB 2.1 (and greater) devices indicate LPM support through
* their USB 2.0 Extended Capabilities BOS descriptor. * their USB 2.0 Extended Capabilities BOS descriptor.
......
...@@ -65,6 +65,7 @@ extern int usb_hub_init(void); ...@@ -65,6 +65,7 @@ extern int usb_hub_init(void);
extern void usb_hub_cleanup(void); extern void usb_hub_cleanup(void);
extern int usb_major_init(void); extern int usb_major_init(void);
extern void usb_major_cleanup(void); extern void usb_major_cleanup(void);
extern int usb_device_supports_lpm(struct usb_device *udev);
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment