From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 13/16] [Suspend2] do_resume routine.
Date: Tue, 27 Jun 2006 08:34:00 +1000 [thread overview]
Message-ID: <20060626223358.3832.74079.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626223314.3832.23435.stgit@nigel.suspend2.net>
Main routine for seeing if we can resume - and doing it!
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/suspend.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 98 insertions(+), 0 deletions(-)
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index f7138c1..0f751d1 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -910,3 +910,101 @@ static __init int core_load(void)
return 0;
}
+/*
+ * Called from init kernel_thread.
+ * We check if we have an image and if so we try to resume.
+ * We also start ksuspendd if configuration looks right.
+ */
+int suspend_resume(void)
+{
+ int read_image_result = 0;
+
+ if (sizeof(swp_entry_t) != sizeof(long)) {
+ printk(KERN_WARNING name_suspend
+ "The size of swp_entry_t != size of long. "
+ "Please report this!\n");
+ return 1;
+ }
+
+ if (!resume2_file[0])
+ printk(KERN_WARNING name_suspend
+ "You need to use a resume2= command line parameter to "
+ "tell Suspend2 where to look for an image.\n");
+
+ suspend_activate_storage(0);
+
+ if (!(test_suspend_state(SUSPEND_RESUME_DEVICE_OK)) &&
+ !suspend_attempt_to_parse_resume_device()) {
+ /*
+ * Without a usable storage device we can do nothing -
+ * even if noresume is given
+ */
+
+ if (!suspend_num_writers)
+ printk(KERN_ALERT name_suspend
+ "No writers have been registered.\n");
+ else
+ printk(KERN_ALERT name_suspend
+ "Missing or invalid storage location "
+ "(resume2= parameter). Please correct and "
+ "rerun lilo (or equivalent) before "
+ "suspending.\n");
+ suspend_deactivate_storage(0);
+ return 1;
+ }
+
+ suspend_orig_mem_free = real_nr_free_pages();
+
+ read_image_result = read_pageset1(); /* non fatal error ignored */
+
+ if (test_suspend_state(SUSPEND_NORESUME_SPECIFIED))
+ printk(KERN_WARNING name_suspend "Resuming disabled as requested.\n");
+
+ suspend_deactivate_storage(0);
+
+ if (read_image_result)
+ return 1;
+
+ suspend2_running = 1;
+
+ suspend_atomic_restore();
+
+ BUG();
+
+ return 0;
+}
+
+/* -- Functions for kickstarting a suspend or resume --- */
+
+/*
+ * Check if we have an image and if so try to resume.
+ */
+void __suspend_try_resume(void)
+{
+ set_suspend_state(SUSPEND_TRYING_TO_RESUME);
+
+ clear_suspend_state(SUSPEND_RESUME_NOT_DONE);
+
+ suspend_resume();
+
+ clear_suspend_state(SUSPEND_IGNORE_LOGLEVEL);
+ clear_suspend_state(SUSPEND_TRYING_TO_RESUME);
+}
+
+/* Wrapper for when called from init/do_mounts.c */
+void suspend2_try_resume(void)
+{
+ if (suspend_start_anything(0))
+ return;
+
+ __suspend_try_resume();
+
+ /*
+ * For initramfs, we have to clear the boot time
+ * flag after trying to resume
+ */
+ clear_suspend_state(SUSPEND_BOOT_TIME);
+
+ suspend_finish_anything(0);
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-26 23:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 22:33 [Suspend2][ 00/16] Suspend.c Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 01/16] [Suspend2] Suspend.c header Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 02/16] [Suspend2] Routines called when starting or finishing anything Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 03/16] [Suspend2] Save image Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 04/16] [Suspend2] Get debug info Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 05/16] [Suspend2] Allocate/free bitmaps Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 06/16] [Suspend2] Check if still keeping an existing image Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 07/16] [Suspend2] Suspend2 init/cleanup Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 08/16] [Suspend2] Can suspend? Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 09/16] [Suspend2] Top level routine for do_suspend Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 10/16] [Suspend2] Image exists proc entry Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 11/16] [Suspend2] General proc entries for suspend Nigel Cunningham
2006-06-26 22:33 ` [Suspend2][ 12/16] [Suspend2] Core load routine Nigel Cunningham
2006-06-26 22:34 ` Nigel Cunningham [this message]
2006-06-26 22:34 ` [Suspend2][ 14/16] [Suspend2] Try to suspend Nigel Cunningham
2006-06-26 22:34 ` [Suspend2][ 15/16] [Suspend2] __init routines Nigel Cunningham
2006-06-26 22:34 ` [Suspend2][ 16/16] [Suspend2] Suspend,c header 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=20060626223358.3832.74079.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
Powered by JetHome