summaryrefslogtreecommitdiff
path: root/sys/dev/usb/xhci.c
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2020-12-24 14:11:39 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2020-12-24 14:11:39 +0000
commitf9799f5bcfdecb0bb8b977e1fb6d611ca0146472 (patch)
tree32d2aba42898f5e0619b0d5a1b0361f5468839e7 /sys/dev/usb/xhci.c
parent2d4daa46fbbbee2808b6881d3a96f45eb2249f26 (diff)
Do proper accounting of zero length TDs. Currently a specific number
of zero length TDs can cause our free TRBs to run out, causing xhci(4) to return USBD_NOMEM to the USB stack. The issue was reported by Jonathon Fletcher <jonathon.fletcher () gmail ! com> -- Thanks! Reviewed/suggestions by patrick@. ok mpi@
Diffstat (limited to 'sys/dev/usb/xhci.c')
-rw-r--r--sys/dev/usb/xhci.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c
index 9ddf1015dca..a016dd0e68d 100644
--- a/sys/dev/usb/xhci.c
+++ b/sys/dev/usb/xhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xhci.c,v 1.119 2020/07/31 19:27:57 mglocker Exp $ */
+/* $OpenBSD: xhci.c,v 1.120 2020/12/24 14:11:38 mglocker Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -1135,8 +1135,10 @@ xhci_xfer_done(struct usbd_xfer *xfer)
i = (xp->ring.ntrb - 1);
}
xp->free_trbs += xx->ntrb;
+ xp->free_trbs += xx->zerotd;
xx->index = -1;
xx->ntrb = 0;
+ xx->zerotd = 0;
timeout_del(&xfer->timeout_handle);
usb_rem_task(xfer->device, &xfer->abort_task);
@@ -1842,6 +1844,7 @@ xhci_xfer_get_trb(struct xhci_softc *sc, struct usbd_xfer *xfer,
switch (last) {
case -1: /* This will be a zero-length TD. */
xp->pending_xfers[xp->ring.index] = NULL;
+ xx->zerotd += 1;
break;
case 0: /* This will be in a chain. */
xp->pending_xfers[xp->ring.index] = xfer;