linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 RFT 0/2] PM / Hibernate: sysfs resume
@ 2013-08-28  1:13 Sebastian Capella
  2013-08-28  1:13 ` [PATCH v2 RFT 1/2] PM / Hibernate: use name_to_dev_t to parse resume Sebastian Capella
  2013-08-28  1:13 ` [PATCH v2 RFT 2/2] PM / Hibernate: add section for resume options Sebastian Capella
  0 siblings, 2 replies; 4+ messages in thread
From: Sebastian Capella @ 2013-08-28  1:13 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-doc, linux-pm, linaro-dev

Patchset related to hibernation resume: one enhancement to make the use
of an existing file more general and one documentation update.

Both patches are based on the 3.11-rc6 tag.  This was tested on a
Pandaboard with partial hibernation support, and compiled on x86.

Further testing is needed on other platforms.  Please let me know if
you're able to verify this on any other systems.

[PATCH 1/2] PM / Hibernate: use name_to_dev_t to parse resume
  Use name_to_dev_t to parse the /sys/power/resume file making the
  syntax more flexible.  It supports the previous use syntax
  and additionally can support other formats such as
  /dev/devicenode and UUID= formats.

  By changing /sys/debug/resume to accept the same syntax as
  the resume=device parameter, we can parse the resume=device
  in the initrd init script and use the resume device directly
  from the kernel command line.

  kernel/power/hibernate.c |   18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)

[PATCH 2/2] PM / Hibernate: add section for resume options
  This adds a small section to the swsusp.txt file to address the
  options for resuming.  This comments on the manual resume
  option which is used when resorting to an initrd or initramfs
  for resuming.  Resuming from late init is discussed later in
  the document, but it seemed appropriate to list them together.

  Documentation/power/swsusp.txt |   15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)

Changes in v2:
--------------

* Added check for null return of kstrndup in hibernate.c


Thanks,

Sebastian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 RFT 1/2] PM / Hibernate: use name_to_dev_t to parse resume
  2013-08-28  1:13 [PATCH v2 RFT 0/2] PM / Hibernate: sysfs resume Sebastian Capella
@ 2013-08-28  1:13 ` Sebastian Capella
  2013-08-28  1:13 ` [PATCH v2 RFT 2/2] PM / Hibernate: add section for resume options Sebastian Capella
  1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Capella @ 2013-08-28  1:13 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-doc, linux-pm, linaro-dev
  Cc: Sebastian Capella, Len Brown, Pavel Machek, Rafael J. Wysocki

Use the name_to_dev_t call to parse the device name echo'd to
to /sys/power/resume.  This imitates the method used in hibernate.c
in software_resume, and allows the resume partition to be specified
using other equivalent device formats as well.  By allowing
/sys/debug/resume to accept the same syntax as the resume=device
parameter, we can parse the resume=device in the init script and
use the resume device directly from the kernel command line.

Signed-off-by: Sebastian Capella <sebastian.capella@linaro.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
---
 kernel/power/hibernate.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index b26f5f1..8ba8719 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -971,15 +971,23 @@ static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
 static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
 			    const char *buf, size_t n)
 {
-	unsigned int maj, min;
 	dev_t res;
 	int ret = -EINVAL;
+	int len = n;
+	char *devcpy;
 
-	if (sscanf(buf, "%u:%u", &maj, &min) != 2)
-		goto out;
+	if (buf[len-1] == '\n')
+		len--;
+
+	devcpy = kstrndup(buf, len, GFP_KERNEL);
+
+	if (devcpy == NULL)
+		return -ENOMEM;
+
+	res = name_to_dev_t(devcpy);
+	kfree(devcpy);
 
-	res = MKDEV(maj,min);
-	if (maj != MAJOR(res) || min != MINOR(res))
+	if (res == 0)
 		goto out;
 
 	lock_system_sleep();
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 RFT 2/2] PM / Hibernate: add section for resume options
  2013-08-28  1:13 [PATCH v2 RFT 0/2] PM / Hibernate: sysfs resume Sebastian Capella
  2013-08-28  1:13 ` [PATCH v2 RFT 1/2] PM / Hibernate: use name_to_dev_t to parse resume Sebastian Capella
@ 2013-08-28  1:13 ` Sebastian Capella
  2013-09-05 12:25   ` Pavel Machek
  1 sibling, 1 reply; 4+ messages in thread
From: Sebastian Capella @ 2013-08-28  1:13 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-doc, linux-pm, linaro-dev
  Cc: Sebastian Capella, Rob Landley, Len Brown, Pavel Machek,
	Rafael J. Wysocki

Expand the existing documentation to explicitly list the options for
resuming a hibernation image, including the manual resume option which
can be used from the initrd or initramfs and the kernel init resume.

Signed-off-by: Sebastian Capella <sebastian.capella@linaro.org>
Cc: Rob Landley <rob@landley.net>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
---
 Documentation/power/swsusp.txt |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index 0b4b63e..079160e 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -50,6 +50,19 @@ echo N > /sys/power/image_size
 
 before suspend (it is limited to 500 MB by default).
 
+. The resume process checks for the presence of the resume device,
+if found, it then checks the contents for the hibernation image signature.
+If both are found, it resumes the hibernation image.
+
+. The resume process may be triggered in two ways:
+  1) During lateinit:  If resume=/dev/your_swap_partition is specified on
+     the kernel command line, lateinit runs the resume process.  If the
+     resume device has not been probed yet, the resume process fails and
+     bootup continues.
+  2) Manually from an initrd or initramfs:  May be run from
+     the init script by using the /sys/power/resume file.  It is vital
+     that this be done prior to remounting any filesystems (even as
+     read-only) otherwise data may be corrupted.
 
 Article about goals and implementation of Software Suspend for Linux
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -326,7 +339,7 @@ Q: How can distributions ship a swsusp-supporting kernel with modular
 disk drivers (especially SATA)?
 
 A: Well, it can be done, load the drivers, then do echo into
-/sys/power/disk/resume file from initrd. Be sure not to mount
+/sys/power/resume file from initrd. Be sure not to mount
 anything, not even read-only mount, or you are going to lose your
 data.
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 RFT 2/2] PM / Hibernate: add section for resume options
  2013-08-28  1:13 ` [PATCH v2 RFT 2/2] PM / Hibernate: add section for resume options Sebastian Capella
@ 2013-09-05 12:25   ` Pavel Machek
  0 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2013-09-05 12:25 UTC (permalink / raw)
  To: Sebastian Capella
  Cc: linux-kernel, linux-arm-kernel, linux-doc, linux-pm, linaro-dev,
	Rob Landley, Len Brown, Rafael J. Wysocki, trivial

Hi!

On Tue 2013-08-27 18:13:57, Sebastian Capella wrote:
> Expand the existing documentation to explicitly list the options for
> resuming a hibernation image, including the manual resume option which
> can be used from the initrd or initramfs and the kernel init resume.

...it also fixes sysfs path in second hunk.

> Signed-off-by: Sebastian Capella <sebastian.capella@linaro.org>
> Cc: Rob Landley <rob@landley.net>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Pavel Machek <pavel@ucw.cz>

Acked-by: Pavel Machek <pavel@ucw.cz>

(Cc-ed trivial so this does not get lost).

> @@ -326,7 +339,7 @@ Q: How can distributions ship a swsusp-supporting kernel with modular
>  disk drivers (especially SATA)?
>  
>  A: Well, it can be done, load the drivers, then do echo into
> -/sys/power/disk/resume file from initrd. Be sure not to mount
> +/sys/power/resume file from initrd. Be sure not to mount
>  anything, not even read-only mount, or you are going to lose your
>  data.
>  


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-05 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-28  1:13 [PATCH v2 RFT 0/2] PM / Hibernate: sysfs resume Sebastian Capella
2013-08-28  1:13 ` [PATCH v2 RFT 1/2] PM / Hibernate: use name_to_dev_t to parse resume Sebastian Capella
2013-08-28  1:13 ` [PATCH v2 RFT 2/2] PM / Hibernate: add section for resume options Sebastian Capella
2013-09-05 12:25   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).