PM / Hibernate : Use get_gendisk to verify partition if resume_file is integer format
Subsystems (3)
PATCH 1/1 PM / Hibernate : Use get_gendisk to verify partition if resume_file is integer format
Sometimes resume= parameter comes in integer style (e.g. major:minor) then name_to_dev_t can not detect partition properly. (especially async device like usb, mmc)
This patch calls get_gendisk if resumewait is true and resume_file is in integer format.
--- Documentation/kernel-parameters.txt | 2 ++ kernel/power/hibernate.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +2 -0
@@ -2372,6 +2372,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. resume= [SWSUSP] Specify the partition device for software suspend + Format: + {/dev/<dev> | PARTUUID=<uuid> | <int>:<int> | <hex>} resume_offset= [SWSUSP] Specify the offset from the beginning of the partition
kernel/power/hibernate.c +13 -0
@@ -25,6 +25,8 @@#include <linux/freezer.h> #include <linux/gfp.h> #include <linux/syscore_ops.h> +#include <linux/ctype.h> +#include <linux/genhd.h> #include <scsi/scsi_scan.h> #include "power.h"
@@ -722,6 +724,17 @@ static int software_resume(void)/* Check if the device is there */ swsusp_resume_device =name_to_dev_t (resume_file); + +/* +* name_to_dev_t is ineffective to verify parition if resume_file is in +* integer format. (e.g. major:minor) +*/ +if (isdigit (resume_file[0 ]) && resume_wait) { +int partno; +while (!get_gendisk (swsusp_resume_device, &partno)) +msleep (10 ); + } +if (!swsusp_resume_device) {/* * Some device discovery might still be in progress; we need
Signature · 1 line
1.7.5.4
Quoted 42 lines · Minho Ban
Sometimes resume= parameter comes in integer style (e.g. major:minor) then
name_to_dev_tcan not detect partition properly. (especially async device like usb, mmc)
This patch callsget_gendiskif resumewait is true andresume_fileis in integer format.Signed-off-by Minho Ban <[email protected]>--- Documentation/kernel-parameters.txt | 2 ++ kernel/power/hibernate.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 0 deletions(-)Documentation/kernel-parameters.txt +2
-0@@ -2372,6 +2372,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. resume= [SWSUSP] Specify the partition device for software suspend + Format: + {/dev/<dev> | PARTUUID=<uuid> | <int>:<int> | <hex>} resume_offset= [SWSUSP] Specify the offset from the beginning of the partitionkernel/power/hibernate.c +2
-0@@ -25,6 +25,8 @@#include <linux/freezer.h> #include <linux/gfp.h> #include <linux/syscore_ops.h> +#include <linux/ctype.h> +#include <linux/genhd.h> #include <scsi/scsi_scan.h> #include "power.h" @@ -722,6 +724,17 @@ static int software_resume(void)/* Check if the device is there */ swsusp_resume_device =name_to_dev_t (resume_file);
kernel/power/hibernate.c static int software_resume(void) · line 736
Quoted 10 lines
kernel/power/hibernate.c +10
-0+ +/* +* name_to_dev_t is ineffective to verify parition if resume_file is in +* integer format. (e.g. major:minor) +*/ +if (isdigit (resume_file[0 ]) && resume_wait) { +int partno; +while (!get_gendisk (swsusp_resume_device, &partno)) +msleep (10 ); + }
Hmm. Wouldn't it be better to do:
if (isdigit(resume_file[0]) && resume_wait) {
int partno;
while (!get_gendisk(swsusp_resume_device, &partno))
msleep(10);
} else {
swsusp_resume_device = name_to_dev_t(resume_file);
}?
Your new code will overwrite whatever swsusp_resume_device is set to by the preceding statement anyway.
kernel/power/hibernate.c static int software_resume(void) · line 740
Quoted 5 lines
kernel/power/hibernate.c +1
-0+if (!swsusp_resume_device) {/* * Some device discovery might still be in progress; we need
Thanks,
Rafael
Quoted 24 lines · Rafael J. Wysocki
kernel/power/hibernate.c static int software_resume(void) · line 736
Quoted 12 lines · Minho Ban
kernel/power/hibernate.c +10
-0/* Check if the device is there */ swsusp_resume_device =name_to_dev_t (resume_file); + +/* +* name_to_dev_t is ineffective to verify parition if resume_file is in +* integer format. (e.g. major:minor) +*/ +if (isdigit (resume_file[0 ]) && resume_wait) { +int partno; +while (!get_gendisk (swsusp_resume_device, &partno)) +msleep (10 ); + }Hmm. Wouldn't it be better to do:
if (isdigit(resume_file[0]) && resume_wait) { int partno; while (!get_gendisk(swsusp_resume_device, &partno)) msleep(10); } else { swsusp_resume_device = name_to_dev_t(resume_file); }
Quoted 1 line
?
Do you want name_to_dev_t to be called again? If not, swsusp_resume_device parameter in get_gendisk can not be used because it is not initialized yet.
Quoted 4 lines
Your new code will overwrite whatever
swsusp_resume_deviceis set to by the preceding statement anyway.
Sorry, I don't understand what will be overwritten by the new code. It would be very much appreciated if you point it again.
Regards,
Minho Ban
Quoted 25 lines · Minho Ban
Quoted 24 lines · Rafael J. Wysocki
kernel/power/hibernate.c static int software_resume(void) · line 736
Quoted 12 lines · Minho Ban
kernel/power/hibernate.c +10
-0/* Check if the device is there */ swsusp_resume_device =name_to_dev_t (resume_file); + +/* +* name_to_dev_t is ineffective to verify parition if resume_file is in +* integer format. (e.g. major:minor) +*/ +if (isdigit (resume_file[0 ]) && resume_wait) { +int partno; +while (!get_gendisk (swsusp_resume_device, &partno)) +msleep (10 ); + }Hmm. Wouldn't it be better to do:
if (isdigit(resume_file[0]) && resume_wait) { int partno; while (!get_gendisk(swsusp_resume_device, &partno)) msleep(10); } else { swsusp_resume_device = name_to_dev_t(resume_file); }
Quoted 4 lines
Quoted 1 line
?
Do you want
name_to_dev_tto be called again? If not,swsusp_resume_deviceparameter inget_gendiskcan not be used because it is not initialized yet.
Ah, OK, I didn't notice that.
I think I can take the patch for v3.5 as is.
Thanks,
Rafael