From 7356f1de4b7b36f61f1e259b470319304d58db60 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 9 Mar 2019 17:53:31 -0500 Subject: [PATCH] XHCI: Properly handle partially-failed transfers. --- src/add-ons/kernel/busses/usb/xhci.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index e44325c501..6d1489a283 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -2223,7 +2223,9 @@ XHCI::HandleTransferComplete(xhci_trb* trb) // The TRB at offset trb_used will be the link TRB, which we do not // care about (and should not generate an interrupt at all.) // We really care about the properly last TRB, at index "count - 1". - if (offset == td->trb_used - 1) { + // Additionally, if we have an unsuccessful completion code, the transfer + // likely failed midway; so just accept it anyway. + if (offset == (td->trb_used - 1) || completionCode != COMP_SUCCESS) { _UnlinkDescriptorForPipe(td, endpoint); mutex_unlock(&endpoint->lock); @@ -2241,8 +2243,8 @@ XHCI::HandleTransferComplete(xhci_trb* trb) TRACE("HandleTransferComplete td %p done\n", td); } else { mutex_unlock(&endpoint->lock); - TRACE_ERROR("TRB %" B_PRIxADDR " was found, but it wasn't the " - "last in the TD!\n", source); + TRACE_ERROR("successful TRB %" B_PRIxADDR " was found, but it wasn't " + "the last in the TD!\n", source); } return; }