From 63895cb5f2984b433d7f188c52e3f21e6723f610 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 29 Jun 2019 15:46:52 -0400 Subject: [PATCH] XHCI: Set the TRB_3_ENT_BIT on the final Link TRB, also. This should not be necessary due to a note in the specification, but it seems some controllers may not obey that; see inline comment. Possibly fixes the "mouse slowness" of #15115 that began following the Event Data changes. --- src/add-ons/kernel/busses/usb/xhci.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index eefdcd688d..25caa49427 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -842,7 +842,7 @@ XHCI::SubmitNormalRequest(Transfer *transfer) // // Note that we *do not* unset the CHAIN bit in this TRB, thus including // the Link TRB in this TD formally, which is required when using the - // ENT bit. (XHCI 1.1 § 4.12.3 p241.) + // ENT bit. (XHCI 1.2 § 4.12.3 p250.) td->trbs[td->trb_used - 1].flags |= TRB_3_ENT_BIT; if (!directionIn) { @@ -1755,12 +1755,20 @@ XHCI::_LinkDescriptorForPipe(xhci_td *descriptor, xhci_endpoint *endpoint) TRACE("_LinkDescriptorForPipe current %d, next %d\n", current, next); - // Compute link. + // Add a Link TRB to the end of the descriptor. addr_t addr = endpoint->trb_addr + eventdata * sizeof(xhci_trb); descriptor->trbs[descriptor->trb_used].address = addr; descriptor->trbs[descriptor->trb_used].status = TRB_2_IRQ(0); descriptor->trbs[descriptor->trb_used].flags = TRB_3_TYPE(TRB_TYPE_LINK) - | TRB_3_CHAIN_BIT | TRB_3_CYCLE_BIT; + | TRB_3_CHAIN_BIT | TRB_3_ENT_BIT | TRB_3_CYCLE_BIT; + // It is specified that (XHCI 1.2 § 4.12.3 Note 2 p251) if the TRB + // following one with the ENT bit set is a Link TRB, the Link TRB + // shall be evaluated *and* the subsequent TRB shall be. Thus, the + // TRB_3_ENT_BIT here *should* be unnecessary, as the last TRB in + // this TD proper should already have the ENT bit set. But at least + // some hardware, it seems, does not necessarily obey the note, so + // we add the ENT bit on the Link TRB, too. + #if !B_HOST_IS_LENDIAN // Convert endianness.