From 6fd4a3eea980b268b17565fba8b287b0e306a9c3 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 29 Jun 2022 11:56:13 -0400 Subject: [PATCH] XHCI: Set the DIR_IN bit on Status Stages even if there is no data. The referenced section of the specification gives no indication that the bit should not be set if there was no data; indeed it indicates it should always be set. This brings our behavior here in line with other OSes seem to do. Change-Id: I86b2eb2a6a5fa3af84fd0941e0a3ec601c7037bf Reviewed-on: https://review.haiku-os.org/c/haiku/+/5421 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/add-ons/kernel/busses/usb/xhci.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index 53df98aa9f..3f751eee08 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -766,12 +766,14 @@ XHCI::SubmitControlRequest(Transfer *transfer) descriptor->trbs[index].address = 0; descriptor->trbs[index].status = TRB_2_IRQ(0); descriptor->trbs[index].flags = TRB_3_TYPE(TRB_TYPE_STATUS_STAGE) - | ((directionIn && requestData->Length > 0) ? 0 : TRB_3_DIR_IN) | TRB_3_CHAIN_BIT | TRB_3_ENT_BIT | TRB_3_CYCLE_BIT; - // Status Stage is an OUT transfer when the device is sending data - // (XHCI 1.2 § 4.11.2.2 Table 4-7 p213), and the CHAIN bit must be - // set when using an Event Data TRB (as _LinkDescriptorForPipe does) - // (XHCI 1.2 § 6.4.1.2.3 Table 6-31 p472) + // The CHAIN bit must be set when using an Event Data TRB + // (XHCI 1.2 § 6.4.1.2.3 Table 6-31 p472). + + // Status Stage is an OUT transfer when the device is sending data + // (XHCI 1.2 § 4.11.2.2 Table 4-7 p213), otherwise set the IN bit. + if (requestData->Length == 0 || !directionIn) + descriptor->trbs[index].flags |= TRB_3_DIR_IN; descriptor->trb_used = index + 1;