Skip to content

Commit

Permalink
xen: use freeze/restore/thaw PM events for suspend/resume/chkpt
Browse files Browse the repository at this point in the history
Use PM_FREEZE, PM_THAW and PM_RESTORE power events for
suspend/resume/checkpoint functionality, instead of PM_SUSPEND
and PM_RESUME. Use of these pm events fixes the Xen Guest hangup
when taking checkpoints. When a suspend event is cancelled
(while taking checkpoints once/continuously), we use PM_THAW
instead of PM_RESUME. PM_RESTORE is used when suspend is not
cancelled. See Documentation/power/devices.txt and linux/pm.h
for more info about freeze, thaw and restore. The sequence of
pm events in a suspend-resume scenario is shown below.

        dpm_suspend_start(PMSG_FREEZE);

                dpm_suspend_noirq(PMSG_FREEZE);

                       sysdev_suspend(PMSG_FREEZE);
                       cancelled = suspend_hypercall()
                       sysdev_resume();

               dpm_resume_noirq(cancelled ? PMSG_THAW : PMSG_RESTORE);

       dpm_resume_end(cancelled ? PMSG_THAW : PMSG_RESTORE);

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Shriram Rajagopalan authored and Konrad Rzeszutek Wilk committed Mar 16, 2011
1 parent c7853ae commit b3e96c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 8 additions & 8 deletions drivers/xen/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ static void xen_post_suspend(int cancelled)
xen_mm_unpin_all();
}

#ifdef CONFIG_PM_SLEEP
#ifdef CONFIG_HIBERNATION
static int xen_suspend(void *data)
{
struct suspend_info *si = data;
int err;

BUG_ON(!irqs_disabled());

err = sysdev_suspend(PMSG_SUSPEND);
err = sysdev_suspend(PMSG_FREEZE);
if (err) {
printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n",
err);
Expand Down Expand Up @@ -118,7 +118,7 @@ static void do_suspend(void)
}
#endif

err = dpm_suspend_start(PMSG_SUSPEND);
err = dpm_suspend_start(PMSG_FREEZE);
if (err) {
printk(KERN_ERR "xen suspend: dpm_suspend_start %d\n", err);
goto out_thaw;
Expand All @@ -127,7 +127,7 @@ static void do_suspend(void)
printk(KERN_DEBUG "suspending xenstore...\n");
xs_suspend();

err = dpm_suspend_noirq(PMSG_SUSPEND);
err = dpm_suspend_noirq(PMSG_FREEZE);
if (err) {
printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err);
goto out_resume;
Expand All @@ -147,7 +147,7 @@ static void do_suspend(void)

err = stop_machine(xen_suspend, &si, cpumask_of(0));

dpm_resume_noirq(PMSG_RESUME);
dpm_resume_noirq(si.cancelled ? PMSG_THAW : PMSG_RESTORE);

if (err) {
printk(KERN_ERR "failed to start xen_suspend: %d\n", err);
Expand All @@ -161,7 +161,7 @@ static void do_suspend(void)
} else
xs_suspend_cancel();

dpm_resume_end(PMSG_RESUME);
dpm_resume_end(si.cancelled ? PMSG_THAW : PMSG_RESTORE);

/* Make sure timer events get retriggered on all CPUs */
clock_was_set();
Expand All @@ -173,7 +173,7 @@ static void do_suspend(void)
#endif
shutting_down = SHUTDOWN_INVALID;
}
#endif /* CONFIG_PM_SLEEP */
#endif /* CONFIG_HIBERNATION */

struct shutdown_handler {
const char *command;
Expand Down Expand Up @@ -202,7 +202,7 @@ static void shutdown_handler(struct xenbus_watch *watch,
{ "poweroff", do_poweroff },
{ "halt", do_poweroff },
{ "reboot", do_reboot },
#ifdef CONFIG_PM_SLEEP
#ifdef CONFIG_HIBERNATION
{ "suspend", do_suspend },
#endif
{NULL, NULL},
Expand Down
8 changes: 5 additions & 3 deletions drivers/xen/xenbus/xenbus_probe_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ static struct device_attribute xenbus_frontend_dev_attrs[] = {
};

static const struct dev_pm_ops xenbus_pm_ops = {
.suspend = xenbus_dev_suspend,
.resume = xenbus_dev_resume,
.thaw = xenbus_dev_cancel,
.suspend = xenbus_dev_suspend,
.resume = xenbus_dev_resume,
.freeze = xenbus_dev_suspend,
.thaw = xenbus_dev_cancel,
.restore = xenbus_dev_resume,
};

static struct xen_bus_type xenbus_frontend = {
Expand Down

0 comments on commit b3e96c0

Please sign in to comment.