From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 02/13] [Suspend2] Boot time hooks.
Date: Tue, 27 Jun 2006 14:42:32 +1000 [thread overview]
Message-ID: <20060627044231.15066.69247.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060627044226.15066.7403.stgit@nigel.suspend2.net>
Hooks for checking whether to resume when booting.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
init/do_mounts.c | 28 +++++++++++++++++++++++++---
init/do_mounts_initrd.c | 10 +++++++++-
init/main.c | 4 +++-
3 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 21b3b8f..0cc9233 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -138,11 +138,16 @@ dev_t name_to_dev_t(char *name)
char s[32];
char *p;
dev_t res = 0;
- int part;
+ int part, mount_result;
#ifdef CONFIG_SYSFS
int mkdir_err = sys_mkdir("/sys", 0700);
- if (sys_mount("sysfs", "/sys", "sysfs", 0, NULL) < 0)
+ /*
+ * When changing resume2 parameter for Software Suspend, sysfs may
+ * already be mounted.
+ */
+ mount_result = sys_mount("sysfs", "/sys", "sysfs", 0, NULL);
+ if (mount_result < 0 && mount_result != -EBUSY)
goto out;
#endif
@@ -194,7 +199,8 @@ dev_t name_to_dev_t(char *name)
res = try_name(s, part);
done:
#ifdef CONFIG_SYSFS
- sys_umount("/sys", 0);
+ if (mount_result >= 0)
+ sys_umount("/sys", 0);
out:
if (!mkdir_err)
sys_rmdir("/sys");
@@ -420,9 +426,25 @@ void __init prepare_namespace(void)
is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
+ /* Suspend2:
+ * By this point, suspend_early_init has been called to initialise our
+ * proc interface. If modules are built in, they have registered (all
+ * of the above via late_initcalls).
+ *
+ * We have not yet looked to see if an image exists, however. If we
+ * have an initrd, it is expected that the user will have set it up
+ * to echo > /proc/suspend2/do_resume and thus initiate any
+ * resume. If they don't do that, we do it immediately after the initrd
+ * is finished (major issues if they mount filesystems rw from the
+ * initrd! - they are warned. If there's no usable initrd, we do our
+ * check next.
+ */
if (initrd_load())
goto out;
+ if (test_suspend_state(SUSPEND_RESUME_NOT_DONE))
+ suspend2_try_resume();
+
if (is_floppy && rd_doload && rd_load_disk(0))
ROOT_DEV = Root_RAM0;
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 405f903..9f8287f 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -7,6 +7,7 @@
#include <linux/romfs_fs.h>
#include <linux/initrd.h>
#include <linux/sched.h>
+#include <linux/suspend.h>
#include "do_mounts.h"
@@ -59,10 +60,17 @@ static void __init handle_initrd(void)
current->flags |= PF_NOFREEZE;
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
if (pid > 0) {
- while (pid != sys_wait4(-1, NULL, 0, NULL))
+ while (pid != sys_wait4(-1, NULL, 0, NULL)) {
yield();
+ try_to_freeze();
+ }
}
+ if (test_suspend_state(SUSPEND_RESUME_NOT_DONE))
+ printk(KERN_ERR "Suspend2: Initrd lacks echo > /proc/suspend2/do_resume.\n");
+ clear_suspend_state(SUSPEND_BOOT_TIME);
+ current->flags &= ~PF_NOFREEZE;
+
/* move initrd to rootfs' /old */
sys_fchdir(old_fd);
sys_mount("/", ".", NULL, MS_MOVE, NULL);
diff --git a/init/main.c b/init/main.c
index f715b9b..89e1ba3 100644
--- a/init/main.c
+++ b/init/main.c
@@ -681,7 +681,9 @@ static int init(void * unused)
/*
* check if there is an early userspace init. If yes, let it do all
- * the work
+ * the work. For suspend2, we assume that it will do the right thing
+ * with regard to trying to resume at the right place. When that
+ * happens, the BOOT_TIME flag will be cleared.
*/
if (!ramdisk_execute_command)
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-27 4:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-27 4:42 [Suspend2][ 00/13] Miscellaneous patches Nigel Cunningham
2006-06-27 4:42 ` [Suspend2][ 01/13] [Suspend2] Suspend2 version header Nigel Cunningham
2006-06-27 4:42 ` Nigel Cunningham [this message]
2006-06-27 4:42 ` [Suspend2][ 03/13] [Suspend2] Add netlink socket numbers Nigel Cunningham
2006-06-27 4:42 ` [Suspend2][ 04/13] [Suspend2] Follow page routine Nigel Cunningham
2006-06-27 4:42 ` [Suspend2][ 05/13] [Suspend2] LRU paranoia patch Nigel Cunningham
2006-06-27 4:42 ` [Suspend2][ 06/13] [Suspend2] Remove __nosave declarations in power.h Nigel Cunningham
2006-06-27 4:42 ` [Suspend2][ 07/13] [Suspend2] Page_alloc paranoia Nigel Cunningham
2006-06-27 6:11 ` Nick Piggin
2006-06-27 6:34 ` Nigel Cunningham
2006-06-29 16:22 ` Nick Piggin
2006-06-29 22:15 ` Nigel Cunningham
2006-07-04 10:54 ` Nigel Cunningham
2006-07-04 16:53 ` Nick Piggin
2006-06-27 6:33 ` Paul Jackson
2006-06-27 7:01 ` Nigel Cunningham
2006-06-27 4:42 ` [Suspend2][ 08/13] [Suspend2] Powerpc support (needed?) Nigel Cunningham
2006-06-27 4:42 ` [Suspend2][ 09/13] [Suspend2] Reset kswapd_max_order after resume Nigel Cunningham
2006-06-27 4:43 ` [Suspend2][ 10/13] [Suspend2] Replace swsusp reboot hook Nigel Cunningham
2006-06-27 4:43 ` [Suspend2][ 11/13] [Suspend2] snprintf_used function Nigel Cunningham
2006-06-27 4:43 ` [Suspend2][ 12/13] [Suspend2] Suspend2 common header Nigel Cunningham
2006-06-27 4:43 ` [Suspend2][ 13/13] [Suspend2] Suspend2 include file Nigel Cunningham
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=20060627044231.15066.69247.stgit@nigel.suspend2.net \
--to=nigel@suspend2.net \
--cc=linux-kernel@vger.kernel.org \
/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