Author: mmlr Date: 2010-03-07 23:46:11 +0100 (Sun, 07 Mar 2010) New Revision: 35780 Changeset: http://dev.haiku-os.org/changeset/35780/haiku Ticket: http://dev.haiku-os.org/ticket/2083 Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp Log: 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. Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2010-03-07 21:07:24 UTC (rev 35779) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2010-03-07 22:46:11 UTC (rev 35780) @@ -181,22 +181,24 @@ 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) { + if ((legacySupport & EHCI_LEGSUP_BIOSOWNED) == 0) + break; + TRACE_ALWAYS("controller is still bios owned, waiting\n"); snooze(50000); - } else - break; + } } if (legacySupport & EHCI_LEGSUP_BIOSOWNED) { @@ -520,7 +522,7 @@ 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