Merge commit 'v2.6.36-rc3' into x86/memblock
[linux-3.10.git] / arch / x86 / kernel / acpi / sleep.c
index 81e5ab6..e125207 100644 (file)
@@ -2,14 +2,16 @@
  * sleep.c - x86-specific ACPI sleep support.
  *
  *  Copyright (C) 2001-2003 Patrick Mochel
- *  Copyright (C) 2001-2003 Pavel Machek <pavel@suse.cz>
+ *  Copyright (C) 2001-2003 Pavel Machek <pavel@ucw.cz>
  */
 
 #include <linux/acpi.h>
 #include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/dmi.h>
 #include <linux/cpumask.h>
 #include <asm/segment.h>
+#include <asm/desc.h>
 
 #include "realmode/wakeup.h"
 #include "sleep.h"
@@ -21,7 +23,7 @@ unsigned long acpi_realmode_flags;
 static unsigned long acpi_realmode;
 
 #if defined(CONFIG_SMP) && defined(CONFIG_64BIT)
-static char temp_stack[10240];
+static char temp_stack[4096];
 #endif
 
 /**
@@ -77,16 +79,13 @@ int acpi_save_state_mem(void)
 #ifndef CONFIG_64BIT
        store_gdt((struct desc_ptr *)&header->pmode_gdt);
 
-       header->pmode_efer_low = nx_enabled;
-       if (header->pmode_efer_low & 1) {
-               /* This is strange, why not save efer, always? */
-               rdmsr(MSR_EFER, header->pmode_efer_low,
-                       header->pmode_efer_high);
-       }
+       if (rdmsr_safe(MSR_EFER, &header->pmode_efer_low,
+                      &header->pmode_efer_high))
+               header->pmode_efer_low = header->pmode_efer_high = 0;
 #endif /* !CONFIG_64BIT */
 
        header->pmode_cr0 = read_cr0();
-       header->pmode_cr4 = read_cr4();
+       header->pmode_cr4 = read_cr4_safe();
        header->realmode_flags = acpi_realmode_flags;
        header->real_magic = 0x12345678;
 
@@ -97,10 +96,13 @@ int acpi_save_state_mem(void)
 #else /* CONFIG_64BIT */
        header->trampoline_segment = setup_trampoline() >> 4;
 #ifdef CONFIG_SMP
-       stack_start.sp = temp_stack + 4096;
+       stack_start.sp = temp_stack + sizeof(temp_stack);
+       early_gdt_descr.address =
+                       (unsigned long)get_cpu_gdt_table(smp_processor_id());
+       initial_gs = per_cpu_offset(smp_processor_id());
 #endif
        initial_code = (unsigned long)wakeup_long64;
-       saved_magic = 0x123456789abcdef0;
+       saved_magic = 0x123456789abcdef0L;
 #endif /* CONFIG_64BIT */
 
        return 0;
@@ -115,29 +117,32 @@ void acpi_restore_state_mem(void)
 
 
 /**
- * acpi_reserve_bootmem - do _very_ early ACPI initialisation
+ * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
  *
  * We allocate a page from the first 1MB of memory for the wakeup
  * routine for when we come back from a sleep state. The
  * runtime allocator allows specification of <16MB pages, but not
  * <1MB pages.
  */
-void __init acpi_reserve_bootmem(void)
+void __init acpi_reserve_wakeup_memory(void)
 {
+       phys_addr_t mem;
+
        if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
                printk(KERN_ERR
                       "ACPI: Wakeup code way too big, S3 disabled.\n");
                return;
        }
 
-       acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
+       mem = memblock_find_in_range(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
 
-       if (!acpi_realmode) {
+       if (mem == MEMBLOCK_ERROR) {
                printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
                return;
        }
-
-       acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
+       acpi_realmode = (unsigned long) phys_to_virt(mem);
+       acpi_wakeup_address = mem;
+       memblock_x86_reserve_range(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
 }
 
 
@@ -153,7 +158,14 @@ static int __init acpi_sleep_setup(char *str)
 #ifdef CONFIG_HIBERNATION
                if (strncmp(str, "s4_nohwsig", 10) == 0)
                        acpi_no_s4_hw_signature();
+               if (strncmp(str, "s4_nonvs", 8) == 0) {
+                       pr_warning("ACPI: acpi_sleep=s4_nonvs is deprecated, "
+                                       "please use acpi_sleep=nonvs instead");
+                       acpi_nvs_nosave();
+               }
 #endif
+               if (strncmp(str, "nonvs", 5) == 0)
+                       acpi_nvs_nosave();
                if (strncmp(str, "old_ordering", 12) == 0)
                        acpi_old_suspend_ordering();
                str = strchr(str, ',');