public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Len Brown <lenb@kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>
Subject: Re: [linux-pm] [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory
Date: Sun, 26 Oct 2008 13:08:39 +0100	[thread overview]
Message-ID: <20081026120838.GB1607@ucw.cz> (raw)
In-Reply-To: <200810222252.11625.rjw@sisk.pl>

Hi!

> From: Rafael J. Wysocki <rjw@sisk.pl>
> 
> ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory
> 
> According to the ACPI Specification 3.0b, Section 15.3.2,
> "OSPM will call the _PTS control method some time before entering a
> sleeping state, to allow the platform???s AML code to update this
> memory image before entering the sleeping state. After the system
> awakes from an S4 state, OSPM will restore this memory area and call
> the _WAK control method to enable the BIOS to reclaim its memory
> image."  For this reason, implement a mechanism allowing us to save
> the NVS memory during hibernation and to restore it during the
> subsequent resume.
> 
> Based on a patch by Zhang Rui.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/acpi/sleep/main.c |   50 ++++++++++++++++---
>  include/linux/suspend.h   |   13 ++++
>  kernel/power/swsusp.c     |  121 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 177 insertions(+), 7 deletions(-)
> 


> @@ -387,8 +410,21 @@ static int acpi_hibernation_begin_old(vo
>  {
>  	int error = acpi_sleep_prepare(ACPI_STATE_S4);
>  
> +	if (!error) {
> +		error = hibernate_nvs_alloc();
> +		if (!error)
> +			acpi_target_sleep_state = ACPI_STATE_S4;
> +	}
> +	return error;
> +}

You can chain this without nesting...

If sleep_prepare() succeeds but nvs_alloc() fails, you should undo
sleep_prepare here, right?


>  #else /* CONFIG_HIBERNATION */
>  static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
>  static inline void swsusp_set_page_free(struct page *p) {}
> @@ -241,6 +246,14 @@ static inline void swsusp_unset_page_fre
>  static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {}
>  static inline int hibernate(void) { return -ENOSYS; }
>  static inline bool system_entering_hibernation(void) { return false; }
> +static inline int hibernate_nvs_register(unsigned long a, unsigned long b)
> +{
> +	return 0;
> +}
> +static inline int hibernate_nvs_alloc(void) { return 0; }
> +static inline void hibernate_nvs_free(void) {}
> +static inline void hibernate_nvs_save(void) {}
> +static inline void hibernate_nvs_restore(void) {}
>  #endif /* CONFIG_HIBERNATION */

Can someone call these for !hibernation case? Should they fake success
if they do call them?


> Index: linux-2.6/kernel/power/swsusp.c
> ===================================================================
> --- linux-2.6.orig/kernel/power/swsusp.c
> +++ linux-2.6/kernel/power/swsusp.c
> @@ -262,3 +262,124 @@ int swsusp_shrink_memory(void)
>  
>  	return 0;
>  }
> +
> +/*
> + * Platforms, like ACPI, may want us to save some memory used by them during
> + * hibernation and to restore the contents of this memory during the subsequent
> + * resume.  The code below implements a mechanism allowing us to do that.
> + */
> +
> +struct nvs_page {
> +	unsigned long phys_start;
> +	unsigned int size;
> +	void *kaddr;
> +	void *data;
> +	struct list_head node;
> +};

Maybe separate nvs.c file would be good? I believe this _is_ acpi
specific, altrough in theory it may not be.
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  parent reply	other threads:[~2008-10-26 12:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-22 20:49 [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec Rafael J. Wysocki
2008-10-22 20:50 ` [PATCH 1/4] Hibernate: Call platform_begin before swsusp_shrink_memory Rafael J. Wysocki
2008-10-22 22:37   ` Nigel Cunningham
2008-10-26 12:00   ` [linux-pm] " Pavel Machek
2008-10-22 20:52 ` [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory Rafael J. Wysocki
2008-10-22 22:48   ` [linux-pm] " Nigel Cunningham
2008-10-22 23:08     ` Rafael J. Wysocki
2008-10-23  1:37       ` Nigel Cunningham
2008-10-23  5:47         ` [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory (rev. 2) Rafael J. Wysocki
2008-10-23  8:03           ` Nigel Cunningham
2008-10-26 12:08   ` Pavel Machek [this message]
2008-10-26 12:23     ` [linux-pm] [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory Rafael J. Wysocki
2008-11-18 16:14       ` Pavel Machek
2008-10-22 20:53 ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup Rafael J. Wysocki
2008-10-26 12:14   ` [linux-pm] " Pavel Machek
2008-10-26 12:29     ` Rafael J. Wysocki
2008-10-29  9:21       ` Zhang Rui
2008-10-29 11:18         ` Pavel Machek
2008-10-30 23:59           ` Rafael J. Wysocki
2008-10-22 20:54 ` [PATCH 4/4] ACPI hibernate: Introduce new kernel parameter acpi_sleep=s4_nonvs Rafael J. Wysocki
2008-10-22 22:51   ` [linux-pm] " Nigel Cunningham
2008-10-22 23:10     ` Rafael J. Wysocki
2008-10-22 23:19       ` [PATCH 4/4] ACPI hibernate: Introduce new kernel parameter acpi_sleep=s4_nonvs (rev. 2) Rafael J. Wysocki
2008-10-26 12:18         ` [linux-pm] " Pavel Machek

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=20081026120838.GB1607@ucw.cz \
    --to=pavel@suse.cz \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mingo@elte.hu \
    --cc=rjw@sisk.pl \
    /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