From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: pm list <linux-pm@lists.osdl.org>
Cc: suspend-devel List <suspend-devel@lists.sourceforge.net>,
linux-acpi@vger.kernel.org, Stefan Seyfried <seife@suse.de>,
Stephen Hemminger <shemminger@osdl.org>,
Pavel Machek <pavel@ucw.cz>
Subject: [PATCH -mm 4/4] swsusp: Change pm_ops handling by userland interface
Date: Sun, 17 Dec 2006 19:18:34 +0100 [thread overview]
Message-ID: <200612171918.35697.rjw@sisk.pl> (raw)
In-Reply-To: <200612171858.16380.rjw@sisk.pl>
Make the userland interface of swsusp call pm_ops->finish() after
enable_nonboot_cpus() and before resume_device(),
as indicated by the recent discussion on Linux-PM
(cf. http://lists.osdl.org/pipermail/linux-pm/2006-November/004164.html).
This patch changes the SNAPSHOT_PMOPS ioctl so that its first function,
PMOPS_PREPARE, only sets a switch turning the platform suspend mode on, and
its last function, PMOPS_PREPARE, only checks if the platform mode is enabled.
This should allow the older userland tools to work with new kernels without
any modifications.
The changes here only affect the userland interface of swsusp.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
kernel/power/user.c | 64 +++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 51 insertions(+), 13 deletions(-)
Index: linux-2.6.20-rc1/kernel/power/user.c
===================================================================
--- linux-2.6.20-rc1.orig/kernel/power/user.c 2006-12-14 23:20:10.000000000 +0100
+++ linux-2.6.20-rc1/kernel/power/user.c 2006-12-14 23:20:18.000000000 +0100
@@ -37,6 +37,7 @@ static struct snapshot_data {
int mode;
char frozen;
char ready;
+ char platform_suspend;
} snapshot_state;
static atomic_t device_available = ATOMIC_INIT(1);
@@ -66,6 +67,7 @@ static int snapshot_open(struct inode *i
data->bitmap = NULL;
data->frozen = 0;
data->ready = 0;
+ data->platform_suspend = 0;
return 0;
}
@@ -122,7 +124,23 @@ static ssize_t snapshot_write(struct fil
return res;
}
-static inline int snapshot_suspend(void)
+static inline int platform_prepare(void)
+{
+ int error = 0;
+
+ if (pm_ops && pm_ops->prepare)
+ error = pm_ops->prepare(PM_SUSPEND_DISK);
+
+ return error;
+}
+
+static inline void platform_finish(void)
+{
+ if (pm_ops && pm_ops->finish)
+ pm_ops->finish(PM_SUSPEND_DISK);
+}
+
+static inline int snapshot_suspend(int platform_suspend)
{
int error;
@@ -132,6 +150,11 @@ static inline int snapshot_suspend(void)
if (error)
goto Finish;
+ if (platform_suspend) {
+ error = platform_prepare();
+ if (error)
+ goto Finish;
+ }
suspend_console();
error = device_suspend(PMSG_FREEZE);
if (error)
@@ -144,6 +167,9 @@ static inline int snapshot_suspend(void)
}
enable_nonboot_cpus();
Resume_devices:
+ if (platform_suspend)
+ platform_finish();
+
device_resume();
resume_console();
Finish:
@@ -151,12 +177,17 @@ static inline int snapshot_suspend(void)
return error;
}
-static inline int snapshot_restore(void)
+static inline int snapshot_restore(int platform_suspend)
{
int error;
mutex_lock(&pm_mutex);
pm_prepare_console();
+ if (platform_suspend) {
+ error = platform_prepare();
+ if (error)
+ goto Finish;
+ }
suspend_console();
error = device_suspend(PMSG_PRETHAW);
if (error)
@@ -168,8 +199,12 @@ static inline int snapshot_restore(void)
enable_nonboot_cpus();
Resume_devices:
+ if (platform_suspend)
+ platform_finish();
+
device_resume();
resume_console();
+ Finish:
pm_restore_console();
mutex_unlock(&pm_mutex);
return error;
@@ -221,7 +256,7 @@ static int snapshot_ioctl(struct inode *
error = -EPERM;
break;
}
- error = snapshot_suspend();
+ error = snapshot_suspend(data->platform_suspend);
if (!error)
error = put_user(in_suspend, (unsigned int __user *)arg);
if (!error)
@@ -235,7 +270,7 @@ static int snapshot_ioctl(struct inode *
error = -EPERM;
break;
}
- error = snapshot_restore();
+ error = snapshot_restore(data->platform_suspend);
break;
case SNAPSHOT_FREE:
@@ -342,28 +377,31 @@ static int snapshot_ioctl(struct inode *
break;
case SNAPSHOT_PMOPS:
+ error = -EINVAL;
+
switch (arg) {
case PMOPS_PREPARE:
- if (pm_ops->prepare) {
- error = pm_ops->prepare(PM_SUSPEND_DISK);
- }
+ data->platform_suspend = 1;
+ error = 0;
break;
case PMOPS_ENTER:
- kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
- error = pm_ops->enter(PM_SUSPEND_DISK);
+ if (data->platform_suspend) {
+ kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
+ error = pm_ops->enter(PM_SUSPEND_DISK);
+ error = 0;
+ }
break;
case PMOPS_FINISH:
- if (pm_ops && pm_ops->finish) {
- pm_ops->finish(PM_SUSPEND_DISK);
- }
+ if (data->platform_suspend)
+ error = 0;
+
break;
default:
printk(KERN_ERR "SNAPSHOT_PMOPS: invalid argument %ld\n", arg);
- error = -EINVAL;
}
break;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
next prev parent reply other threads:[~2006-12-17 18:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-17 17:58 [PATCH -mm] PM: Change ordering of suspend and resume code Rafael J. Wysocki
2006-12-17 18:02 ` [PATCH -mm 1/4] PM: Change code ordering in main.c Rafael J. Wysocki
2006-12-17 18:05 ` [PATCH -mm 2/4] swsusp: Change code ordering in disk.c Rafael J. Wysocki
2006-12-17 18:09 ` [PATCH -mm 3/4] swsusp: Change code ordering in user.c Rafael J. Wysocki
2006-12-17 18:18 ` Rafael J. Wysocki [this message]
2006-12-18 7:42 ` [PATCH -mm] PM: Change ordering of suspend and resume code Stefan Seyfried
2006-12-18 15:10 ` Rafael J. Wysocki
2006-12-19 23:30 ` Pavel Machek
2006-12-20 12:43 ` [Suspend-devel] " Rafael J. Wysocki
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=200612171918.35697.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pm@lists.osdl.org \
--cc=pavel@ucw.cz \
--cc=seife@suse.de \
--cc=shemminger@osdl.org \
--cc=suspend-devel@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox