All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shriram Rajagopalan <rshriram@cs.ubc.ca>
To: xen-devel@lists.xensource.com
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Shriram Rajagopalan <rshriram@cs.ubc.ca>,
	linux-pm@lists.linux-foundation.org,
	Iam Campbell <ian.campbell@citrix.com>,
	Pavel Machek <pavel@ucw.cz>
Subject: [PATCH 2/3] xen: use freeze/restore/thaw PM events for suspend/resume/chkpt
Date: Sat, 19 Feb 2011 15:12:37 -0800	[thread overview]
Message-ID: <1298157158-5421-3-git-send-email-rshriram@cs.ubc.ca> (raw)
In-Reply-To: <1298157158-5421-1-git-send-email-rshriram@cs.ubc.ca>

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);

Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
---
 drivers/base/power/main.c                  |    8 ++++----
 drivers/xen/manage.c                       |   16 ++++++++--------
 drivers/xen/xenbus/xenbus_probe_frontend.c |    8 +++++---
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 8340497..aab4f60 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -233,7 +233,7 @@ static int pm_op(struct device *dev,
 		}
 		break;
 #endif /* CONFIG_SUSPEND */
-#ifdef CONFIG_HIBERNATION
+#if defined(CONFIG_HIBERNATION) || defined(CONFIG_XEN_SAVE_RESTORE)
 	case PM_EVENT_FREEZE:
 	case PM_EVENT_QUIESCE:
 		if (ops->freeze) {
@@ -260,7 +260,7 @@ static int pm_op(struct device *dev,
 			suspend_report_result(ops->restore, error);
 		}
 		break;
-#endif /* CONFIG_HIBERNATION */
+#endif /* CONFIG_HIBERNATION || CONFIG_XEN_SAVE_RESTORE */
 	default:
 		error = -EINVAL;
 	}
@@ -308,7 +308,7 @@ static int pm_noirq_op(struct device *dev,
 		}
 		break;
 #endif /* CONFIG_SUSPEND */
-#ifdef CONFIG_HIBERNATION
+#if defined(CONFIG_HIBERNATION) || defined(CONFIG_XEN_SAVE_RESTORE)
 	case PM_EVENT_FREEZE:
 	case PM_EVENT_QUIESCE:
 		if (ops->freeze_noirq) {
@@ -335,7 +335,7 @@ static int pm_noirq_op(struct device *dev,
 			suspend_report_result(ops->restore_noirq, error);
 		}
 		break;
-#endif /* CONFIG_HIBERNATION */
+#endif /* CONFIG_HIBERNATION || CONFIG_XEN_SAVE_RESTORE */
 	default:
 		error = -EINVAL;
 	}
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index c255ed4..c24d0e7 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -61,7 +61,7 @@ static void xen_post_suspend(int cancelled)
 	xen_mm_unpin_all();
 }
 
-#ifdef CONFIG_PM_SLEEP
+#ifdef CONFIG_XEN_SAVE_RESTORE
 static int xen_suspend(void *data)
 {
 	struct suspend_info *si = data;
@@ -69,7 +69,7 @@ static int xen_suspend(void *data)
 
 	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);
@@ -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;
@@ -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;
@@ -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);
@@ -161,7 +161,7 @@ out_resume:
 	} 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();
@@ -173,7 +173,7 @@ out:
 #endif
 	shutting_down = SHUTDOWN_INVALID;
 }
-#endif	/* CONFIG_PM_SLEEP */
+#endif	/* CONFIG_XEN_SAVE_RESTORE */
 
 struct shutdown_handler {
 	const char *command;
@@ -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_XEN_SAVE_RESTORE
 		{ "suspend",	do_suspend  },
 #endif
 		{NULL, NULL},
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index ea83999..b6a2690 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -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 = {
-- 
1.7.0.4

  parent reply	other threads:[~2011-02-19 23:12 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-19 23:12 [PATCH 0/3] xen: Use PM/Hibernate events for save/restore/chkpt Shriram Rajagopalan
2011-02-19 23:12 ` [PATCH 1/3] xen: xenbus PM events support Shriram Rajagopalan
2011-02-19 23:12 ` Shriram Rajagopalan
2011-02-19 23:12 ` Shriram Rajagopalan [this message]
2011-02-22 20:43   ` [Xen-devel] [PATCH 2/3] xen: use freeze/restore/thaw PM events for suspend/resume/chkpt Konrad Rzeszutek Wilk
2011-02-22 20:43   ` Konrad Rzeszutek Wilk
2011-02-22 21:14     ` [Xen-devel] " Rafael J. Wysocki
2011-02-22 21:14     ` Rafael J. Wysocki
2011-02-22 22:09     ` [Xen-devel] " Shriram Rajagopalan
2011-02-22 22:09     ` Shriram Rajagopalan
2011-02-22 22:35       ` Rafael J. Wysocki
2011-02-22 22:35       ` [Xen-devel] " Rafael J. Wysocki
2011-02-22 22:36       ` Konrad Rzeszutek Wilk
2011-02-22 22:53         ` [Xen-devel] " Shriram Rajagopalan
2011-02-22 22:53         ` Shriram Rajagopalan
2011-02-22 22:36       ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-02-19 23:12 ` Shriram Rajagopalan
2011-02-19 23:12 ` [PATCH 3/3] PM: pm.h - Add comments about Xen save/restore/chkpt use case Shriram Rajagopalan
2011-02-19 23:12 ` Shriram Rajagopalan
2011-02-20  7:49 ` [PATCH 0/3] xen: Use PM/Hibernate events for save/restore/chkpt Pavel Machek
2011-02-20  7:49 ` Pavel Machek
2011-02-21 10:05   ` Ian Campbell
2011-02-21 10:05   ` Ian Campbell
2011-02-21 16:40     ` [linux-pm] " Alan Stern
2011-02-21 17:17       ` Ian Campbell
2011-02-21 20:23         ` Rafael J. Wysocki
2011-02-25 16:17           ` Stefano Stabellini
2011-02-25 16:19             ` Ian Campbell
2011-02-25 16:19             ` [linux-pm] " Ian Campbell
2011-02-25 16:23               ` Stefano Stabellini
2011-02-25 16:23               ` [linux-pm] " Stefano Stabellini
2011-02-25 16:17           ` Stefano Stabellini
2011-02-21 20:23         ` Rafael J. Wysocki
2011-02-21 17:17       ` Ian Campbell
2011-02-21 16:40     ` Alan Stern
2011-02-23 18:38     ` Pavel Machek
2011-02-23 20:10       ` Rafael J. Wysocki
2011-02-24 16:13         ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-02-24 16:13         ` Konrad Rzeszutek Wilk
2011-02-24 18:41           ` Rafael J. Wysocki
2011-02-25 17:19             ` Stefano Stabellini
2011-02-25 18:24               ` [Xen-devel] " Rafael J. Wysocki
2011-02-25 18:24               ` Rafael J. Wysocki
2011-02-28 11:06                 ` [Xen-devel] " Stefano Stabellini
2011-03-04 16:04                   ` Shriram Rajagopalan
2011-03-04 20:52                     ` Rafael J. Wysocki
2011-03-04 20:52                     ` [Xen-devel] " Rafael J. Wysocki
2011-03-04 16:04                   ` Shriram Rajagopalan
2011-02-25 17:19             ` Stefano Stabellini
2011-02-24 18:41           ` Rafael J. Wysocki
2011-02-23 20:10       ` Rafael J. Wysocki
2011-02-23 18:38     ` Pavel Machek
2011-02-23  7:03 ` [PATCH v2 2/3] xen: use freeze/restore/thaw PM events for suspend/resume/chkpt Shriram Rajagopalan
2011-02-23  7:03 ` Shriram Rajagopalan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1298157158-5421-3-git-send-email-rshriram@cs.ubc.ca \
    --to=rshriram@cs.ubc.ca \
    --cc=ian.campbell@citrix.com \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.