Skip to content

Commit b3e96c0

Browse files
Shriram Rajagopalankonradwilk
Shriram Rajagopalan
authored andcommitted
xen: use freeze/restore/thaw PM events for suspend/resume/chkpt
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 <[email protected]> Signed-off-by: Shriram Rajagopalan <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent c7853ae commit b3e96c0

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

drivers/xen/manage.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ static void xen_post_suspend(int cancelled)
6161
xen_mm_unpin_all();
6262
}
6363

64-
#ifdef CONFIG_PM_SLEEP
64+
#ifdef CONFIG_HIBERNATION
6565
static int xen_suspend(void *data)
6666
{
6767
struct suspend_info *si = data;
6868
int err;
6969

7070
BUG_ON(!irqs_disabled());
7171

72-
err = sysdev_suspend(PMSG_SUSPEND);
72+
err = sysdev_suspend(PMSG_FREEZE);
7373
if (err) {
7474
printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n",
7575
err);
@@ -118,7 +118,7 @@ static void do_suspend(void)
118118
}
119119
#endif
120120

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

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

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

150-
dpm_resume_noirq(PMSG_RESUME);
150+
dpm_resume_noirq(si.cancelled ? PMSG_THAW : PMSG_RESTORE);
151151

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

164-
dpm_resume_end(PMSG_RESUME);
164+
dpm_resume_end(si.cancelled ? PMSG_THAW : PMSG_RESTORE);
165165

166166
/* Make sure timer events get retriggered on all CPUs */
167167
clock_was_set();
@@ -173,7 +173,7 @@ static void do_suspend(void)
173173
#endif
174174
shutting_down = SHUTDOWN_INVALID;
175175
}
176-
#endif /* CONFIG_PM_SLEEP */
176+
#endif /* CONFIG_HIBERNATION */
177177

178178
struct shutdown_handler {
179179
const char *command;
@@ -202,7 +202,7 @@ static void shutdown_handler(struct xenbus_watch *watch,
202202
{ "poweroff", do_poweroff },
203203
{ "halt", do_poweroff },
204204
{ "reboot", do_reboot },
205-
#ifdef CONFIG_PM_SLEEP
205+
#ifdef CONFIG_HIBERNATION
206206
{ "suspend", do_suspend },
207207
#endif
208208
{NULL, NULL},

drivers/xen/xenbus/xenbus_probe_frontend.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ static struct device_attribute xenbus_frontend_dev_attrs[] = {
8686
};
8787

8888
static const struct dev_pm_ops xenbus_pm_ops = {
89-
.suspend = xenbus_dev_suspend,
90-
.resume = xenbus_dev_resume,
91-
.thaw = xenbus_dev_cancel,
89+
.suspend = xenbus_dev_suspend,
90+
.resume = xenbus_dev_resume,
91+
.freeze = xenbus_dev_suspend,
92+
.thaw = xenbus_dev_cancel,
93+
.restore = xenbus_dev_resume,
9294
};
9395

9496
static struct xen_bus_type xenbus_frontend = {

0 commit comments

Comments
 (0)