[haiku-commits] haiku: hrev52885 - src/add-ons/kernel/busses/usb

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 18 Feb 2019 10:16:54 -0500 (EST)

hrev52885 adds 3 changesets to branch 'master'
old head: 29dcf8568b6cc112536955acfd7b4bc971baa742
new head: eae896c7aeff5fc0b641bcc0d5cc3629ec792588
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=eae896c7aeff+%5E29dcf8568b6c

----------------------------------------------------------------------------

6554cc220fbc: XHCI: Fix the build of tracing code.

a881209f38d9: XHCI: Minor tweaks and other changes.
  
   * Cap fSlotCount at the hardware level, not just at the software
     level.
   * Clear interrupts in init routine.
   * Write high DMA address of DCBAAP.
  
  Found by cross-comparing with DragonFlyBSD and OpenBSD.

eae896c7aeff: XHCI: Print command code in "unsuccessful command" log message.
  
  This should help with debugging #13772.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

1 file changed, 15 insertions(+), 14 deletions(-)
src/add-ons/kernel/busses/usb/xhci.cpp | 29 +++++++++++++++--------------

############################################################################

Commit:      6554cc220fbc0d950734f47d3427d7b95ee54559
URL:         https://git.haiku-os.org/haiku/commit/?id=6554cc220fbc
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Feb 18 15:03:47 2019 UTC

XHCI: Fix the build of tracing code.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index 8d690266df..b8c3dc3eb0 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -159,11 +159,8 @@ XHCI::XHCI(pci_info *info, Stack *stack)
 
        size_t mapSize = fPCIInfo->u.h0.base_register_sizes[0];
 
-       TRACE("map physical memory %08" B_PRIx32 " : %08" B_PRIx32 " "
-               "(base: %08" B_PRIxPHYSADDR "; offset: %" B_PRIx32 ");"
-               "size: %" B_PRId32 "\n", fPCIInfo->u.h0.base_registers[0],
-               fPCIInfo->u.h0.base_registers[1], physicalAddress, offset,
-               fPCIInfo->u.h0.base_register_sizes[0]);
+       TRACE("map physical memory %08" B_PRIxPHYSADDR ", size: %" B_PRId32 
"\n",
+               physicalAddress, mapSize);
 
        fRegisterArea = map_physical_memory("XHCI memory mapped registers",
                physicalAddress, mapSize, B_ANY_KERNEL_BLOCK_ADDRESS,
@@ -181,9 +178,9 @@ XHCI::XHCI(pci_info *info, Stack *stack)
        fDoorbellRegisterOffset = ReadCapReg32(XHCI_DBOFF) & ~0x3;
 
        TRACE("mapped registers: %p\n", fRegisters);
-       TRACE("operational register offset: %d\n", fOperationalRegisterOffset);
-       TRACE("runtime register offset: %p\n", fRuntimeRegisterOffset);
-       TRACE("doorbell register offset: %p\n", fDoorbellRegisterOffset);
+       TRACE("operational register offset: %" B_PRId32 "\n", 
fOperationalRegisterOffset);
+       TRACE("runtime register offset: %" B_PRId32 "\n", 
fRuntimeRegisterOffset);
+       TRACE("doorbell register offset: %" B_PRId32 "\n", 
fDoorbellRegisterOffset);
 
        TRACE_ALWAYS("interface version: 0x%04" B_PRIx32 "\n",
                HCI_VERSION(ReadCapReg32(XHCI_HCI_VERSION)));
@@ -402,9 +399,9 @@ XHCI::Start()
        fPortCount = HCS_MAX_PORTS(capabilities);
        if (fPortCount == 0) {
                TRACE_ERROR("Invalid number of ports: %u\n", fPortCount);
-               fPortCount = 0;
                return B_ERROR;
        }
+
        fSlotCount = HCS_MAX_SLOTS(capabilities);
        WriteOpReg(XHCI_CONFIG, fSlotCount);
 
@@ -471,7 +468,7 @@ XHCI::Start()
        for (uint32 i = 0; i < fScratchpadCount; i++) {
                phys_addr_t scratchDmaAddress;
                fScratchpadArea[i] = fStack->AllocateArea((void 
**)&fScratchpad[i],
-               &scratchDmaAddress, B_PAGE_SIZE, "Scratchpad Area");
+                       &scratchDmaAddress, B_PAGE_SIZE, "Scratchpad Area");
                if (fScratchpadArea[i] < B_OK) {
                        TRACE_ERROR("unable to create the scratchpad area\n");
                        return B_ERROR;
@@ -840,7 +837,7 @@ XHCI::AddTo(Stack *stack)
                if (item->class_base == PCI_serial_bus && item->class_sub == 
PCI_usb
                        && item->class_api == PCI_usb_xhci) {
                        TRACE_MODULE("found device at PCI:%d:%d:%d\n",
-                               item->bus, item->device, item->funcion);
+                               item->bus, item->device, item->function);
                        XHCI *bus = new(std::nothrow) XHCI(item, stack);
                        if (!bus) {
                                delete item;

############################################################################

Commit:      a881209f38d9cf2d5d5ce2bc63e2a7b5603ba7fa
URL:         https://git.haiku-os.org/haiku/commit/?id=a881209f38d9
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Feb 18 15:05:04 2019 UTC

XHCI: Minor tweaks and other changes.

 * Cap fSlotCount at the hardware level, not just at the software
   level.
 * Clear interrupts in init routine.
 * Write high DMA address of DCBAAP.

Found by cross-comparing with DragonFlyBSD and OpenBSD.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index b8c3dc3eb0..9eed51c166 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -403,6 +403,8 @@ XHCI::Start()
        }
 
        fSlotCount = HCS_MAX_SLOTS(capabilities);
+       if (fSlotCount > XHCI_MAX_DEVICES)
+               fSlotCount = XHCI_MAX_DEVICES;
        WriteOpReg(XHCI_CONFIG, fSlotCount);
 
        // find out which protocol is used for each port
@@ -446,6 +448,8 @@ XHCI::Start()
        fExitLatMax = HCS_U1_DEVICE_LATENCY(params3)
                + HCS_U2_DEVICE_LATENCY(params3);
 
+       // clear interrupts & disable device notifications
+       WriteOpReg(XHCI_STS, ReadOpReg(XHCI_STS));
        WriteOpReg(XHCI_DNCTRL, 0);
 
        // allocate Device Context Base Address array
@@ -478,7 +482,7 @@ XHCI::Start()
 
        TRACE("setting DCBAAP %" B_PRIxPHYSADDR "\n", dmaAddress);
        WriteOpReg(XHCI_DCBAAP_LO, (uint32)dmaAddress);
-       WriteOpReg(XHCI_DCBAAP_HI, /*(uint32)(dmaAddress >> 32)*/0);
+       WriteOpReg(XHCI_DCBAAP_HI, (uint32)(dmaAddress >> 32));
 
        // allocate Event Ring Segment Table
        uint8 *addr;

############################################################################

Revision:    hrev52885
Commit:      eae896c7aeff5fc0b641bcc0d5cc3629ec792588
URL:         https://git.haiku-os.org/haiku/commit/?id=eae896c7aeff
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Feb 18 15:15:55 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/13772

XHCI: Print command code in "unsuccessful command" log message.

This should help with debugging #13772.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index 9eed51c166..d816446318 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -2130,8 +2130,8 @@ XHCI::DoCommand(xhci_trb* trb)
        TRACE("Command Complete. Result: %" B_PRId32 "\n", completionCode);
        if (completionCode != COMP_SUCCESS) {
                uint32 errorCode = TRB_2_COMP_CODE_GET(fCmdResult[0]);
-               TRACE_ERROR("unsuccessful command, error %s (%" B_PRId32 ")\n",
-                       xhci_error_string(errorCode), errorCode);
+               TRACE_ERROR("unsuccessful command %" B_PRId32 ", error %s (%" 
B_PRId32 ")\n",
+                       TRB_3_TYPE_GET(trb->dwtrb3), 
xhci_error_string(errorCode), errorCode);
                status = B_IO_ERROR;
        }
 


Other related posts: