From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: matthew Boyle <mcboyle1865@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Niklas Neronin <niklas.neronin@linux.intel.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Michal Pecio <michal.pecio@gmail.com>
Subject: Re: Fwd: [PATCH] usb: xhci: dbc: advance transfer ring dequeue pointer on completion
Date: Thu, 3 Dec 2026 12:48:55 +0200 [thread overview]
Message-ID: <beafce26-aeb4-4d69-ae9f-74510d603d3e@linux.intel.com> (raw)
In-Reply-To: <CAD858L9Tq__bcFvEUHSTWyA=GQ8nJGq45L1F6vfwtZEEV4+4tg@mail.gmail.com>
On 12/2/26 18:32, matthew Boyle wrote:
> Good Morning,
> Commit 7ee645963075 ("usb: xhci: remove legacy 'num_trbs_free'
> tracking") removed ring->num_trbs_free and switched
> xhci_dbc_queue_bulk_tx() to xhci_num_trbs_free(ring), which computes
> free space from ring->enqueue and ring->dequeue.
>
> However, DbC transfer rings never updated ring->dequeue on transfer
> completion; previously only ring->num_trbs_free was incremented in
> dbc_handle_xfer_event(). As a result, ring->dequeue remains stuck at
> the start of the single-segment ring while ring->enqueue advances.
> After exactly 254 TRBs (254 * 1024 B = 260,096 B on a 256-TRB segment
> with one link TRB and the xhci_num_trbs_free(ring) <= num_trbs guard),
> xhci_num_trbs_free() drops to 1 and every subsequent bulk transfer
> fails permanently with -EBUSY ("failed to queue trbs").
nice catch, thanks
>
> Add a dbc_inc_deq() helper mirroring xhci_dbc_queue_trb()'s link-TRB
> wraparound and call it in dbc_handle_xfer_event() before giving back
> completed and stale stalled requests (while dbc->lock is still held,
> before completion callbacks can re-queue new TRBs).
The transfer event contains the dequeue TRB DMA address, how about setting
the ring->dequeue directly based on it instead.
Does this work for you:
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index 48ee6a4f9e1c..a9c011194cd8 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -835,6 +835,7 @@ static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event)
/* Match the pending request: */
list_for_each_entry(r, &dep->list_pending, list_pending) {
if (r->trb_dma == event->trans_event.buffer) {
+ ring->dequeue = xhci_dma_to_trb(ring->deq_seg, r->trb_dma, NULL);
req = r;
break;
}
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 7ccd89a4b995..bc9a162617dd 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -85,7 +85,7 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg,
return seg->dma + (segment_offset * sizeof(*trb));
}
-static union xhci_trb *xhci_dma_to_trb(struct xhci_segment *start_seg,
+union xhci_trb *xhci_dma_to_trb(struct xhci_segment *start_seg,
dma_addr_t dma,
struct xhci_segment **match_seg)
{
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 6201b6b24252..42cc7e592ccd 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1963,6 +1963,8 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci);
void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring);
unsigned int count_trbs(u64 addr, u64 len);
unsigned int xhci_num_trbs_free(struct xhci_ring *ring);
+union xhci_trb *xhci_dma_to_trb(struct xhci_segment *start_seg, dma_addr_t dma,
+ struct xhci_segment **match_seg);
void xhci_process_cancelled_tds(struct xhci_hcd *xhci, struct xhci_virt_ep *ep);
void xhci_update_erst_dequeue(struct xhci_hcd *xhci,
struct xhci_interrupter *ir,
Thanks
Mathias
next prev parent reply other threads:[~2026-12-03 10:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAD858L_rFUTS_63uBFb=HytY+U1DKSVtNTttKqXWSPf0Ba4TRA@mail.gmail.com>
[not found] ` <CAD858L_iB6zkTXk4czOfen3+PbGc2VjBNHio4y42L0k73vk0Uw@mail.gmail.com>
2026-12-02 16:32 ` Fwd: [PATCH] usb: xhci: dbc: advance transfer ring dequeue pointer on completion matthew Boyle
2026-12-03 3:52 ` Greg Kroah-Hartman
2026-12-03 10:48 ` Mathias Nyman [this message]
2026-12-03 11:05 ` Michal Pecio
2026-12-03 12:32 ` 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=beafce26-aeb4-4d69-ae9f-74510d603d3e@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mcboyle1865@gmail.com \
--cc=michal.pecio@gmail.com \
--cc=niklas.neronin@linux.intel.com \
--cc=stable@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.