Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47423
b: refs/heads/master
c: ed746e3
h: refs/heads/master
i:
  47421: 0d4f6ed
  47419: 7b46871
  47415: a3b9c1d
  47407: a24f689
  47391: 83692d7
  47359: 1e30470
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Linus Torvalds committed Feb 11, 2007
1 parent 73e5ce8 commit 6499b36
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 58 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e3c7db621bed4afb8e231cb005057f2feb5db557
refs/heads/master: ed746e3b18f4df18afa3763155972c5835f284c5
2 changes: 2 additions & 0 deletions trunk/kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ void enable_nonboot_cpus(void)
mutex_lock(&cpu_add_remove_lock);
cpu_hotplug_disabled = 0;
mutex_unlock(&cpu_add_remove_lock);
if (cpus_empty(frozen_cpus))
return;

printk("Enabling non-boot CPUs ...\n");
for_each_cpu_mask(cpu, frozen_cpus) {
Expand Down
115 changes: 58 additions & 57 deletions trunk/kernel/power/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,52 +87,24 @@ static inline void platform_finish(void)
}
}

static void unprepare_processes(void)
{
thaw_processes();
pm_restore_console();
}

static int prepare_processes(void)
{
int error = 0;

pm_prepare_console();

error = disable_nonboot_cpus();
if (error)
goto enable_cpus;

if (freeze_processes()) {
error = -EBUSY;
goto thaw;
unprepare_processes();
}

if (pm_disk_mode == PM_DISK_TESTPROC) {
printk("swsusp debug: Waiting for 5 seconds.\n");
mdelay(5000);
goto thaw;
}

error = platform_prepare();
if (error)
goto thaw;

/* Free memory before shutting down devices. */
if (!(error = swsusp_shrink_memory()))
return 0;

platform_finish();
thaw:
thaw_processes();
enable_cpus:
enable_nonboot_cpus();
pm_restore_console();
return error;
}

static void unprepare_processes(void)
{
platform_finish();
thaw_processes();
enable_nonboot_cpus();
pm_restore_console();
}

/**
* pm_suspend_disk - The granpappy of hibernation power management.
*
Expand All @@ -150,29 +122,45 @@ int pm_suspend_disk(void)
if (error)
return error;

if (pm_disk_mode == PM_DISK_TESTPROC)
return 0;
if (pm_disk_mode == PM_DISK_TESTPROC) {
printk("swsusp debug: Waiting for 5 seconds.\n");
mdelay(5000);
goto Thaw;
}
/* Free memory before shutting down devices. */
error = swsusp_shrink_memory();
if (error)
goto Thaw;

error = platform_prepare();
if (error)
goto Thaw;

suspend_console();
error = device_suspend(PMSG_FREEZE);
if (error) {
resume_console();
printk("Some devices failed to suspend\n");
goto Thaw;
printk(KERN_ERR "PM: Some devices failed to suspend\n");
goto Resume_devices;
}
error = disable_nonboot_cpus();
if (error)
goto Enable_cpus;

if (pm_disk_mode == PM_DISK_TEST) {
printk("swsusp debug: Waiting for 5 seconds.\n");
mdelay(5000);
goto Done;
goto Enable_cpus;
}

pr_debug("PM: snapshotting memory.\n");
in_suspend = 1;
if ((error = swsusp_suspend()))
goto Done;
error = swsusp_suspend();
if (error)
goto Enable_cpus;

if (in_suspend) {
enable_nonboot_cpus();
platform_finish();
device_resume();
resume_console();
pr_debug("PM: writing image.\n");
Expand All @@ -188,7 +176,10 @@ int pm_suspend_disk(void)
}

swsusp_free();
Done:
Enable_cpus:
enable_nonboot_cpus();
Resume_devices:
platform_finish();
device_resume();
resume_console();
Thaw:
Expand Down Expand Up @@ -237,41 +228,51 @@ static int software_resume(void)

pr_debug("PM: Checking swsusp image.\n");

if ((error = swsusp_check()))
error = swsusp_check();
if (error)
goto Done;

pr_debug("PM: Preparing processes for restore.\n");

if ((error = prepare_processes())) {
error = prepare_processes();
if (error) {
swsusp_close();
goto Done;
}

error = platform_prepare();
if (error) {
swsusp_free();
goto Thaw;
}

pr_debug("PM: Reading swsusp image.\n");

if ((error = swsusp_read())) {
error = swsusp_read();
if (error) {
swsusp_free();
goto Thaw;
}

pr_debug("PM: Preparing devices for restore.\n");

suspend_console();
if ((error = device_suspend(PMSG_PRETHAW))) {
resume_console();
printk("Some devices failed to suspend\n");
swsusp_free();
goto Thaw;
}
error = device_suspend(PMSG_PRETHAW);
if (error)
goto Free;

mb();
error = disable_nonboot_cpus();
if (!error)
swsusp_resume();

pr_debug("PM: Restoring saved image.\n");
swsusp_resume();
pr_debug("PM: Restore failed, recovering.n");
enable_nonboot_cpus();
Free:
swsusp_free();
platform_finish();
device_resume();
resume_console();
Thaw:
printk(KERN_ERR "PM: Restore failed, recovering.\n");
unprepare_processes();
Done:
/* For success case, the suspend path will release the lock */
Expand Down

0 comments on commit 6499b36

Please sign in to comment.