aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLu Baolu <baolu.lu@linux.intel.com>2015-06-15 21:08:26 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-07-22 17:46:50 -0400
commit2d2a316765d956bc5cb6bb367b2ec52ca59ab8e9 (patch)
tree1adc52c5dfa57300afcb78af89b40c4af3a749a2
parent7021deae9735871c67ac0cc1c6ab0bdf634b665e (diff)
usb: core: lpm: set lpm_capable for root hub device
Commit 25cd2882e2fc ("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 25cd2882e2fc ("usb/xhci: Change how we indicate a host supports Link PM."). Cc: stable@vger.kernel.org # 3.15 Reported-by: Kevin Strasser <kevin.strasser@linux.intel.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/core/hcd.c7
-rw-r--r--drivers/usb/core/hub.c2
-rw-r--r--drivers/usb/core/usb.h1
3 files changed, 7 insertions, 3 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index be5b2074f906..cbcd0920fb51 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1022,9 +1022,12 @@ static int register_root_hub(struct usb_hcd *hcd)
1022 dev_name(&usb_dev->dev), retval); 1022 dev_name(&usb_dev->dev), retval);
1023 return (retval < 0) ? retval : -EMSGSIZE; 1023 return (retval < 0) ? retval : -EMSGSIZE;
1024 } 1024 }
1025 if (usb_dev->speed == USB_SPEED_SUPER) { 1025
1026 if (le16_to_cpu(usb_dev->descriptor.bcdUSB) >= 0x0201) {
1026 retval = usb_get_bos_descriptor(usb_dev); 1027 retval = usb_get_bos_descriptor(usb_dev);
1027 if (retval < 0) { 1028 if (!retval) {
1029 usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev);
1030 } else if (usb_dev->speed == USB_SPEED_SUPER) {
1028 mutex_unlock(&usb_bus_list_lock); 1031 mutex_unlock(&usb_bus_list_lock);
1029 dev_dbg(parent_dev, "can't read %s bos descriptor %d\n", 1032 dev_dbg(parent_dev, "can't read %s bos descriptor %d\n",
1030 dev_name(&usb_dev->dev), retval); 1033 dev_name(&usb_dev->dev), retval);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 43cb2f2e3b43..73dfa194160b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -122,7 +122,7 @@ struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev)
122 return usb_get_intfdata(hdev->actconfig->interface[0]); 122 return usb_get_intfdata(hdev->actconfig->interface[0]);
123} 123}
124 124
125static int usb_device_supports_lpm(struct usb_device *udev) 125int usb_device_supports_lpm(struct usb_device *udev)
126{ 126{
127 /* USB 2.1 (and greater) devices indicate LPM support through 127 /* USB 2.1 (and greater) devices indicate LPM support through
128 * their USB 2.0 Extended Capabilities BOS descriptor. 128 * their USB 2.0 Extended Capabilities BOS descriptor.
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 7eb1e26798e5..457255a3306a 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -65,6 +65,7 @@ extern int usb_hub_init(void);
65extern void usb_hub_cleanup(void); 65extern void usb_hub_cleanup(void);
66extern int usb_major_init(void); 66extern int usb_major_init(void);
67extern void usb_major_cleanup(void); 67extern void usb_major_cleanup(void);
68extern int usb_device_supports_lpm(struct usb_device *udev);
68 69
69#ifdef CONFIG_PM 70#ifdef CONFIG_PM
70 71