From: Stephano Cetola <stephano@cetola.net>
To: Sascha Hauer <s.hauer@pengutronix.de>,
"open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 4/5] usb: xhci: xhci_bulk_tx: re-fetch ep_ctx after resetting a halted endpoint
Date: Sat, 22 Aug 2026 15:34:03 -0700 [thread overview]
Message-ID: <20260822-send-xhci-fixes-v1-4-22e1de3be715@cetola.net> (raw)
In-Reply-To: <20260822-send-xhci-fixes-v1-0-22e1de3be715@cetola.net>
xhci_bulk_tx() reads the endpoint's context once at the top of the
function and reuses that same value both to decide whether to call
reset_ep() and, further down, to pass to prepare_ring(). reset_ep()
clears the halt by updating the endpoint's output context via DMA,
but the earlier ep_ctx read is never invalidated or refetched after
that, so prepare_ring() always sees the stale pre-reset
EP_STATE_HALTED value.
prepare_ring() rejects the transfer with -EINVAL, regardless of
whether reset_ep() actually succeeded. The USB keyboard driver's
poller treats any error other than -EAGAIN as fatal. One spurious
rejection is enough to stop it for good, and nothing calls
xhci_bulk_tx() again after that. The keyboard stays dead until the
next boot.
Signed-off-by: Stephano Cetola <stephano@cetola.net>
---
drivers/usb/host/xhci-ring.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 522ac7c45f..a3b78052a4 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -705,8 +705,13 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
* the next transfer. It is the responsibility of the upper layer to
* have dealt with whatever caused the error.
*/
- if ((le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK) == EP_STATE_HALTED)
+ if ((le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK) == EP_STATE_HALTED) {
reset_ep(udev, ep_index);
+ /* reset_ep() updates the context via DMA. Re-fetch it here. */
+ xhci_inval_cache((uintptr_t)virt_dev->out_ctx->bytes,
+ virt_dev->out_ctx->size);
+ ep_ctx = xhci_get_ep_ctx(ctrl, virt_dev->out_ctx, ep_index);
+ }
ring = virt_dev->eps[ep_index].ring;
/*
--
2.55.0
next prev parent reply other threads:[~2026-08-22 22:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 22:33 [PATCH 0/5] usb: xhci: fix endpoint halt and stall recovery Stephano Cetola
2026-08-22 22:34 ` [PATCH 1/5] usb: xhci: tolerate COMP_CTX_STATE in abort_td's final completion check Stephano Cetola
2026-08-22 22:34 ` [PATCH 2/5] usb: xhci: reset_ep: wait for real completion, not the caller's timeout Stephano Cetola
2026-08-22 22:34 ` [PATCH 3/5] usb: xhci: reset_ep: fix misaligned pointer in Set TR Dequeue Pointer Stephano Cetola
2026-08-22 22:34 ` Stephano Cetola [this message]
2026-08-22 22:34 ` [PATCH 5/5] usb: xhci: wait a real interval for interrupt endpoint transfers Stephano Cetola
2026-08-24 10:14 ` [PATCH 0/5] usb: xhci: fix endpoint halt and stall recovery Sascha Hauer
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=20260822-send-xhci-fixes-v1-4-22e1de3be715@cetola.net \
--to=stephano@cetola.net \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox