From: Mathias Nyman Date: Fri, 14 Mar 2025 14:19:57 +0000 (+0200) Subject: usb: hub: verify device is configured in usb_device_may_initiate_lpm() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c8be504beb1e3110d3e037fb578f3c1cb586dc85;p=users%2Fjedix%2Flinux-maple.git usb: hub: verify device is configured in usb_device_may_initiate_lpm() 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 Link: https://lore.kernel.org/r/20250314142000.93090-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 577516683318e..9b5ef4147891e 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -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,