Skip to content

Commit 413c1b3

Browse files
matnymangregkh
authored andcommitted
xhci: dbc: Fix full DbC transfer ring after several reconnects
[ Upstream commit a5c98e8 ] Pending requests will be flushed on disconnect, and the corresponding TRBs will be turned into No-op TRBs, which are ignored by the xHC controller once it starts processing the ring. If the USB debug cable repeatedly disconnects before ring is started then the ring will eventually be filled with No-op TRBs. No new transfers can be queued when the ring is full, and driver will print the following error message: "xhci_hcd 0000:00:14.0: failed to queue trbs" This is a normal case for 'in' transfers where TRBs are always enqueued in advance, ready to take on incoming data. If no data arrives, and device is disconnected, then ring dequeue will remain at beginning of the ring while enqueue points to first free TRB after last cancelled No-op TRB. s Solve this by reinitializing the rings when the debug cable disconnects and DbC is leaving the configured state. Clear the whole ring buffer and set enqueue and dequeue to the beginning of ring, and set cycle bit to its initial state. Cc: stable@vger.kernel.org Fixes: dfba217 ("usb: xhci: Add DbC support in xHCI driver") Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20250902105306.877476-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1bf3b02 commit 413c1b3

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/usb/host/xhci-dbgcap.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,25 @@ static void xhci_dbc_ring_init(struct xhci_ring *ring)
447447
xhci_initialize_ring_info(ring, 1);
448448
}
449449

450+
static int xhci_dbc_reinit_ep_rings(struct xhci_dbc *dbc)
451+
{
452+
struct xhci_ring *in_ring = dbc->eps[BULK_IN].ring;
453+
struct xhci_ring *out_ring = dbc->eps[BULK_OUT].ring;
454+
455+
if (!in_ring || !out_ring || !dbc->ctx) {
456+
dev_warn(dbc->dev, "Can't re-init unallocated endpoints\n");
457+
return -ENODEV;
458+
}
459+
460+
xhci_dbc_ring_init(in_ring);
461+
xhci_dbc_ring_init(out_ring);
462+
463+
/* set ep context enqueue, dequeue, and cycle to initial values */
464+
xhci_dbc_init_ep_contexts(dbc);
465+
466+
return 0;
467+
}
468+
450469
static struct xhci_ring *
451470
xhci_dbc_ring_alloc(struct device *dev, enum xhci_ring_type type, gfp_t flags)
452471
{
@@ -871,7 +890,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc)
871890
dev_info(dbc->dev, "DbC cable unplugged\n");
872891
dbc->state = DS_ENABLED;
873892
xhci_dbc_flush_requests(dbc);
874-
893+
xhci_dbc_reinit_ep_rings(dbc);
875894
return EVT_DISC;
876895
}
877896

@@ -881,7 +900,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc)
881900
writel(portsc, &dbc->regs->portsc);
882901
dbc->state = DS_ENABLED;
883902
xhci_dbc_flush_requests(dbc);
884-
903+
xhci_dbc_reinit_ep_rings(dbc);
885904
return EVT_DISC;
886905
}
887906

0 commit comments

Comments
 (0)