Skip to contentSkip to conversation

PM: HIBERNATION: add resume_wait param to support MMC-like devices as resume file

PATCH In review Barry Song 2 participants 3 messages Sep 29, 2011 – Oct 5, 2011 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v2 1/1 PM: HIBERNATION: add resume_wait param to support MMC-like devices as resume file

From: Barry Song <[email protected]>

Some devices like mmc are async detected very slow. For example, drivers/mmc/host/sdhci.c launchs a 200ms delayed work to detect mmc partitions then add disk.

we do have wait_for_device_probe and scsi_complete_async_scans before calling swsusp_check, but it is not enough to wait mmc.

This patch adds resumewait kernel param just like rootwait so that we have enough time to wait mmc ready. The differene is here we wait for resume partition but rootwait waits for rootfs partition.

This patch will make swsusp support many embedded products without scsi devices but devices like mmc.

This was tested on one ARM platform with Frank Hofmann's patch.

---
-v2:
add document for the resumewait kernel parameter

 Documentation/kernel-parameters.txt |    4 ++++
 kernel/power/hibernate.c            |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +4 -0
index 614d038..2aed0d2 100644
@@ -2237,6 +2237,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			in <PAGE_SIZE> units (needed only for swap files).
 			See  Documentation/power/swsusp-and-swap-files.txt
 
+	resumewait	[HIBERNATION] Wait (indefinitely) for resume device to show up.
+			Useful for devices that are detected asynchronously
+			(e.g. USB and MMC devices).
+
 	hibernate=	[HIBERNATION]
 		noresume	Don't check if there's a hibernation image
 				present during boot.
kernel/power/hibernate.c +16 -0
index 8f7b1db..9f4b4f3 100644
@@ -14,6 +14,7 @@
 #include <linux/reboot.h>
 #include <linux/string.h>
 #include <linux/device.h>
+#include <linux/async.h>
 #include <linux/kmod.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
@@ -31,6 +32,7 @@
 
 static int nocompress = 0;
 static int noresume = 0;
+static int resume_wait = 0;
 static char resume_file[256] = CONFIG_PM_STD_PARTITION;
 dev_t swsusp_resume_device;
 sector_t swsusp_resume_block;
@@ -732,6 +734,13 @@ static int software_resume(void)
 		 * to wait for this to finish.
 		 */
 		wait_for_device_probe();
+
+		if (resume_wait) {
+			while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
+				msleep(10);
+			async_synchronize_full();
+		}
+
 		/*
 		 * We can't depend on SCSI devices being available after loading
 		 * one of their modules until scsi_complete_async_scans() is
@@ -1060,7 +1069,14 @@ static int __init noresume_setup(char *str)
 	return 1;
 }
 
+static int __init resumewait_setup(char *str)
+{
+	resume_wait = 1;
+	return 1;
+}
+
 __setup("noresume", noresume_setup);
 __setup("resume_offset=", resume_offset_setup);
 __setup("resume=", resume_setup);
 __setup("hibernate=", hibernate_setup);
+__setup("resumewait", resumewait_setup);
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 14 lines · Barry Song

From: Barry Song <[email protected]>

Some devices like mmc are async detected very slow. For example, drivers/mmc/host/sdhci.c launchs a 200ms delayed work to detect mmc partitions then add disk.

we do have wait_for_device_probe and scsi_complete_async_scans before calling swsusp_check, but it is not enough to wait mmc.

This patch adds resumewait kernel param just like rootwait so that we have enough time to wait mmc ready. The differene is here we wait for resume partition but rootwait waits for rootfs partition.

Quoted 7 lines

This patch will make swsusp support many embedded products without scsi devices but devices like mmc.

This was tested on one ARM platform with Frank Hofmann's patch.

Sorry, I couldn't find the patch previously.

I only have one question. Namely, are there any systems that would use resumewait and wouldn't use rootwait?

Rafael

Quoted 73 lines

---
-v2:
add document for the resumewait kernel parameter

 Documentation/kernel-parameters.txt |    4 ++++
 kernel/power/hibernate.c            |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +4 -0
index 614d038..2aed0d2 100644
@@ -2237,6 +2237,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			in <PAGE_SIZE> units (needed only for swap files).
 			See  Documentation/power/swsusp-and-swap-files.txt
 
+	resumewait	[HIBERNATION] Wait (indefinitely) for resume device to show up.
+			Useful for devices that are detected asynchronously
+			(e.g. USB and MMC devices).
+
 	hibernate=	[HIBERNATION]
 		noresume	Don't check if there's a hibernation image
 				present during boot.
kernel/power/hibernate.c +16 -0
index 8f7b1db..9f4b4f3 100644
@@ -14,6 +14,7 @@
 #include <linux/reboot.h>
 #include <linux/string.h>
 #include <linux/device.h>
+#include <linux/async.h>
 #include <linux/kmod.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
@@ -31,6 +32,7 @@
 
 static int nocompress = 0;
 static int noresume = 0;
+static int resume_wait = 0;
 static char resume_file[256] = CONFIG_PM_STD_PARTITION;
 dev_t swsusp_resume_device;
 sector_t swsusp_resume_block;
@@ -732,6 +734,13 @@ static int software_resume(void)
 		 * to wait for this to finish.
 		 */
 		wait_for_device_probe();
+
+		if (resume_wait) {
+			while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
+				msleep(10);
+			async_synchronize_full();
+		}
+
 		/*
 		 * We can't depend on SCSI devices being available after loading
 		 * one of their modules until scsi_complete_async_scans() is
@@ -1060,7 +1069,14 @@ static int __init noresume_setup(char *str)
 	return 1;
 }
 
+static int __init resumewait_setup(char *str)
+{
+	resume_wait = 1;
+	return 1;
+}
+
 __setup("noresume", noresume_setup);
 __setup("resume_offset=", resume_offset_setup);
 __setup("resume=", resume_setup);
 __setup("hibernate=", hibernate_setup);
+__setup("resumewait", resumewait_setup);
#3 lore raw
In reply to a message not in the archive
Quoted 27 lines · Barry Song
Quoted 26 lines · 在 2011-10-5 上午6:30,"Rafael J. Wysocki" <[email protected]>写道:
Quoted 14 lines · Barry Song

From: Barry Song <[email protected]>

Some devices like mmc are async detected very slow. For example, drivers/mmc/host/sdhci.c launchs a 200ms delayed work to detect mmc partitions then add disk.

we do have wait_for_device_probe and scsi_complete_async_scans before calling swsusp_check, but it is not enough to wait mmc.

This patch adds resumewait kernel param just like rootwait so that we have enough time to wait mmc ready. The differene is here we wait for resume partition but rootwait waits for rootfs partition.

Quoted 7 lines

This patch will make swsusp support many embedded products without scsi devices but devices like mmc.

This was tested on one ARM platform with Frank Hofmann's patch.

Sorry, I couldn't find the patch previously.

Quoted 7 lines
Quoted 2 lines

I only have one question. Namely, are there any systems that would use resumewait and wouldn't use rootwait?

I think yes. Some devices use nand
as root and SD as resume swap.
Still some devices use both SD as root and swap. But rootfs is mounted by ramfs without rootwait.

OK, fair enough. I applied the patch to linux-pm/linux-next and will push it for 3.2.

Thanks,
Rafael

Quoted 82 lines
Quoted 9 lines

Review

Quoted 9 lines

---
-v2:
add document for the resumewait kernel parameter

 Documentation/kernel-parameters.txt |    4 ++++
 kernel/power/hibernate.c            |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/Documentation/kernel-parameters.txt

Quoted 4 lines

Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also

Quoted 4 lines

index 614d038..2aed0d2 100644

Documentation/kernel-parameters.txt +0 -0
@@ -2237,6 +2237,10 @@ bytes respectively. Such letter suffixes can also

be entirely omitted.

Quoted 4 lines

Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted.

Quoted 4 lines
Documentation/kernel-parameters.txt +1 -0
                      in <PAGE_SIZE> units (needed only for swap files).
                      See  Documentation/power/swsusp-and-swap-files.txt
 
+     resumewait      [HIBERNATION] Wait (indefinitely) for resume

device to show up.

Quoted 1 line

Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also · line 2241

Quoted 1 line
Documentation/kernel-parameters.txt +1 -0
+                     Useful for devices that are detected

asynchronously

Quoted 19 lines
Quoted 19 lines
Documentation/kernel-parameters.txt +2 -0
+                     (e.g. USB and MMC devices).
+
      hibernate=      [HIBERNATION]
              noresume        Don't check if there's a hibernation image
                              present during boot.
kernel/power/hibernate.c +1 -0
index 8f7b1db..9f4b4f3 100644
@@ -14,6 +14,7 @@
 #include <linux/reboot.h>
 #include <linux/string.h>
 #include <linux/device.h>
+#include <linux/async.h>
 #include <linux/kmod.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
@@ -31,6 +32,7 @@
 
Quoted 13 lines

kernel/power/hibernate.c static int software_resume(void) · line 739

Quoted 13 lines
kernel/power/hibernate.c +4 -0
 static int nocompress = 0;
 static int noresume = 0;
+static int resume_wait = 0;
 static char resume_file[256] = CONFIG_PM_STD_PARTITION;
 dev_t swsusp_resume_device;
 sector_t swsusp_resume_block;
@@ -732,6 +734,13 @@ static int software_resume(void)
               * to wait for this to finish.
               */
              wait_for_device_probe();
+
+             if (resume_wait) {
+                     while ((swsusp_resume_device =

name_to_dev_t(resume_file)) == 0)

Quoted 6 lines

kernel/power/hibernate.c static int software_resume(void)

Quoted 6 lines
kernel/power/hibernate.c +4 -0
+                             msleep(10);
+                     async_synchronize_full();
+             }
+
              /*
               * We can't depend on SCSI devices being available after

loading

Quoted 1 line

kernel/power/hibernate.c static int software_resume(void) · line 746

Quoted 1 line
kernel/power/hibernate.c +0 -0
               * one of their modules until scsi_complete_async_scans()

is

Quoted 17 lines
Quoted 16 lines
kernel/power/hibernate.c +7 -0
@@ -1060,7 +1069,14 @@ static int __init noresume_setup(char *str)
      return 1;
 }
 
+static int __init resumewait_setup(char *str)
+{
+     resume_wait = 1;
+     return 1;
+}
+
 __setup("noresume", noresume_setup);
 __setup("resume_offset=", resume_offset_setup);
 __setup("resume=", resume_setup);
 __setup("hibernate=", hibernate_setup);
+__setup("resumewait", resumewait_setup);