Skip to content

Commit 25cd288

Browse files
author
Sarah Sharp
committed
usb/xhci: Change how we indicate a host supports Link PM.
The xHCI driver currently uses a USB core internal field, udev->lpm_capable, to indicate the xHCI driver knows how to calculate the LPM timeout values. If this value is set for the host controller udev, it means Link PM can be enabled for child devices under that host. Change the code so the xHCI driver isn't mucking with USB core internal fields. Instead, indicate the xHCI driver doesn't support Link PM on this host by clearing the U1 and U2 exit latencies in the roothub SuperSpeed Extended Capabilities BOS descriptor. The code to check for the roothub setting U1 and U2 exit latencies to zero will also disable LPM for external devices that do that same. This was already effectively done with commit ae8963a "usb: Don't enable LPM if the exit latency is zero." Leave that code in place, so that if a device sets one exit latency value to zero, but the other is set to a valid value, LPM is only enabled for the U1 or U2 state that had the valid value. This is the same behavior the code had before. Also, change messages about missing Link PM information from warning level to info level. Only print a warning about the first device that doesn't support LPM, to avoid log spam. Further, cleanup some unnecessary line breaks to help people to grep for the error messages. Signed-off-by: Sarah Sharp <[email protected]> Cc: Alan Stern <[email protected]>
1 parent 3c1b2c3 commit 25cd288

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

drivers/usb/core/hub.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,27 @@ static int usb_device_supports_lpm(struct usb_device *udev)
141141
return 0;
142142
}
143143

144-
/* All USB 3.0 must support LPM, but we need their max exit latency
145-
* information from the SuperSpeed Extended Capabilities BOS descriptor.
144+
/*
145+
* According to the USB 3.0 spec, all USB 3.0 devices must support LPM.
146+
* However, there are some that don't, and they set the U1/U2 exit
147+
* latencies to zero.
146148
*/
147149
if (!udev->bos->ss_cap) {
148-
dev_warn(&udev->dev, "No LPM exit latency info found. "
149-
"Power management will be impacted.\n");
150+
dev_info(&udev->dev, "No LPM exit latency info found, disabling LPM.\n");
150151
return 0;
151152
}
152-
if (udev->parent->lpm_capable)
153-
return 1;
154153

155-
dev_warn(&udev->dev, "Parent hub missing LPM exit latency info. "
156-
"Power management will be impacted.\n");
154+
if (udev->bos->ss_cap->bU1devExitLat == 0 &&
155+
udev->bos->ss_cap->bU2DevExitLat == 0) {
156+
if (udev->parent)
157+
dev_info(&udev->dev, "LPM exit latency is zeroed, disabling LPM.\n");
158+
else
159+
dev_info(&udev->dev, "We don't know the algorithms for LPM for this host, disabling LPM.\n");
160+
return 0;
161+
}
162+
163+
if (!udev->parent || udev->parent->lpm_capable)
164+
return 1;
157165
return 0;
158166
}
159167

drivers/usb/host/xhci-hub.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,9 +732,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
732732
/* Set the U1 and U2 exit latencies. */
733733
memcpy(buf, &usb_bos_descriptor,
734734
USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE);
735-
temp = readl(&xhci->cap_regs->hcs_params3);
736-
buf[12] = HCS_U1_LATENCY(temp);
737-
put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]);
735+
if ((xhci->quirks & XHCI_LPM_SUPPORT)) {
736+
temp = readl(&xhci->cap_regs->hcs_params3);
737+
buf[12] = HCS_U1_LATENCY(temp);
738+
put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]);
739+
}
738740

739741
/* Indicate whether the host has LTM support. */
740742
temp = readl(&xhci->cap_regs->hcc_params);

drivers/usb/host/xhci-pci.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,6 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
222222
goto put_usb3_hcd;
223223
/* Roothub already marked as USB 3.0 speed */
224224

225-
/* We know the LPM timeout algorithms for this host, let the USB core
226-
* enable and disable LPM for devices under the USB 3.0 roothub.
227-
*/
228-
if (xhci->quirks & XHCI_LPM_SUPPORT)
229-
hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1;
230-
231225
return 0;
232226

233227
put_usb3_hcd:

0 commit comments

Comments
 (0)