All of lore.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@kernel.org
To: linux-usb@vger.kernel.org
Subject: [Bug 222348] New: xhci: dbc: permanent "failed to queue trbs" wedge after 254 TRBs (commit 7ee645963075 never advances dep->ring->dequeue)
Date: Mon, 30 Nov 2026 01:44:19 +0000	[thread overview]
Message-ID: <bug-222348-208809@https.bugzilla.kernel.org/> (raw)

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: drivers_usb@kernel-bugs.kernel.org
          Reporter: mcboyle1865@gmail.com
        Regression: No

After 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.)

-- 
You are receiving this mail because:
You are watching the assignee of the bug.

                 reply	other threads:[~2026-11-30  1:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=bug-222348-208809@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@kernel.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.