Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Michal Pecio <michal.pecio@gmail.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: matthew Boyle <mcboyle1865@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Niklas Neronin <niklas.neronin@linux.intel.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] usb: xhci: dbc: advance transfer ring dequeue pointer on completion
Date: Thu, 3 Dec 2026 12:05:04 +0100	[thread overview]
Message-ID: <20261203120504.59ff2fca.michal.pecio@gmail.com> (raw)
In-Reply-To: <beafce26-aeb4-4d69-ae9f-74510d603d3e@linux.intel.com>

On Thu, 3 Dec 2026 12:48:55 +0200, Mathias Nyman wrote:
> 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;
>   		}

Not familiar with DBC, but I suspect you actually want:

ring->dequeue = xhci_dma_to_trb(ring->deq_seg, r->trb_dma, &ring->deq_seg);

Regards,
Michal

      reply	other threads:[~2026-12-03 11:05 UTC|newest]

Thread overview: 4+ 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
2026-12-03 11:05       ` Michal Pecio [this message]

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=20261203120504.59ff2fca.michal.pecio@gmail.com \
    --to=michal.pecio@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mcboyle1865@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox