From 2cf04ca7280a51addb83525c1a00166d77cba0e9 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 7 Mar 2010 22:46:11 +0000 Subject: [PATCH] Don't take ownership by writing the OS-owned semaphore when the BIOS-owned flag isn't set. I'd tend to say that's a rather odd interpretation of the specified protocol if a BIOS goes mad if the sem is written to while it doesn't actually own the controller (it should just be a no-op in that case and directly set the sem state). But it seems this is what others do as well (FreeBSD, Linux) so we follow. Thanks to vegardw in #2083 for researching into this and proposing this fix. Minor other cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35780 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/busses/usb/ehci.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/ehci.cpp b/src/add-ons/kernel/busses/usb/ehci.cpp index 08dbc66aa6..696a6af82f 100644 --- a/src/add-ons/kernel/busses/usb/ehci.cpp +++ b/src/add-ons/kernel/busses/usb/ehci.cpp @@ -181,22 +181,24 @@ EHCI::EHCI(pci_info *info, Stack *stack) uint32 legacySupport = 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) - TRACE_ALWAYS("the host controller is bios owned\n"); + if ((legacySupport & EHCI_LEGSUP_BIOSOWNED) != 0) { + TRACE_ALWAYS("the host controller is bios owned, claiming" + " ownership\n"); - TRACE_ALWAYS("claiming ownership of the host controller\n"); - sPCIModule->write_pci_config(fPCIInfo->bus, fPCIInfo->device, - fPCIInfo->function, extendedCapPointer + 3, 1, 1); + sPCIModule->write_pci_config(fPCIInfo->bus, fPCIInfo->device, + fPCIInfo->function, extendedCapPointer + 3, 1, 1); - for (int32 i = 0; i < 20; i++) { - legacySupport = sPCIModule->read_pci_config(fPCIInfo->bus, - fPCIInfo->device, fPCIInfo->function, extendedCapPointer, 4); + 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; - if (legacySupport & EHCI_LEGSUP_BIOSOWNED) { TRACE_ALWAYS("controller is still bios owned, waiting\n"); snooze(50000); - } else - break; + } } if (legacySupport & EHCI_LEGSUP_BIOSOWNED) { @@ -520,7 +522,7 @@ status_t EHCI::AddTo(Stack *stack) { #ifdef TRACE_USB - set_dprintf_enabled(true); + set_dprintf_enabled(true); #ifndef HAIKU_TARGET_PLATFORM_HAIKU load_driver_symbols("ehci"); #endif