XHCI: Make sure we have at least one TRB in CreateDescriptorChain.

Linux seems to do the same thing. Confirmed as correct by korli
in #12929.
This commit is contained in:
Augustin Cavalier 2019-02-18 11:40:45 -05:00
parent b5ded9cc1a
commit db360a2064

View File

@ -883,6 +883,9 @@ XHCI::CreateDescriptorChain(size_t bufferSize, int32 &trbCount)
{
size_t packetSize = B_PAGE_SIZE * 16;
trbCount = (bufferSize + packetSize - 1) / packetSize;
if (trbCount == 0)
trbCount = 1;
// keep one trb for linking
int32 tdCount = (trbCount + XHCI_MAX_TRBS_PER_TD - 2)
/ (XHCI_MAX_TRBS_PER_TD - 1);