usb: remove Link Powermanagement (LPM) disable before port reset.
authorMathias Nyman <mathias.nyman@linux.intel.com>
Wed, 16 Feb 2022 09:51:51 +0000 (11:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Feb 2022 15:20:46 +0000 (16:20 +0100)
Trying to disable Link Powermanagement (LPM) before port reset is
unnecessary and can cause additional delay if host can't communicate
with the device, which is often the reason why device is reset in the
first place.

usb_disable_lpm() will
- zero usb U1/U2 timeouts for the hub downstream port
- send ENABLE U1/U2 clear feature requests to the connected device.
- increase internal reference count for udev->lpm_disable_count

There is no need to zero U1/U2 hub port timeouts, or clearing the
U1/U2 enable for the connected device before reset. These are set
to default by the reset.

USB 3.1 section 10.2.2 "HUB Downstream port U1/U2 timers" states that:
"the U1 and U2 timeout values for a downstream port reset to the default
values when the port receives a SetPortFeature request for a port reset"

Set the udev->lpm_disable_count to "1" after port reset, which is the
default lpm_disable_count value when allocating udev, representing
disabled LPM.

Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20220216095153.1303105-8-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hub.c

index 83b5aff..1460857 100644 (file)
@@ -5009,6 +5009,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
                retval = usb_get_bos_descriptor(udev);
                if (!retval) {
                        udev->lpm_capable = usb_device_supports_lpm(udev);
+                       udev->lpm_disable_count = 1;
                        usb_set_lpm_parameters(udev);
                }
        }
@@ -5932,16 +5933,6 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
         */
        usb_disable_usb2_hardware_lpm(udev);
 
-       /* Disable LPM while we reset the device and reinstall the alt settings.
-        * Device-initiated LPM, and system exit latency settings are cleared
-        * when the device is reset, so we have to set them up again.
-        */
-       ret = usb_unlocked_disable_lpm(udev);
-       if (ret) {
-               dev_err(&udev->dev, "%s Failed to disable LPM\n", __func__);
-               goto re_enumerate_no_bos;
-       }
-
        bos = udev->bos;
        udev->bos = NULL;
 
@@ -6046,8 +6037,6 @@ done:
 re_enumerate:
        usb_release_bos_descriptor(udev);
        udev->bos = bos;
-re_enumerate_no_bos:
-       /* LPM state doesn't matter when we're about to destroy the device. */
        hub_port_logical_disconnect(parent_hub, port1);
        return -ENODEV;
 }