]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/power/swsusp.c
Merge git://git.infradead.org/mtd-2.6
[linux-2.6-omap-h63xx.git] / kernel / power / swsusp.c
index 78b6e71b08131ad1a3d3cbec25d1a79f2d4e26f4..17f669c83012e95121d9d8930a32d3bd25c080aa 100644 (file)
@@ -62,6 +62,16 @@ unsigned long image_size = 500 * 1024 * 1024;
 
 int in_suspend __nosavedata = 0;
 
+#ifdef CONFIG_HIGHMEM
+unsigned int count_highmem_pages(void);
+int save_highmem(void);
+int restore_highmem(void);
+#else
+static inline int save_highmem(void) { return 0; }
+static inline int restore_highmem(void) { return 0; }
+static inline unsigned int count_highmem_pages(void) { return 0; }
+#endif
+
 /**
  *     The following functions are used for tracing the allocated
  *     swap pages, so that they can be freed in case of an error.
@@ -182,14 +192,16 @@ int swsusp_shrink_memory(void)
 
        printk("Shrinking memory...  ");
        do {
-               size = 2 * count_special_pages();
+               size = 2 * count_highmem_pages();
                size += size / 50 + count_data_pages();
                size += (size + PBES_PER_PAGE - 1) / PBES_PER_PAGE +
                        PAGES_FOR_IO;
                tmp = size;
                for_each_zone (zone)
-                       if (!is_highmem(zone))
+                       if (!is_highmem(zone) && populated_zone(zone)) {
                                tmp -= zone->free_pages;
+                               tmp += zone->lowmem_reserve[ZONE_NORMAL];
+                       }
                if (tmp > 0) {
                        tmp = __shrink_memory(tmp);
                        if (!tmp)
@@ -224,7 +236,7 @@ int swsusp_suspend(void)
                goto Enable_irqs;
        }
 
-       if ((error = save_special_mem())) {
+       if ((error = save_highmem())) {
                printk(KERN_ERR "swsusp: Not enough free pages for highmem\n");
                goto Restore_highmem;
        }
@@ -235,7 +247,7 @@ int swsusp_suspend(void)
        /* Restore control flow magically appears here */
        restore_processor_state();
 Restore_highmem:
-       restore_special_mem();
+       restore_highmem();
        device_power_up();
 Enable_irqs:
        local_irq_enable();
@@ -261,7 +273,7 @@ int swsusp_resume(void)
         */
        swsusp_free();
        restore_processor_state();
-       restore_special_mem();
+       restore_highmem();
        touch_softlockup_watchdog();
        device_power_up();
        local_irq_enable();