From: Steven Noonan Instead of waiting a painful 5000ms, quirk_usb_disable_ehci() now does a 250ms loop to verify the EHCI handoff completed. If it didn't, it tries to force the ownership by writing the OS ownership bit. It then does a second 250ms loop which will terminate early if the bit change is reflected when reading the ownership state. If it's still not proper, print a warning. (akpm: Might break things. david-b thinks that there were devices out there which need the 5000ms) Signed-off-by: Steven Noonan Cc: Alan Stern Cc: Greg KH Cc: David Brownell Signed-off-by: Andrew Morton --- drivers/usb/host/pci-quirks.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff -puN drivers/usb/host/pci-quirks.c~drivers-usb-host-pci-quirksc-wait-for-ehci-handoff-far-too-long-in-quirk_usb_disable_ehci drivers/usb/host/pci-quirks.c --- a/drivers/usb/host/pci-quirks.c~drivers-usb-host-pci-quirksc-wait-for-ehci-handoff-far-too-long-in-quirk_usb_disable_ehci +++ a/drivers/usb/host/pci-quirks.c @@ -271,7 +271,7 @@ static void __devinit quirk_usb_disable_ /* if boot firmware now owns EHCI, spin till * it hands it over. */ - msec = 5000; + msec = 250; while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) { tried_handoff = 1; msleep(10); @@ -283,9 +283,16 @@ static void __devinit quirk_usb_disable_ /* well, possibly buggy BIOS... try to shut * it down, and hope nothing goes too wrong */ - dev_warn(&pdev->dev, "EHCI: BIOS handoff failed" - " (BIOS bug?) %08x\n", cap); + dev_warn(&pdev->dev, "EHCI: Forcing OS ownership\n"); pci_write_config_byte(pdev, offset + 2, 0); + + /* verify that the BIOS handoff was forced */ + msec = 250; + while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) { + msleep(10); + msec -= 10; + pci_read_config_dword(pdev, offset, &cap); + } } /* just in case, always disable EHCI SMIs */ @@ -293,6 +300,12 @@ static void __devinit quirk_usb_disable_ offset + EHCI_USBLEGCTLSTS, 0); + pci_read_config_dword(pdev, offset, &cap); + if (cap & EHCI_USBLEGSUP_BIOS) { + dev_warn(&pdev->dev, "EHCI: BIOS handoff failed" + " (BIOS bug?) %08x\n", cap); + } + /* If the BIOS ever owned the controller then we * can't expect any power sessions to remain intact. */ _