New: xhci: dbc: permanent "failed to queue trbs" wedge after 254 TRBs (commit 7ee645963075 never advances dep->ring->dequeue)
https://bugzilla.kernel.org/show_bug.cgi?id=222348
Bug ID: 222348
Summary: xhci: dbc: permanent "failed to queue trbs" wedge
after 254 TRBs (commit 7ee645963075 never advances
dep->ring->dequeue)
Product: Drivers
Version: 2.5
Hardware: Intel
OS: Linux
Status: NEW
Severity: normal
Priority: P3
Component: USB
Assignee: [email protected]
Reporter: [email protected]
Regression: NoAfter commit 7ee645963075 ("usb: xhci: remove legacy 'num_trbs_free' tracking", merged for v7.2-rc1 and backported to Ubuntu 26.04 7.0.0-44-generic), xHCI Debug Capability (xhci_dbc, /dev/ttyDBC0) deterministically wedges after exactly 254 bulk transfers (254 * 1024 B = 260,096 B). On transfer #255, xhci_dbc_queue_bulk_tx() permanently returns -EBUSY, dbc_ep_do_queue() logs failed to queue trbs, and TX stalls permanently at 0 B/s until cable disconnect or USB reset.
This regression is still present on torvalds/linux master (v7.4-rc5). ### Hardware & Kernel
- Controller: Intel 800-Series (Arrow Lake) PCH xHCI (0000:80:14.0), SuperSpeedPlus 10000M USB-C host-to-host cable
- Kernel tested: Ubuntu 26.04 7.0.0-44-generic (CONFIG_USB_XHCI_HCD=y, CONFIG_USB_XHCI_DBGCAP=y)
- Upstream verified: torvalds/linux v7.4-rc5 (drivers/usb/host/xhci-dbgcap.c)
### Root Cause
Commit 7ee645963075651d72f8d85bee428a9b7f1f148c removed ring->num_trbs_free and changed xhci_dbc_queue_bulk_tx() (drivers/usb/host/xhci-dbgcap.c:298) to:
if (xhci_num_trbs_free(ring) <= num_trbs)
return -EBUSY;
xhci_num_trbs_free(ring) (drivers/usb/host/xhci-ring.c:351) computes free TRBs dynamically from ring->enqueue to ring->dequeue.
However, drivers/usb/host/xhci-dbgcap.c NEVER advances dep->ring->dequeue for BULK_IN / BULK_OUT transfer rings (inc_evt_deq() is only called on dbc->ring_evt). As a result:
1. dep->ring->dequeue stays permanently pinned at &deq_seg->trbs[0].
2. On a 1-segment DbC transfer ring (TRBS_PER_SEGMENT = 256, Link TRB at index 255):
- Transfers 1..254 advance ring->enqueue from trbs[0] to trbs[254].
- After transfer #254, xhci_num_trbs_free(ring) returns 255 - 254 = 1.
- On transfer #255 (num_trbs = 1), xhci_num_trbs_free(ring) <= 1
evaluates true (1 <= 1) and returns -EBUSY.
3. dbc_ep_do_queue() (drivers/usb/host/xhci-dbgcap.c:361) logs failed to queue trbs and returns -EFAULT permanently.
### Deterministic Reproducer
Connect two Linux hosts via a passive USB-C 3.2 Gen 2 cable (1d6b:0010 / usb_debug on Host, echo enable > /sys/bus/pci/devices/0000:80:14.0/dbc on Target):
1. On Target (/dev/ttyDBC0) and Host (/dev/ttyUSB0), configure both TTYs in raw mode (stty -F <dev> raw -echo).
2. Stream >260 KiB in either direction (even paced slowly at 300 x 1024 B writes with a 2 ms delay between writes, ~4 Mbps):
- Target -> Host: delivers exactly 260,096 bytes (254 x 1024 B) at ~213
Mbps, then hangs permanently.
- Host -> Target: delivers exactly 260,096 bytes (254 x 1024 B) at ~130
Mbps, then hangs permanently.
- Paced 300 x 1024 B (2 ms gap): still wedges at exactly 260,096 bytes
(254.0 KiB), proving a deterministic TRB-count leak rather than congestion.
3. Target dmesg immediately logs:
xhci_hcd 0000:80:14.0: failed to queue trbs
### Proposed Fix
In drivers/usb/host/xhci-dbgcap.c, advance dep->ring->dequeue in dbc_handle_xfer_event() whenever a request is retired (in both the stale/stalled giveback loop and normal xhci_dbc_giveback()), wrapping over the Link TRB at TRBS_PER_SEGMENT - 1 (e.g., via inc_deq() or a small dbc_inc_deq(ring) helper):
/* Inside dbc_handle_xfer_event(), when retiring each req on dep->ring: */
ring->dequeue = req->trb + 1;
if (trb_is_link(ring->dequeue)) {
ring->deq_seg = ring->deq_seg->next;
ring->dequeue = ring->deq_seg->trbs;
}(Or alternatively call inc_deq(xhci, dep->ring) / revert 7ee645963075 on stable branches.)
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 222348] xhci: dbc: permanent "failed to queue trbs" wedge after 254 TRBs (commit 7ee645963075 never advances dep->ring->dequeue)
https://bugzilla.kernel.org/show_bug.cgi?id=222348
Michał Pecio ([email protected]) changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]
--- Comment #1 from Michał Pecio ([email protected]) --- It looks like maybe nobody noticed this bug, which is frankly not uncommon. Since you know the culprit commit, I suggest emailing its authors and linux-usb:
https://docs.kernel.org/admin-guide/reporting-issues.html
Or if you have a working fix, you may simply submit it:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.