x86 acpi: Follow Windows behaviour more closely during reset.
authorKeir Fraser <keir@xen.org>
Fri, 10 Dec 2010 11:32:19 +0000 (11:32 +0000)
committerKeir Fraser <keir@xen.org>
Fri, 10 Dec 2010 11:32:19 +0000 (11:32 +0000)
This follows some changes proposed for upstream Linux:
 1. Do not check the FADT reset register size/offset
 2. Try ACPI poking twice during our reset attempt sequence

Hopefully this will help us reset reliably on a wider range of
platforms.

Signed-off-by: Keir Fraser <keir@xen.org>
xen/arch/x86/shutdown.c
xen/drivers/acpi/reboot.c

index 7fa264125ff8bb869919280c6479f893e8df83c3..7fbc33e485c0dfcd49754851d15af36dc617857e 100644 (file)
@@ -302,7 +302,8 @@ static void __machine_restart(void *pdelay)
 
 void machine_restart(unsigned int delay_millisecs)
 {
-    int i;
+    unsigned int i, attempt;
+    enum reboot_type orig_reboot_type = reboot_type;
 
     watchdog_disable();
     console_start_sync();
@@ -337,7 +338,7 @@ void machine_restart(unsigned int delay_millisecs)
     /* Rebooting needs to touch the page at absolute address 0. */
     *((unsigned short *)__va(0x472)) = reboot_mode;
 
-    for ( ; ; )
+    for ( attempt = 0; ; attempt++ )
     {
         switch ( reboot_type )
         {
@@ -350,19 +351,29 @@ void machine_restart(unsigned int delay_millisecs)
                 outb(0xfe,0x64); /* pulse reset low */
                 udelay(50);
             }
-            /* fall through */
+            /*
+             * If this platform supports ACPI reset, we follow a Windows-style
+             * reboot attempt sequence:
+             *   ACPI -> KBD -> ACPI -> KBD
+             * After this we revert to our usual sequence:
+             *   KBD -> TRIPLE -> KBD -> TRIPLE -> KBD -> ...
+             */
+            reboot_type = (((attempt == 0) && (orig_reboot_type == BOOT_ACPI))
+                           ? BOOT_ACPI : BOOT_TRIPLE);
+            break;
         case BOOT_TRIPLE:
             asm volatile ( "lidt %0 ; int3" : "=m" (no_idt) );
+            reboot_type = BOOT_KBD;
             break;
         case BOOT_BIOS:
             machine_real_restart(jump_to_bios, sizeof(jump_to_bios));
+            reboot_type = BOOT_KBD;
             break;
         case BOOT_ACPI:
             acpi_reboot();
+            reboot_type = BOOT_KBD;
             break;
         }
-
-        reboot_type = BOOT_KBD;
     }
 }
 
index 69ea8afeead81eef99bcaa3091b759c935e4b872..744c500a763dabc1517a4ac72521216f004080a5 100644 (file)
@@ -10,9 +10,10 @@ void acpi_reboot(void)
 
        rr = &acpi_gbl_FADT.reset_register;
 
-       /* Is the reset register supported? */
-       if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) ||
-           (rr->bit_width != 8) || (rr->bit_offset != 0))
+       /* Is the reset register supported? The spec says we should be
+        * checking the bit width and bit offset, but Windows ignores
+        * these fields */
+       if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER))
                return;
 
        reset_value = acpi_gbl_FADT.reset_value;