From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>, <stern@rowland.harvard.edu>,
Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [PATCH 2/5] usb: hub: verify device is configured in usb_device_may_initiate_lpm()
Date: Fri, 14 Mar 2025 16:19:57 +0200 [thread overview]
Message-ID: <20250314142000.93090-3-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20250314142000.93090-1-mathias.nyman@linux.intel.com>
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>
---
drivers/usb/core/hub.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a901d1b55856..10ef9f51fcfd 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,
--
2.43.0
next prev parent reply other threads:[~2025-03-14 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 14:19 [PATCH 0/5] usb: hub: Fail fast on USB3 LPM requests issues Mathias Nyman
2025-03-14 14:19 ` [PATCH 1/5] usb: hub: Block less in USB3 link power management LPM disable path Mathias Nyman
2025-03-14 14:19 ` Mathias Nyman [this message]
2025-03-14 14:19 ` [PATCH 3/5] usb: hub: Don't disable LPM completely if device initiated LPM fails Mathias Nyman
2025-03-14 14:19 ` [PATCH 4/5] usb: hub: reorder USB3 link power management enable requests Mathias Nyman
2025-03-14 14:20 ` [PATCH 5/5] usb: hub: Fail fast in USB3 link power management enable path Mathias Nyman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250314142000.93090-3-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.