On Tue, Sep 12, 2006 at 08:56:33AM +0200, Stefan Seyfried wrote: > Hi, > > i finally tested it and it seems to work.
no, it didn't. But i fixed it. The placement of platform_finish() is non-intuitive :-) Also, moved to one ioctl with a parameter. If the style / ioctl design is ok, could we push this ASAP? It is pretty important to me to be able to test this further :-) I'll also clean up the userspace part (add a configuration variable so once can decide between "platform", "shutdown", maybe even "reboot", but that can still be done once the kernel part is pushed. This is for the kernel: Add an ioctl to user.c so that uswsusp can suspend correctly using the pm_ops methods. From: Stefan Seyfried <[EMAIL PROTECTED]> diff --exclude='.*' --exclude='*o' -ruNp /usr/src/linux/kernel/power/power.h linux-2.6.18-rc6-2/kernel/power/power.h --- /usr/src/linux/kernel/power/power.h 2006-09-08 19:02:33.000000000 +0200 +++ linux-2.6.18-rc6-2/kernel/power/power.h 2006-09-12 17:45:33.000000000 +0200 @@ -78,7 +78,12 @@ int snapshot_image_loaded(struct snapsho #define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) #define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) #define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11) -#define SNAPSHOT_IOC_MAXNR 11 +#define SNAPSHOT_PMOPS _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int) +#define SNAPSHOT_IOC_MAXNR 12 + +#define PMOPS_PREPARE 1 +#define PMOPS_ENTER 2 +#define PMOPS_FINISH 3 /** * The bitmap is used for tracing allocated swap pages diff --exclude='.*' --exclude='*o' -ruNp /usr/src/linux/kernel/power/user.c linux-2.6.18-rc6-2/kernel/power/user.c --- /usr/src/linux/kernel/power/user.c 2006-06-18 03:49:35.000000000 +0200 +++ linux-2.6.18-rc6-2/kernel/power/user.c 2006-09-12 18:45:34.000000000 +0200 @@ -11,6 +11,7 @@ #include <linux/suspend.h> #include <linux/syscalls.h> +#include <linux/reboot.h> #include <linux/string.h> #include <linux/device.h> #include <linux/miscdevice.h> @@ -302,6 +303,33 @@ OutS3: up(&pm_sem); break; + case SNAPSHOT_PMOPS: + switch (arg) { + + case PMOPS_PREPARE: + if (pm_ops->prepare) { + error = pm_ops->prepare(PM_SUSPEND_DISK); + } + break; + + case PMOPS_ENTER: + kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); + error = pm_ops->enter(PM_SUSPEND_DISK); + break; + + case PMOPS_FINISH: + if (pm_ops && pm_ops->finish) { + pm_ops->finish(PM_SUSPEND_DISK); + } + break; + + default: + printk(KERN_ERR "SNAPSHOT_PMOPS: invalid argument %ld\n", arg); + error = -EINVAL; + + } + break; + default: error = -ENOTTY; ------------------------------------- and this is for userspace: Index: suspend.c =================================================================== RCS file: /cvsroot/suspend/suspend/suspend.c,v retrieving revision 1.48 diff -u -p -r1.48 suspend.c --- suspend.c 23 Jul 2006 11:32:52 -0000 1.48 +++ suspend.c 12 Sep 2006 16:56:48 -0000 @@ -636,9 +636,10 @@ static int reset_signature(int fd) } #endif -static void suspend_shutdown(void) +static void suspend_shutdown(int dev) { - power_off(); + // power_off(); + ioctl(dev, SNAPSHOT_PMOPS, PMOPS_ENTER); /* Signature is on disk, it is very dangerous to continue now. * We'd do resume with stale caches on next boot. */ printf("Powerdown failed. That's impossible.\n"); @@ -677,6 +678,8 @@ int suspend_system(int snapshot_fd, int if (error) goto Unfreeze; + ioctl(snapshot_fd, SNAPSHOT_PMOPS, PMOPS_PREPARE); + printf("suspend: Snapshotting system\n"); attempts = 2; do { @@ -687,6 +690,7 @@ int suspend_system(int snapshot_fd, int if (!atomic_snapshot(snapshot_fd, &in_suspend)) { if (!in_suspend) { free_snapshot(snapshot_fd); + platform_finish(snapshot_fd); break; } error = write_image(snapshot_fd, resume_fd, vt_no); @@ -694,14 +698,14 @@ int suspend_system(int snapshot_fd, int splash.progress(100); #ifdef CONFIG_BOTH if (!s2ram) { - suspend_shutdown(); + suspend_shutdown(snapshot_fd); } else { /* If we die (and allow system to continue) between * now and reset_signature(), very bad things will * happen. */ error = suspend_to_ram(snapshot_fd); if (error) - suspend_shutdown(); + suspend_shutdown(snapshot_fd); reset_signature(resume_fd); free_swap_pages(snapshot_fd); free_snapshot(snapshot_fd); @@ -709,7 +713,7 @@ int suspend_system(int snapshot_fd, int goto Unfreeze; } #else - suspend_shutdown(); + suspend_shutdown(snapshot_fd); #endif } else { free_swap_pages(snapshot_fd); Index: swsusp.h =================================================================== RCS file: /cvsroot/suspend/suspend/swsusp.h,v retrieving revision 1.25 diff -u -p -r1.25 swsusp.h --- swsusp.h 3 Sep 2006 22:04:34 -0000 1.25 +++ swsusp.h 12 Sep 2006 16:56:48 -0000 @@ -26,7 +26,12 @@ #define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) #define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) #define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11) -#define SNAPSHOT_IOC_MAXNR 11 +#define SNAPSHOT_PMOPS _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int) +#define SNAPSHOT_IOC_MAXNR 12 + +#define PMOPS_PREPARE 1 +#define PMOPS_ENTER 2 +#define PMOPS_FINISH 3 #define LINUX_REBOOT_MAGIC1 0xfee1dead #define LINUX_REBOOT_MAGIC2 672274793 @@ -98,6 +103,11 @@ static inline int atomic_restore(int dev return ioctl(dev, SNAPSHOT_ATOMIC_RESTORE, 0); } +static inline void platform_finish(int dev) +{ + ioctl (dev, SNAPSHOT_PMOPS, PMOPS_FINISH); +} + static inline int free_snapshot(int dev) { return ioctl(dev, SNAPSHOT_FREE, 0); -- Stefan Seyfried | "Please, just tell people QA / R&D Team Mobile Devices | to use KDE." SUSE LINUX Products GmbH, Nürnberg | -- Linus Torvalds ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Suspend-devel mailing list Suspend-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/suspend-devel