From: Michal Pecio <michal.pecio@gmail.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: yiyu@yiyuzhou.io, <linux-usb@vger.kernel.org>,
regressions@lists.linux.dev, diogochaves@me.com,
raoxu@uniontech.com, dennis@dsine.de, gregkh@linuxfoundation.org
Subject: [PATCH 3/4] usb: xhci: Give back URBs on halted disconnected endpoints
Date: Thu, 29 Oct 2026 07:56:22 +0100 [thread overview]
Message-ID: <20261029075622.2eacf9be.michal.pecio@gmail.com> (raw)
In-Reply-To: <20261029075409.4b203658.michal.pecio@gmail.com>
Bailing out of xhci_handle_halted_endpoint() on disconnected devices
had a side effect of leaving the failed URB and other URBs stranded
until the driver times out or its disconnect() routine runs and the
URBs are unlinked. And since disconnect() can't run during probe(),
only timeouts remained, slowing down error handling and making some
devices which disconnect during probe fail to probe altogether.
Ensure giveback of all URBs when we don't queue Reset Endpoint.
Set return status to 0, because the only caller that looks at it is
xhci_handle_cmd_stop_ep(), which would only repeat an equivalent of
xhci_process_cancelled_tds() if we return -ENODEV.
Reported-by: Yiyu Zhou <yiyu@yiyuzhou.io>
Link: https://lore.kernel.org/linux-usb/20261010064407.11030-1-yiyu@yiyuzhou.io/
Reported-by: Dennis Wissel <dennis@dsine.de>
Link: https://lore.kernel.org/linux-usb/SrQQcLIwRWyg9PdEIpc0eg@dsine.de/
Fixes: 7e0ef4332ed9 ("xhci: avoid xHC endpoint changes after disconnect or link error.")
Cc: stable@vger.kernel.org
Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
---
drivers/usb/host/xhci-ring.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 14cfb025c365..1097600699d4 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -993,13 +993,14 @@ static int xhci_handle_halted_endpoint(struct xhci_hcd *xhci,
int err;
/*
- * Avoid resetting endpoint if link is inactive or device disonnected.
- * Can cause host hang.
- * Device will be reset to recover an inactive link, so don't do anything
+ * Flag endpoints behind disconnected RH ports and override soft retries.
+ * Restarting them is futile and known to trigger HC bugs on USB3 buses.
*/
if (rhub_port->link_inactive || !rhub_port->connected) {
+ xhci_dbg(xhci, "Halted slot %d ep %d is lost\n",
+ slot_id, ep->ep_index);
ep->ep_state |= EP_DROP_PENDING;
- return -ENODEV;
+ reset_type = EP_HARD_RESET;
}
/* add td to cancelled list and let reset ep handler take care of it */
@@ -1017,6 +1018,12 @@ static int xhci_handle_halted_endpoint(struct xhci_hcd *xhci,
return 0;
}
+ /* Don't reset lost endpoints, only EP0 can survive device reset */
+ if (ep->ep_state & EP_DROP_PENDING && ep->ep_index != 0) {
+ xhci_process_cancelled_tds(xhci, ep);
+ return 0;
+ }
+
err = xhci_reset_halted_ep(xhci, slot_id, ep->ep_index, reset_type);
if (err)
return err;
--
2.48.1
next prev parent reply other threads:[~2026-10-29 6:56 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 17:47 [REGRESSION] usbhid -110 timeouts and reset loop for Keychron M5 (3434:d068) at boot since v7.3 Dennis Wissel
2026-10-24 20:34 ` Yiyu Zhou
2026-10-24 20:35 ` Yiyu Zhou
2026-10-24 23:10 ` Dennis Wissel
2026-10-25 8:59 ` Thorsten Leemhuis
2026-10-26 9:28 ` Mathias Nyman
2026-10-26 9:49 ` Thorsten Leemhuis
2026-10-26 10:47 ` Greg KH
2026-10-25 10:14 ` Michal Pecio
2026-10-25 11:11 ` Dennis Wissel
2026-10-26 11:15 ` Michal Pecio
2026-10-26 20:39 ` Yiyu Zhou
2026-10-27 7:29 ` Dennis Wissel
2026-10-27 8:48 ` [PATCH] xhci: keep ep0 blocked after disconnect until Address Device reloads it Yiyu Zhou
2026-10-27 9:10 ` sashiko-bot
2026-10-27 10:36 ` Mathias Nyman
2026-10-27 11:27 ` Michal Pecio
2026-10-27 18:40 ` Yiyu Zhou
2026-10-27 19:21 ` [RFT PATCH 0/2] xhci: clean up endpoint rings after disconnect detect Mathias Nyman
2026-10-27 19:21 ` [RFT PATCH 1/2] xhci: give back all TDs when skipping endpoint reset after disconnect Mathias Nyman
2026-10-27 19:21 ` [RFT PATCH 2/2] xhci: clean up ep0 ring after disconnect instead of leaving stale TRBs Mathias Nyman
2026-10-27 23:05 ` [RFT PATCH 0/2] xhci: clean up endpoint rings after disconnect detect Dennis Wissel
2026-10-29 14:07 ` Mathias Nyman
2026-10-28 7:07 ` Michal Pecio
2026-10-29 6:54 ` [PATCH 0/4] Fix problems on disconnected devices in 7.3 Michal Pecio
2026-10-29 6:54 ` [PATCH 1/4] usb: xhci: Fix TD invalidation on disconnected endpoints Michal Pecio
2026-10-29 7:12 ` sashiko-bot
2026-10-29 6:55 ` [PATCH 2/4] usb: xhci: Give back stranded URBs " Michal Pecio
2026-10-29 7:23 ` sashiko-bot
2026-10-29 6:56 ` Michal Pecio [this message]
2026-10-29 7:19 ` [PATCH 3/4] usb: xhci: Give back URBs on halted " sashiko-bot
2026-10-29 6:57 ` [PATCH 4/4] usb: xhci: Reject URBs to disconnected devices Michal Pecio
2026-10-29 7:24 ` sashiko-bot
2026-10-29 4:18 ` [RFT PATCH 0/2] xhci: clean up endpoint rings after disconnect detect Yiyu Zhou
2026-10-29 13:15 ` Mathias Nyman
2026-10-27 10:58 ` [REGRESSION] usbhid -110 timeouts and reset loop for Keychron M5 (3434:d068) at boot since v7.3 Michal Pecio
2026-10-26 9:18 ` Mathias Nyman
2026-10-26 9:51 ` Michal Pecio
2026-10-26 11:38 ` Michal Pecio
2026-10-26 11:54 ` Mathias Nyman
2026-10-26 18:56 ` Alan Stern
2026-10-26 18:58 ` Alan Stern
2026-10-25 6:28 ` Greg KH
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=20261029075622.2eacf9be.michal.pecio@gmail.com \
--to=michal.pecio@gmail.com \
--cc=dennis@dsine.de \
--cc=diogochaves@me.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=raoxu@uniontech.com \
--cc=regressions@lists.linux.dev \
--cc=yiyu@yiyuzhou.io \
/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.