Skip to content

Commit

Permalink
PM: Add missing syscore_suspend() and syscore_resume() calls
Browse files Browse the repository at this point in the history
Device suspend/resume infrastructure is used not only by the suspend
and hibernate code in kernel/power, but also by APM, Xen and the
kexec jump feature.  However, commit 40dc166
(PM / Core: Introduce struct syscore_ops for core subsystems PM)
failed to add syscore_suspend() and syscore_resume() calls to that
code, which generally leads to breakage when the features in question
are used.

To fix this problem, add the missing syscore_suspend() and
syscore_resume() calls to arch/x86/kernel/apm_32.c, kernel/kexec.c
and drivers/xen/manage.c.

Signed-off-by: Rafael J. Wysocki <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Ian Campbell <[email protected]>
  • Loading branch information
rjwysocki committed Apr 19, 2011
1 parent 2ca6f62 commit 19234c0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions arch/x86/kernel/apm_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
#include <linux/kthread.h>
#include <linux/jiffies.h>
#include <linux/acpi.h>
#include <linux/syscore_ops.h>

#include <asm/system.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -1238,6 +1239,7 @@ static int suspend(int vetoable)

local_irq_disable();
sysdev_suspend(PMSG_SUSPEND);
syscore_suspend();

local_irq_enable();

Expand All @@ -1255,6 +1257,7 @@ static int suspend(int vetoable)
apm_error("suspend", err);
err = (err == APM_SUCCESS) ? 0 : -EIO;

syscore_resume();
sysdev_resume();
local_irq_enable();

Expand All @@ -1280,13 +1283,15 @@ static void standby(void)

local_irq_disable();
sysdev_suspend(PMSG_SUSPEND);
syscore_suspend();
local_irq_enable();

err = set_system_power_state(APM_STATE_STANDBY);
if ((err != APM_SUCCESS) && (err != APM_NO_ERROR))
apm_error("standby", err);

local_irq_disable();
syscore_resume();
sysdev_resume();
local_irq_enable();

Expand Down
2 changes: 2 additions & 0 deletions drivers/base/syscore.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ int syscore_suspend(void)

return ret;
}
EXPORT_SYMBOL_GPL(syscore_suspend);

/**
* syscore_resume - Execute all the registered system core resume callbacks.
Expand All @@ -95,6 +96,7 @@ void syscore_resume(void)
"Interrupts enabled after %pF\n", ops->resume);
}
}
EXPORT_SYMBOL_GPL(syscore_resume);
#endif /* CONFIG_PM_SLEEP */

/**
Expand Down
9 changes: 8 additions & 1 deletion drivers/xen/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/sysrq.h>
#include <linux/stop_machine.h>
#include <linux/freezer.h>
#include <linux/syscore_ops.h>

#include <xen/xen.h>
#include <xen/xenbus.h>
Expand Down Expand Up @@ -70,8 +71,13 @@ static int xen_suspend(void *data)
BUG_ON(!irqs_disabled());

err = sysdev_suspend(PMSG_FREEZE);
if (!err) {
err = syscore_suspend();
if (err)
sysdev_resume();
}
if (err) {
printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n",
printk(KERN_ERR "xen_suspend: system core suspend failed: %d\n",
err);
return err;
}
Expand All @@ -95,6 +101,7 @@ static int xen_suspend(void *data)
xen_timer_resume();
}

syscore_resume();
sysdev_resume();

return 0;
Expand Down
7 changes: 7 additions & 0 deletions kernel/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/vmalloc.h>
#include <linux/swap.h>
#include <linux/kmsg_dump.h>
#include <linux/syscore_ops.h>

#include <asm/page.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -1532,6 +1533,11 @@ int kernel_kexec(void)
local_irq_disable();
/* Suspend system devices */
error = sysdev_suspend(PMSG_FREEZE);
if (!error) {
error = syscore_suspend();
if (error)
sysdev_resume();
}
if (error)
goto Enable_irqs;
} else
Expand All @@ -1546,6 +1552,7 @@ int kernel_kexec(void)

#ifdef CONFIG_KEXEC_JUMP
if (kexec_image->preserve_context) {
syscore_resume();
sysdev_resume();
Enable_irqs:
local_irq_enable();
Expand Down

0 comments on commit 19234c0

Please sign in to comment.