Hi, I'm just touching this again because I'd like to see this
fix committed to CVS.

The problem that is fixed by this change is a complete deadlock 
while booting with USB2 HiSpeed enabled in BIOS.


On Mon, 8 Mar 2010 15:39:55 +0100 Christopher Zimmermann wrote:
> Heres my theory of what went wrong:
> 
> My (broken) BIOS does not know how to hand over the ehci host
> controller. Therefore the timeout.

That's the "ehci0: timed out waiting for BIOS" message

> Additionally when 'HiSpeed' is selected it turns on several System 
> Management Interupts in the ehci host controller and won't turn them 
> off when the kernel requests the handover.
> Later, when the kernel sets the CF bit the host controller issues a 
> SMI to notify the BIOS of the ownership change of mouse and keyboard 
> from ohci to the ehci host controller. The BIOS does not seem to like 
> this and the kernel/BIOS freezes.

-> complete deadlock

> My fix simply clears all SMI_ENABLE bits in the USBLEGCTLSTS register 
> when the BIOS does not acknowledge the handover. This violates the 
> spec, because the USBLEGCTLSTS register is supposed to be used by the 
> BIOS, not the OS.


Still this will only be done in case we timeout while waiting for 
the bios to acknowledge the handover.
Therefore this should be tested by people seeing the

ehci0: timed out waiting for BIOS

in their dmesg.



Christopher



Index: dev/pci/ehci_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/ehci_pci.c,v
retrieving revision 1.18
diff -u -p -r1.18 ehci_pci.c
--- dev/pci/ehci_pci.c  24 Jul 2009 03:18:58 -0000      1.18
+++ dev/pci/ehci_pci.c  8 Mar 2010 14:17:48 -0000
@@ -294,9 +294,26 @@ ehci_pci_takecontroller(struct ehci_pci_
                                        break;
                                DELAY(1000);
                        }
-                       if (legsup & EHCI_LEGSUP_BIOSOWNED)
-                               printf("%s: timed out waiting for BIOS\n",
+                       if (legsup & EHCI_LEGSUP_BIOSOWNED) {
+                               /*
+                                * The BIOS on the Asus K8S-MV/P does not
+                                * release the semaphore in time and won't
+                                * turn of System management interrupts.
+                                * It will get confused by the SMIs caused
+                                * by port changes when the CF bit goes up.
+                                * Therefore we do the job of the BIOS and
+                                * turn off SMIs. The SMI control bits
+                                * are bits 0-15 at register eecp+0x04.
+                                * See the intel EHCI spec.
+                                */
+                               printf("%s: timed out waiting for BIOS"
+                                       " - at least disable all SMIs.\n",
                                    sc->sc.sc_bus.bdev.dv_xname);
+                               legsup = pci_conf_read(sc->sc_pc, sc->sc_tag,
+                                       eecp + 0x04);
+                               pci_conf_write(sc->sc_pc, sc->sc_tag,
+                                       eecp + 0x04, legsup & 0xffff0000);
+                       }
                }
        }
 }



My dmesg after applying the change:

OpenBSD 4.7-current (sys) #55: Mon Mar 29 18:29:56 CEST 2010
    madro...@pundit:/var/obj/sys
[...]
ohci0 at pci0 dev 3 function 0 "SiS 5597/5598 USB" rev 0x0f: apic 
1 int 20 (irq 5), version 1.0, legacy support
ohci1 at pci0 dev 3 function 1 "SiS 5597/5598 USB" rev 0x0f: apic 1 int 21 (irq 
10), version 1.0, legacy support
ohci2 at pci0 dev 3 function 2 "SiS 5597/5598 USB" rev 0x0f: apic 1 int 22 (irq 
5), version 1.0, legacy support
ehci0 at pci0 dev 3 function 3 "SiS 7002 USB" rev 0x00: apic 1 int 23 (irq 10)
ehci0: timed out waiting for BIOS - at least disable all SMIs.
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "SiS EHCI root hub" rev 2.00/1.00 addr 1
[...]
usb1 at ohci0: USB revision 1.0
uhub1 at usb1 "SiS OHCI root hub" rev 1.00/1.00 addr 1
usb2 at ohci1: USB revision 1.0
uhub2 at usb2 "SiS OHCI root hub" rev 1.00/1.00 addr 1
usb3 at ohci2: USB revision 1.0
uhub3 at usb3 "SiS OHCI root hub" rev 1.00/1.00 addr 1
mtrr: Pentium Pro MTRR support
uhidev0 at uhub1 port 2 configuration 1 interface 0 "Sun Microsystems Type 6 
Keyboard" rev 1.10/2.00 addr 2
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes, country code 33
wskbd0 at ukbd0: console keyboard, using wsdisplay0
uhidev1 at uhub3 port 1 configuration 1 interface 0 "Logitech USB Optical 
Mouse" rev 2.00/43.01 addr 2
uhidev1: iclass 3/1
ums0 at uhidev1: 3 buttons, Z dir
wsmouse0 at ums0 mux 0
[...]

Reply via email to