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

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 10 Aug 2019 23:45:47 -0400 (EDT)

hrev53364 adds 3 changesets to branch 'master'
old head: da73ed96dd833549c0d24544a5113e942f7e6be6
new head: c8e11499ccb07ed540de5565af34735c4d146855
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=c8e11499ccb0+%5Eda73ed96dd83

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

a614ac810150: XHCI: Remove unused and unnecessary data structure definitions.

8bfe3d25f432: XHCI: Rename ERST_EHB to ERDP_BUSY for clarity's sake.
  
  No functional change intended.

c8e11499ccb0: XHCI: Force an event ring poll if a first timeout occurs on 
commands.
  
  FreeBSD does something similar here. May help with some of the
  stranger event ring lockups.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

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

2 files changed, 18 insertions(+), 22 deletions(-)
src/add-ons/kernel/busses/usb/xhci.cpp        | 25 +++++++++++++++--------
src/add-ons/kernel/busses/usb/xhci_hardware.h | 15 +-------------

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

Commit:      a614ac810150ae28355d4a6b4239f1834d13a68d
URL:         https://git.haiku-os.org/haiku/commit/?id=a614ac810150
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Aug 11 02:48:01 2019 UTC

XHCI: Remove unused and unnecessary data structure definitions.

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

diff --git a/src/add-ons/kernel/busses/usb/xhci_hardware.h 
b/src/add-ons/kernel/busses/usb/xhci_hardware.h
index 2e3a085b0f..711bfcb8fb 100644
--- a/src/add-ons/kernel/busses/usb/xhci_hardware.h
+++ b/src/add-ons/kernel/busses/usb/xhci_hardware.h
@@ -319,19 +319,6 @@ struct xhci_trb {
 } __attribute__((__aligned__(4)));
 
 
-struct xhci_segment {
-       xhci_trb *              trbs;
-       xhci_segment *  next;
-};
-
-
-struct xhci_ring {
-       xhci_segment *  first_seg;
-       xhci_trb *              enqueue;
-       xhci_trb *              dequeue;
-};
-
-
 // Section 6.5
 struct xhci_erst_element {
        uint64  rs_addr;

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

Commit:      8bfe3d25f432eb4af3a998bd504cb628c98784b7
URL:         https://git.haiku-os.org/haiku/commit/?id=8bfe3d25f432
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Aug 11 03:02:20 2019 UTC

XHCI: Rename ERST_EHB to ERDP_BUSY for clarity's sake.

No functional change intended.

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

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index e2d072deb7..2b5028c154 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -2378,8 +2378,8 @@ XHCI::Ring(uint8 slot, uint8 endpoint)
 
        WriteDoorReg32(XHCI_DOORBELL(slot), XHCI_DOORBELL_TARGET(endpoint)
                | XHCI_DOORBELL_STREAMID(0));
-       /* Flush PCI posted writes */
        ReadDoorReg32(XHCI_DOORBELL(slot));
+               // Flush PCI writes
 }
 
 
@@ -2829,8 +2829,7 @@ XHCI::ProcessEvents()
        fEventCcs = j;
 
        uint64 addr = fErst->rs_addr + i * sizeof(xhci_trb);
-       addr |= ERST_EHB;
-       WriteRunReg32(XHCI_ERDP_LO(0), (uint32)addr);
+       WriteRunReg32(XHCI_ERDP_LO(0), (uint32)addr | ERDP_BUSY);
        WriteRunReg32(XHCI_ERDP_HI(0), (uint32)(addr >> 32));
 }
 
diff --git a/src/add-ons/kernel/busses/usb/xhci_hardware.h 
b/src/add-ons/kernel/busses/usb/xhci_hardware.h
index 711bfcb8fb..24ae8df2d7 100644
--- a/src/add-ons/kernel/busses/usb/xhci_hardware.h
+++ b/src/add-ons/kernel/busses/usb/xhci_hardware.h
@@ -120,7 +120,7 @@
 #define XHCI_ERDP_LO(n)                (0x0038 + (0x20 * (n)))
 #define XHCI_ERDP_HI(n)                (0x003C + (0x20 * (n)))
 // Event Handler Busy (EHB)
-#define ERST_EHB                       (1 << 3)
+#define ERDP_BUSY                      (1 << 3)
 
 
 // Host Controller Doorbell Registers

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

Revision:    hrev53364
Commit:      c8e11499ccb07ed540de5565af34735c4d146855
URL:         https://git.haiku-os.org/haiku/commit/?id=c8e11499ccb0
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Aug 11 03:45:15 2019 UTC

XHCI: Force an event ring poll if a first timeout occurs on commands.

FreeBSD does something similar here. May help with some of the
stranger event ring lockups.

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

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index 2b5028c154..c0f9b34ac2 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -2567,12 +2567,22 @@ XHCI::DoCommand(xhci_trb* trb)
        QueueCommand(trb);
        Ring(0, 0);
 
-       if (acquire_sem_etc(fCmdCompSem, 1, B_RELATIVE_TIMEOUT, 1 * 1000 * 
1000) < B_OK) {
-               TRACE("Unable to obtain fCmdCompSem!\n");
-               fCmdAddr = 0;
-               Unlock();
-               return B_TIMED_OUT;
+       // Begin with a 50ms timeout.
+       if (acquire_sem_etc(fCmdCompSem, 1, B_RELATIVE_TIMEOUT, 50 * 1000) != 
B_OK) {
+               // We've hit the timeout. In some error cases, interrupts are 
not
+               // generated; so here we force the event ring to be polled once.
+               release_sem(fEventSem);
+
+               // Now try again, this time with a 750ms timeout.
+               if (acquire_sem_etc(fCmdCompSem, 1, B_RELATIVE_TIMEOUT,
+                               750 * 1000) != B_OK) {
+                       TRACE("Unable to obtain fCmdCompSem!\n");
+                       fCmdAddr = 0;
+                       Unlock();
+                       return B_TIMED_OUT;
+               }
        }
+
        // eat up sems that have been released by multiple interrupts
        int32 semCount = 0;
        get_sem_count(fCmdCompSem, &semCount);


Other related posts:

  • » [haiku-commits] haiku: hrev53364 - src/add-ons/kernel/busses/usb - waddlesplash