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

  • From: pulkomandy@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 12 Mar 2018 08:25:37 -0400 (EDT)

hrev51848 adds 1 changeset to branch 'master'
old head: 8bcb93452aa7dd6a30f7ae6449c2ee3e787786d3
new head: 137135a10dc6322773be9da67861c05f53b709a5
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=137135a10dc6+%5E8bcb93452aa7

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

137135a10dc6: EHCI USB: process the extended capabilities chain
  
  ...instead of the first one only.

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

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

Revision:    hrev51848
Commit:      137135a10dc6322773be9da67861c05f53b709a5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=137135a10dc6
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Sun Dec 14 11:52:54 2014 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Mon Mar 12 12:25:34 2018 UTC

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

2 files changed, 35 insertions(+), 35 deletions(-)
src/add-ons/kernel/busses/usb/ehci.cpp        | 69 +++++++++++------------
src/add-ons/kernel/busses/usb/ehci_hardware.h |  1 +

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

diff --git a/src/add-ons/kernel/busses/usb/ehci.cpp 
b/src/add-ons/kernel/busses/usb/ehci.cpp
index c12c1d89f4..f689b4b1e0 100644
--- a/src/add-ons/kernel/busses/usb/ehci.cpp
+++ b/src/add-ons/kernel/busses/usb/ehci.cpp
@@ -252,54 +252,53 @@ EHCI::EHCI(pci_info *info, Stack *stack)
 
        uint32 extendedCapPointer = ReadCapReg32(EHCI_HCCPARAMS) >> 
EHCI_ECP_SHIFT;
        extendedCapPointer &= EHCI_ECP_MASK;
-       if (extendedCapPointer > 0) {
+       for (uint32 eec = extendedCapPointer; eec != 0; extendedCapPointer = 
EHCI_EECP_NEXT(eec)) {
                TRACE("extended capabilities register at %" B_PRIu32 "\n",
                        extendedCapPointer);
 
-               uint32 legacySupport = 
sPCIModule->read_pci_config(fPCIInfo->bus,
+               eec = sPCIModule->read_pci_config(fPCIInfo->bus,
                        fPCIInfo->device, fPCIInfo->function, 
extendedCapPointer, 4);
-               if ((legacySupport & EHCI_LEGSUP_CAPID_MASK) == 
EHCI_LEGSUP_CAPID) {
-                       if ((legacySupport & EHCI_LEGSUP_BIOSOWNED) != 0) {
-                               TRACE_ALWAYS("the host controller is bios 
owned, claiming"
-                                       " ownership\n");
 
-                               sPCIModule->write_pci_config(fPCIInfo->bus, 
fPCIInfo->device,
-                                       fPCIInfo->function, extendedCapPointer 
+ 3, 1, 1);
+               if ((eec & EHCI_LEGSUP_CAPID_MASK) != EHCI_LEGSUP_CAPID)
+                       continue;
 
-                               for (int32 i = 0; i < 20; i++) {
-                                       legacySupport = 
sPCIModule->read_pci_config(fPCIInfo->bus,
-                                               fPCIInfo->device, 
fPCIInfo->function,
-                                               extendedCapPointer, 4);
+               uint32 legacySupport = eec;
 
-                                       if ((legacySupport & 
EHCI_LEGSUP_BIOSOWNED) == 0)
-                                               break;
+               if ((legacySupport & EHCI_LEGSUP_BIOSOWNED) != 0) {
+                       TRACE_ALWAYS("the host controller is bios owned, 
claiming"
+                               " ownership\n");
 
-                                       TRACE_ALWAYS("controller is still bios 
owned, waiting\n");
-                                       snooze(50000);
-                               }
-                       }
+                       sPCIModule->write_pci_config(fPCIInfo->bus, 
fPCIInfo->device,
+                               fPCIInfo->function, extendedCapPointer + 3, 1, 
1);
 
-                       if (legacySupport & EHCI_LEGSUP_BIOSOWNED) {
-                               TRACE_ERROR("bios won't give up control over 
the host "
-                                       "controller (ignoring)\n");
-                       } else if (legacySupport & EHCI_LEGSUP_OSOWNED) {
-                               TRACE_ALWAYS(
-                                       "successfully took ownership of the 
host controller\n");
+                       for (int32 i = 0; i < 20; i++) {
+                               legacySupport = 
sPCIModule->read_pci_config(fPCIInfo->bus,
+                                       fPCIInfo->device, fPCIInfo->function,
+                                       extendedCapPointer, 4);
+
+                               if ((legacySupport & EHCI_LEGSUP_BIOSOWNED) == 
0)
+                                       break;
+
+                               TRACE_ALWAYS("controller is still bios owned, 
waiting\n");
+                               snooze(50000);
                        }
+               }
 
-                       // Force off the BIOS owned flag, and clear all SMIs. 
Some BIOSes
-                       // do indicate a successful handover but do not remove 
their SMIs
-                       // and then freeze the system when interrupts are 
generated.
-                       sPCIModule->write_pci_config(fPCIInfo->bus, 
fPCIInfo->device,
-                               fPCIInfo->function, extendedCapPointer + 2, 1, 
0);
-                       sPCIModule->write_pci_config(fPCIInfo->bus, 
fPCIInfo->device,
-                               fPCIInfo->function, extendedCapPointer + 4, 4, 
0);
-               } else {
+               if (legacySupport & EHCI_LEGSUP_BIOSOWNED) {
+                       TRACE_ERROR("bios won't give up control over the host "
+                               "controller (ignoring)\n");
+               } else if (legacySupport & EHCI_LEGSUP_OSOWNED) {
                        TRACE_ALWAYS(
-                               "extended capability is not a legacy support 
register\n");
+                               "successfully took ownership of the host 
controller\n");
                }
-       } else {
-               TRACE_ALWAYS("no extended capabilities register\n");
+
+               // Force off the BIOS owned flag, and clear all SMIs. Some 
BIOSes
+               // do indicate a successful handover but do not remove their 
SMIs
+               // and then freeze the system when interrupts are generated.
+               sPCIModule->write_pci_config(fPCIInfo->bus, fPCIInfo->device,
+                       fPCIInfo->function, extendedCapPointer + 2, 1, 0);
+               sPCIModule->write_pci_config(fPCIInfo->bus, fPCIInfo->device,
+                       fPCIInfo->function, extendedCapPointer + 4, 4, 0);
        }
 
        // disable interrupts
diff --git a/src/add-ons/kernel/busses/usb/ehci_hardware.h 
b/src/add-ons/kernel/busses/usb/ehci_hardware.h
index 1348303859..79be0b3202 100644
--- a/src/add-ons/kernel/busses/usb/ehci_hardware.h
+++ b/src/add-ons/kernel/busses/usb/ehci_hardware.h
@@ -103,6 +103,7 @@
 // Extended Capabilities
 #define EHCI_ECP_SHIFT                 8                       // Extended 
Capability Pointer
 #define EHCI_ECP_MASK                  0xff
+#define EHCI_EECP_NEXT(x)              (((x) >> 8) & 0xff)
 #define EHCI_LEGSUP_CAPID_MASK 0xff
 #define EHCI_LEGSUP_CAPID              0x01
 #define EHCI_LEGSUP_OSOWNED            (1 << 24)       // OS Owned Semaphore


Other related posts:

  • » [haiku-commits] haiku: hrev51848 - src/add-ons/kernel/busses/usb - pulkomandy