From 0d3250fdb594e281f09de01c70c5aff44ed546aa Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 19 Feb 2020 12:26:35 -0500 Subject: [PATCH] XHCI: Round TD Size up instead of down. This is what the specification dictates. --- src/add-ons/kernel/busses/usb/xhci.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index db67024c03..330ef29d77 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -822,6 +822,7 @@ XHCI::SubmitNormalRequest(Transfer *transfer) return B_NO_MEMORY; // Normal Stage + const size_t maxPacketSize = pipe->MaxPacketSize(); size_t remaining = transfer->DataLength(); for (int32 i = 0; i < trbCount; i++) { int32 trbLength = (remaining < trbSize) ? remaining : trbSize; @@ -831,7 +832,7 @@ XHCI::SubmitNormalRequest(Transfer *transfer) // remaining maximum-size *packets* in this TD, *not* including the // packets in the current TRB, and capped at 31 if there are more // than 31 packets remaining in the TD. (XHCI 1.2 ยง 4.11.2.4 p218.) - int32 tdSize = remaining / pipe->MaxPacketSize(); + int32 tdSize = (remaining + maxPacketSize - 1) / maxPacketSize; if (tdSize > 31) tdSize = 31;