From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 09/16] [Suspend2] Top level routine for do_suspend.
Date: Tue, 27 Jun 2006 08:33:45 +1000 [thread overview]
Message-ID: <20060626223344.3832.83492.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626223314.3832.23435.stgit@nigel.suspend2.net>
Our top level routine for suspending - activate storage, check if we can
suspend, check if a kept image is still to be used (powerdown if so), then
prepare and save the image (including powering down). When we return from
save_image, we've either aborted during saving, or resumed at a later time.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/suspend.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index bda4c2a..40f54f7 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -599,3 +599,44 @@ static int can_suspend(void)
return 1;
}
+/*
+ * suspend_main
+ * Functionality : First level of code for software suspend invocations.
+ * Stores and restores load averages (to avoid a spike),
+ * allocates bitmaps, freezes processes and eats memory
+ * as required before suspending drivers and invoking
+ * the 'low level' code to save the state to disk.
+ * By the time we return from do_suspend2_suspend, we
+ * have either failed to save the image or successfully
+ * suspended and reloaded the image. The difference can
+ * be discerned by checking SUSPEND_ABORTED.
+ * Called From :
+ */
+void suspend_main(void)
+{
+ if (suspend_activate_storage(0))
+ return;
+
+ if (!can_suspend())
+ goto cleanup;
+
+ /*
+ * If kept image and still keeping image and suspending to RAM, we will
+ * return 1 after suspending and resuming (provided the power doesn't
+ * run out.
+ */
+ if (test_result_state(SUSPEND_KEPT_IMAGE) && check_still_keeping_image())
+ goto cleanup;
+
+
+ if (suspend_init() && !suspend_prepare_image() && !test_result_state(SUSPEND_ABORTED) &&
+ !test_action_state(SUSPEND_FREEZER_TEST)) {
+ suspend_prepare_status(DONT_CLEAR_BAR, "Starting to save the image..");
+ save_image();
+ }
+
+cleanup:
+ suspend_cleanup();
+ suspend_deactivate_storage(0);
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-26 22:33 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 ` Nigel Cunningham [this message]
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 ` [Suspend2][ 13/16] [Suspend2] do_resume routine Nigel Cunningham
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=20060626223344.3832.83492.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