]> www.infradead.org Git - nvme.git/commitdiff
usb: hub: verify device is configured in usb_device_may_initiate_lpm()
authorMathias Nyman <mathias.nyman@linux.intel.com>
Fri, 14 Mar 2025 14:19:57 +0000 (16:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Apr 2025 14:08:34 +0000 (16:08 +0200)
Move device configured check into usb_device_may_initiate_lpm() instead
of calling it before the function.

No functional changes, helps rework to fail faster during link power
management (LPM) enabling.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20250314142000.93090-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hub.c

index 577516683318e439f463f78129f2a3f971b5c257..9b5ef4147891e447703794f24664e1790db88ade 100644 (file)
@@ -4234,9 +4234,9 @@ static int usb_set_lpm_timeout(struct usb_device *udev,
 }
 
 /*
- * Don't allow device intiated U1/U2 if the system exit latency + one bus
- * interval is greater than the minimum service interval of any active
- * periodic endpoint. See USB 3.2 section 9.4.9
+ * Don't allow device intiated U1/U2 if device isn't in the configured state,
+ * or the system exit latency + one bus interval is greater than the minimum
+ * service interval of any active periodic endpoint. See USB 3.2 section 9.4.9
  */
 static bool usb_device_may_initiate_lpm(struct usb_device *udev,
                                        enum usb3_link_state state)
@@ -4244,7 +4244,7 @@ static bool usb_device_may_initiate_lpm(struct usb_device *udev,
        unsigned int sel;               /* us */
        int i, j;
 
-       if (!udev->lpm_devinit_allow)
+       if (!udev->lpm_devinit_allow || !udev->actconfig)
                return false;
 
        if (state == USB3_LPM_U1)
@@ -4341,11 +4341,11 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
                return;
        }
 
-       /* Only a configured device will accept the Set Feature
-        * U1/U2_ENABLE
+       /*
+        * Enable device initiated U1/U2 with a SetFeature(U1/U2_ENABLE) request
+        * if system exit latency is short enough and device is configured
         */
-       if (udev->actconfig &&
-           usb_device_may_initiate_lpm(udev, state)) {
+       if (usb_device_may_initiate_lpm(udev, state)) {
                if (usb_set_device_initiated_lpm(udev, state, true)) {
                        /*
                         * Request to enable device initiated U1/U2 failed,