custom testpatch to show more info about touching usb2 hw lpm setting for usb3 devices not for upstream, just testing Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx> --- drivers/usb/core/hub.c | 32 +++++++++++++++++++++++++------- drivers/usb/host/xhci.c | 11 +++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index bee1351..14fcd87 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3201,9 +3201,11 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) } /* disable USB2 hardware LPM */ - if (udev->usb2_hw_lpm_enabled == 1) + if (udev->usb2_hw_lpm_enabled == 1) { + if (!udev->usb2_hw_lpm_capable) + dev_err(&udev->dev, "USB2 LPM disabling for non-capable dev\n"); usb_set_usb2_hardware_lpm(udev, 0); - + } if (usb_disable_ltm(udev)) { dev_err(&udev->dev, "Failed to disable LTM before suspend\n."); status = -ENOMEM; @@ -4306,6 +4308,9 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) if (!udev->usb2_hw_lpm_capable) return; + if (udev->speed >= USB_SPEED_SUPER) + dev_err(&udev->dev, "USB2 LPM: set initial for SS devic\n"); + if (hub) connect_type = hub->ports[udev->portnum - 1]->connect_type; @@ -4648,7 +4653,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, hcd->driver->update_device(hcd, udev); hub_set_initial_usb2_lpm_policy(udev); fail: + + if (retval) { + if (udev->usb2_hw_lpm_capable) + dev_err(&udev->dev, "USB2 LPM %s fails but capable is set, speed %d\n", + __func__, udev->speed); hub_port_disable(hub, port1, 0); update_devnum(udev, devnum); /* for disconnect processing */ } @@ -4814,11 +4824,13 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, udev->wusb = hub_is_wusb(hub); /* Devices connected to SuperSpeed hubs are USB 3.0 or later */ - if (hub_is_superspeed(hub->hdev)) + if (hub_is_superspeed(hub->hdev)) { udev->speed = USB_SPEED_SUPER; - else + if (udev->usb2_hw_lpm_capable) + dev_err(&udev->dev, "USB2 LPM capable set for fresh SS device\n"); + } else { udev->speed = USB_SPEED_UNKNOWN; - + } choose_devnum(udev); if (udev->devnum <= 0) { status = -ENOTCONN; /* Don't retry */ @@ -5444,9 +5456,15 @@ static int usb_reset_and_verify_device(struct usb_device *udev) /* Disable USB2 hardware LPM. * It will be re-enabled by the enumeration process. */ - if (udev->usb2_hw_lpm_enabled == 1) + if (udev->usb2_hw_lpm_enabled == 1) { + if (udev->speed >= USB_SPEED_SUPER) + dev_err(&udev->dev, " USB2 LPM %s for SS device\n", + __func__); + if (!udev->usb2_hw_lpm_capable) + dev_err(&udev->dev, " USB2 LPM %s for uncapable device\n", + __func__); usb_set_usb2_hardware_lpm(udev, 0); - + } /* Disable LPM and LTM while we reset the device and reinstall the alt * settings. Device-initiated LPM settings, and system exit latency * settings are cleared when the device is reset, so we have to set diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index fa7e1ef..fdda854 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4137,6 +4137,13 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, hlpm_addr = port_array[port_num] + PORTHLPMC; field = le32_to_cpu(udev->bos->ext_cap->bmAttributes); + if (port_num >= xhci->num_usb2_ports) + dev_warn(&udev->dev, "USB2 LPM portnum %d > num_usb2_ports %d\n", + port_num, xhci->num_usb2_ports); + + if (udev->speed >= USB_SPEED_SUPER) + dev_warn(&udev->dev, "USB2 LPM for SS device!!\n"); + xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", enable ? "enable" : "disable", port_num + 1); @@ -4247,6 +4254,10 @@ int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) xhci_check_usb2_port_capability( xhci, portnum, XHCI_HLC)) { udev->usb2_hw_lpm_capable = 1; + dev_err(&udev->dev, "USB2 LPM capable set, port %d speed %d\n", + portnum, udev->speed); + dev_err(&udev->dev, "max usb2 ports %d\n", + xhci->num_usb2_ports); udev->l1_params.timeout = XHCI_L1_TIMEOUT; udev->l1_params.besl = XHCI_DEFAULT_BESL; if (xhci_check_usb2_port_capability(xhci, portnum, -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html