Skip to content

Commit 2d2a316

Browse files
LuBaolugregkh
authored andcommitted
usb: core: lpm: set lpm_capable for root hub device
Commit 25cd288 ("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 25cd288 ("usb/xhci: Change how we indicate a host supports Link PM."). Cc: [email protected] # 3.15 Reported-by: Kevin Strasser <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Acked-by: Alan Stern <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7021dea commit 2d2a316

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

drivers/usb/core/hcd.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,12 @@ static int register_root_hub(struct usb_hcd *hcd)
10221022
dev_name(&usb_dev->dev), retval);
10231023
return (retval < 0) ? retval : -EMSGSIZE;
10241024
}
1025-
if (usb_dev->speed == USB_SPEED_SUPER) {
1025+
1026+
if (le16_to_cpu(usb_dev->descriptor.bcdUSB) >= 0x0201) {
10261027
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) {
10281031
mutex_unlock(&usb_bus_list_lock);
10291032
dev_dbg(parent_dev, "can't read %s bos descriptor %d\n",
10301033
dev_name(&usb_dev->dev), retval);

drivers/usb/core/hub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev)
122122
return usb_get_intfdata(hdev->actconfig->interface[0]);
123123
}
124124

125-
static int usb_device_supports_lpm(struct usb_device *udev)
125+
int usb_device_supports_lpm(struct usb_device *udev)
126126
{
127127
/* USB 2.1 (and greater) devices indicate LPM support through
128128
* their USB 2.0 Extended Capabilities BOS descriptor.

drivers/usb/core/usb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ extern int usb_hub_init(void);
6565
extern void usb_hub_cleanup(void);
6666
extern int usb_major_init(void);
6767
extern void usb_major_cleanup(void);
68+
extern int usb_device_supports_lpm(struct usb_device *udev);
6869

6970
#ifdef CONFIG_PM
7071

0 commit comments

Comments
 (0)