From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>,
Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [PATCH 8/9] xhci: Finetune host initiated USB3 rootport link suspend and resume
Date: Thu, 12 Mar 2020 16:45:16 +0200 [thread overview]
Message-ID: <20200312144517.1593-9-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20200312144517.1593-1-mathias.nyman@linux.intel.com>
Depending on the current link state the steps to resume the link to U0
varies. The normal case when a port is suspended (U3) we set the link
to U0 and wait for a port event when U3exit completed and port moved to
U0.
If the port is in U1/U2, then no event is issued, just set link to U0
If port is in Resume or Recovery state then the device has already
initiated resume, and this host initiated resume is racing against it.
Port event handler for device initiated resume will set link to U0,
just wait for the port to reach U0 before returning.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-hub.c | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 02f52d4f74df..a9c87eb8951e 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1307,20 +1307,34 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
goto error;
}
+ /*
+ * set link to U0, steps depend on current link state.
+ * U3: set link to U0 and wait for u3exit completion.
+ * U1/U2: no PLC complete event, only set link to U0.
+ * Resume/Recovery: device initiated U0, only wait for
+ * completion
+ */
if (link_state == USB_SS_PORT_LS_U0) {
- if ((temp & PORT_PLS_MASK) == XDEV_U0)
- break;
+ u32 pls = temp & PORT_PLS_MASK;
+ bool wait_u0 = false;
- if (!((temp & PORT_PLS_MASK) == XDEV_U1 ||
- (temp & PORT_PLS_MASK) == XDEV_U2 ||
- (temp & PORT_PLS_MASK) == XDEV_U3)) {
- xhci_warn(xhci, "Can only set port %d to U0 from U state\n",
- wIndex);
- goto error;
+ /* already in U0 */
+ if (pls == XDEV_U0)
+ break;
+ if (pls == XDEV_U3 ||
+ pls == XDEV_RESUME ||
+ pls == XDEV_RECOVERY) {
+ wait_u0 = true;
+ reinit_completion(&bus_state->u3exit_done[wIndex]);
+ }
+ if (pls <= XDEV_U3) /* U1, U2, U3 */
+ xhci_set_link_state(xhci, ports[wIndex],
+ USB_SS_PORT_LS_U0);
+ if (!wait_u0) {
+ if (pls > XDEV_U3)
+ goto error;
+ break;
}
- reinit_completion(&bus_state->u3exit_done[wIndex]);
- xhci_set_link_state(xhci, ports[wIndex],
- USB_SS_PORT_LS_U0);
spin_unlock_irqrestore(&xhci->lock, flags);
if (!wait_for_completion_timeout(&bus_state->u3exit_done[wIndex],
msecs_to_jiffies(100)))
--
2.17.1
next prev parent reply other threads:[~2020-03-12 14:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 14:45 [PATCH 0/9] xhci features for usb-next Mathias Nyman
2020-03-12 14:45 ` [PATCH 1/9] xhci: bail out early if driver can't accress host in resume Mathias Nyman
2020-03-12 14:45 ` [PATCH 2/9] xhci: Add a separate debug message for split transaction errors Mathias Nyman
2020-03-12 14:45 ` [PATCH 3/9] xhci: Show host status when watchdog triggers and host is assumed dead Mathias Nyman
2020-03-12 14:45 ` [PATCH 4/9] usb: xhci: Enable LPM for VIA LABS VL805 Mathias Nyman
2020-03-12 14:45 ` [PATCH 5/9] usb: host: xhci-tegra: Tegra186/Tegra194 LPM Mathias Nyman
2020-03-12 14:45 ` [PATCH 6/9] xhci: Ensure link state is U3 after setting USB_SS_PORT_LS_U3 Mathias Nyman
2020-03-12 14:45 ` [PATCH 7/9] xhci: Wait until link state trainsits to U0 after setting USB_SS_PORT_LS_U0 Mathias Nyman
2020-03-12 14:45 ` Mathias Nyman [this message]
2020-03-12 14:45 ` [PATCH 9/9] xhci-pci: Allow host runtime PM as default for Intel Tiger Lake xHCI 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=20200312144517.1593-9-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/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.