From f20f55692d80323582a713a2b5fbed8d7a8b817d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 15 Sep 2021 18:58:46 -0400 Subject: [PATCH] XHCI: The root hub address is always 1. AllocateAddress() is the pre-USB3 way of doing things; as we never use it anywhere else and it is specific to each BusManager, we always just got 1, which is what the root hub will always be anyway. Additionally, clarify the logic in _InsertEndpointForPipe that is special-casing the root hub. No functional change intended. --- src/add-ons/kernel/busses/usb/xhci.cpp | 13 +++++++------ src/add-ons/kernel/busses/usb/xhci.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index 216089a460..b26e7d668f 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -201,7 +201,6 @@ XHCI::XHCI(pci_info *info, Stack *stack) fCmdCompSem(-1), fStopThreads(false), fRootHub(NULL), - fRootHubAddress(0), fPortCount(0), fSlotCount(0), fScratchpadCount(0), @@ -664,8 +663,7 @@ XHCI::Start() TRACE_ERROR("HCH start up timeout\n"); } - fRootHubAddress = AllocateAddress(); - fRootHub = new(std::nothrow) XHCIRootHub(RootObject(), fRootHubAddress); + fRootHub = new(std::nothrow) XHCIRootHub(RootObject(), 1); if (!fRootHub) { TRACE_ERROR("no memory to allocate root hub\n"); return B_NO_MEMORY; @@ -693,7 +691,7 @@ status_t XHCI::SubmitTransfer(Transfer *transfer) { // short circuit the root hub - if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress) + if (transfer->TransferPipe()->DeviceAddress() == 1) return fRootHub->ProcessTransfer(this, transfer); TRACE("SubmitTransfer(%p)\n", transfer); @@ -1705,10 +1703,13 @@ XHCI::_InsertEndpointForPipe(Pipe *pipe) } Device* usbDevice = (Device *)pipe->Parent(); + if (usbDevice->Parent() == RootObject()) { + // root hub needs no initialization + return B_OK; + } + struct xhci_device *device = (struct xhci_device *) usbDevice->ControllerCookie(); - if (usbDevice->Parent() == RootObject()) - return B_OK; if (device == NULL) { panic("device is NULL\n"); return B_NO_INIT; diff --git a/src/add-ons/kernel/busses/usb/xhci.h b/src/add-ons/kernel/busses/usb/xhci.h index c7e108e9ff..d1974fbfe3 100644 --- a/src/add-ons/kernel/busses/usb/xhci.h +++ b/src/add-ons/kernel/busses/usb/xhci.h @@ -252,7 +252,6 @@ private: // Root Hub XHCIRootHub * fRootHub; - uint8 fRootHubAddress; // Port management uint8 fPortCount;