diff options
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/disk.c | 12 | ||||
-rw-r--r-- | kernel/power/main.c | 16 | ||||
-rw-r--r-- | kernel/power/process.c | 6 | ||||
-rw-r--r-- | kernel/power/swsusp.c | 36 |
4 files changed, 41 insertions, 29 deletions
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index fb8de63c2919..3ec789c6b537 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
19 | #include <linux/mount.h> | ||
20 | |||
19 | #include "power.h" | 21 | #include "power.h" |
20 | 22 | ||
21 | 23 | ||
@@ -234,6 +236,16 @@ static int software_resume(void) | |||
234 | { | 236 | { |
235 | int error; | 237 | int error; |
236 | 238 | ||
239 | if (!swsusp_resume_device) { | ||
240 | if (!strlen(resume_file)) | ||
241 | return -ENOENT; | ||
242 | swsusp_resume_device = name_to_dev_t(resume_file); | ||
243 | pr_debug("swsusp: Resume From Partition %s\n", resume_file); | ||
244 | } else { | ||
245 | pr_debug("swsusp: Resume From Partition %d:%d\n", | ||
246 | MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); | ||
247 | } | ||
248 | |||
237 | if (noresume) { | 249 | if (noresume) { |
238 | /** | 250 | /** |
239 | * FIXME: If noresume is specified, we need to find the partition | 251 | * FIXME: If noresume is specified, we need to find the partition |
diff --git a/kernel/power/main.c b/kernel/power/main.c index c94cb9e95090..71aa0fd22007 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -19,6 +19,9 @@ | |||
19 | 19 | ||
20 | #include "power.h" | 20 | #include "power.h" |
21 | 21 | ||
22 | /*This is just an arbitrary number */ | ||
23 | #define FREE_PAGE_NUMBER (100) | ||
24 | |||
22 | DECLARE_MUTEX(pm_sem); | 25 | DECLARE_MUTEX(pm_sem); |
23 | 26 | ||
24 | struct pm_ops * pm_ops = NULL; | 27 | struct pm_ops * pm_ops = NULL; |
@@ -49,6 +52,7 @@ void pm_set_ops(struct pm_ops * ops) | |||
49 | static int suspend_prepare(suspend_state_t state) | 52 | static int suspend_prepare(suspend_state_t state) |
50 | { | 53 | { |
51 | int error = 0; | 54 | int error = 0; |
55 | unsigned int free_pages; | ||
52 | 56 | ||
53 | if (!pm_ops || !pm_ops->enter) | 57 | if (!pm_ops || !pm_ops->enter) |
54 | return -EPERM; | 58 | return -EPERM; |
@@ -67,6 +71,16 @@ static int suspend_prepare(suspend_state_t state) | |||
67 | goto Thaw; | 71 | goto Thaw; |
68 | } | 72 | } |
69 | 73 | ||
74 | if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) { | ||
75 | pr_debug("PM: free some memory\n"); | ||
76 | shrink_all_memory(FREE_PAGE_NUMBER - free_pages); | ||
77 | if (nr_free_pages() < FREE_PAGE_NUMBER) { | ||
78 | error = -ENOMEM; | ||
79 | printk(KERN_ERR "PM: No enough memory\n"); | ||
80 | goto Thaw; | ||
81 | } | ||
82 | } | ||
83 | |||
70 | if (pm_ops->prepare) { | 84 | if (pm_ops->prepare) { |
71 | if ((error = pm_ops->prepare(state))) | 85 | if ((error = pm_ops->prepare(state))) |
72 | goto Thaw; | 86 | goto Thaw; |
@@ -194,7 +208,7 @@ int software_suspend(void) | |||
194 | 208 | ||
195 | int pm_suspend(suspend_state_t state) | 209 | int pm_suspend(suspend_state_t state) |
196 | { | 210 | { |
197 | if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) | 211 | if (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX) |
198 | return enter_state(state); | 212 | return enter_state(state); |
199 | return -EINVAL; | 213 | return -EINVAL; |
200 | } | 214 | } |
diff --git a/kernel/power/process.c b/kernel/power/process.c index 0a086640bcfc..3bd0d261818f 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c | |||
@@ -59,6 +59,7 @@ int freeze_processes(void) | |||
59 | int todo; | 59 | int todo; |
60 | unsigned long start_time; | 60 | unsigned long start_time; |
61 | struct task_struct *g, *p; | 61 | struct task_struct *g, *p; |
62 | unsigned long flags; | ||
62 | 63 | ||
63 | printk( "Stopping tasks: " ); | 64 | printk( "Stopping tasks: " ); |
64 | start_time = jiffies; | 65 | start_time = jiffies; |
@@ -66,12 +67,9 @@ int freeze_processes(void) | |||
66 | todo = 0; | 67 | todo = 0; |
67 | read_lock(&tasklist_lock); | 68 | read_lock(&tasklist_lock); |
68 | do_each_thread(g, p) { | 69 | do_each_thread(g, p) { |
69 | unsigned long flags; | ||
70 | if (!freezeable(p)) | 70 | if (!freezeable(p)) |
71 | continue; | 71 | continue; |
72 | if ((frozen(p)) || | 72 | if (frozen(p)) |
73 | (p->state == TASK_TRACED) || | ||
74 | (p->state == TASK_STOPPED)) | ||
75 | continue; | 73 | continue; |
76 | 74 | ||
77 | freeze(p); | 75 | freeze(p); |
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index c285fc5a2320..f2bc71b9fe8b 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c | |||
@@ -63,6 +63,7 @@ | |||
63 | #include <linux/console.h> | 63 | #include <linux/console.h> |
64 | #include <linux/highmem.h> | 64 | #include <linux/highmem.h> |
65 | #include <linux/bio.h> | 65 | #include <linux/bio.h> |
66 | #include <linux/mount.h> | ||
66 | 67 | ||
67 | #include <asm/uaccess.h> | 68 | #include <asm/uaccess.h> |
68 | #include <asm/mmu_context.h> | 69 | #include <asm/mmu_context.h> |
@@ -869,13 +870,6 @@ extern asmlinkage int swsusp_arch_resume(void); | |||
869 | 870 | ||
870 | asmlinkage int swsusp_save(void) | 871 | asmlinkage int swsusp_save(void) |
871 | { | 872 | { |
872 | int error = 0; | ||
873 | |||
874 | if ((error = swsusp_swap_check())) { | ||
875 | printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try " | ||
876 | "swapon -a!\n"); | ||
877 | return error; | ||
878 | } | ||
879 | return suspend_prepare_image(); | 873 | return suspend_prepare_image(); |
880 | } | 874 | } |
881 | 875 | ||
@@ -892,14 +886,20 @@ int swsusp_suspend(void) | |||
892 | * at resume time, and evil weirdness ensues. | 886 | * at resume time, and evil weirdness ensues. |
893 | */ | 887 | */ |
894 | if ((error = device_power_down(PMSG_FREEZE))) { | 888 | if ((error = device_power_down(PMSG_FREEZE))) { |
895 | printk(KERN_ERR "Some devices failed to power down, aborting suspend\n"); | ||
896 | local_irq_enable(); | 889 | local_irq_enable(); |
897 | swsusp_free(); | ||
898 | return error; | 890 | return error; |
899 | } | 891 | } |
892 | |||
893 | if ((error = swsusp_swap_check())) { | ||
894 | printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try " | ||
895 | "swapon -a!\n"); | ||
896 | local_irq_enable(); | ||
897 | return error; | ||
898 | } | ||
899 | |||
900 | save_processor_state(); | 900 | save_processor_state(); |
901 | if ((error = swsusp_arch_suspend())) | 901 | if ((error = swsusp_arch_suspend())) |
902 | swsusp_free(); | 902 | printk("Error %d suspending\n", error); |
903 | /* Restore control flow magically appears here */ | 903 | /* Restore control flow magically appears here */ |
904 | restore_processor_state(); | 904 | restore_processor_state(); |
905 | BUG_ON (nr_copy_pages_check != nr_copy_pages); | 905 | BUG_ON (nr_copy_pages_check != nr_copy_pages); |
@@ -1166,9 +1166,9 @@ static int bio_write_page(pgoff_t page_off, void * page) | |||
1166 | static const char * sanity_check(void) | 1166 | static const char * sanity_check(void) |
1167 | { | 1167 | { |
1168 | dump_info(); | 1168 | dump_info(); |
1169 | if(swsusp_info.version_code != LINUX_VERSION_CODE) | 1169 | if (swsusp_info.version_code != LINUX_VERSION_CODE) |
1170 | return "kernel version"; | 1170 | return "kernel version"; |
1171 | if(swsusp_info.num_physpages != num_physpages) | 1171 | if (swsusp_info.num_physpages != num_physpages) |
1172 | return "memory size"; | 1172 | return "memory size"; |
1173 | if (strcmp(swsusp_info.uts.sysname,system_utsname.sysname)) | 1173 | if (strcmp(swsusp_info.uts.sysname,system_utsname.sysname)) |
1174 | return "system type"; | 1174 | return "system type"; |
@@ -1261,8 +1261,6 @@ static int data_read(struct pbe *pblist) | |||
1261 | return error; | 1261 | return error; |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | extern dev_t name_to_dev_t(const char *line); | ||
1265 | |||
1266 | /** | 1264 | /** |
1267 | * read_pagedir - Read page backup list pages from swap | 1265 | * read_pagedir - Read page backup list pages from swap |
1268 | */ | 1266 | */ |
@@ -1356,16 +1354,6 @@ int swsusp_check(void) | |||
1356 | { | 1354 | { |
1357 | int error; | 1355 | int error; |
1358 | 1356 | ||
1359 | if (!swsusp_resume_device) { | ||
1360 | if (!strlen(resume_file)) | ||
1361 | return -ENOENT; | ||
1362 | swsusp_resume_device = name_to_dev_t(resume_file); | ||
1363 | pr_debug("swsusp: Resume From Partition %s\n", resume_file); | ||
1364 | } else { | ||
1365 | pr_debug("swsusp: Resume From Partition %d:%d\n", | ||
1366 | MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); | ||
1367 | } | ||
1368 | |||
1369 | resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ); | 1357 | resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ); |
1370 | if (!IS_ERR(resume_bdev)) { | 1358 | if (!IS_ERR(resume_bdev)) { |
1371 | set_blocksize(resume_bdev, PAGE_SIZE); | 1359 | set_blocksize(resume_bdev, PAGE_SIZE); |