Need to replace one patch in suspend branch
Subsystems (3)
Hi Len,
Would it be possible to replace commit a04ca6718960e842624833a01dbd5f10f38f5af1 "Suspend: Testing facility (rev. 2)" in the suspend branch with the appended patch?
Unfortunately, the original commit uses pointers to 'struct kset' which is no longer valid after the recently merged driver core changes.
Thanks,
Rafael
---
From: Rafael J. Wysocki <[email protected]>
Introduce sysfs attribute /sys/power/pm_test allowing one to test the suspend core code. Namely, writing one of the strings:
freezer
devices
platform
processors
core
to this file causes the suspend code to work in one of the test modes defined as follows:
freezer
- test the freezing of processes
devices
- test the freezing of processes and suspending of devices
platform
- test the freezing of processes, suspending of devices and platform global control methods(*)
processors
- test the freezing of processes, suspending of devices, platform global control methods and the disabling of nonboot CPUs
core
- test the freezing of processes, suspending of devices, platform global control methods, the disabling of nonboot CPUs and suspending of platform/system devices
(*) These are ACPI global control methods on ACPI systems
Then, if a suspend is started by normal means, the suspend core will perform its normal operations up to the point indicated by given test level. Next, it will wait for 5 seconds and carry out the resume operations needed to transition the system back to the fully functional state.
Writing "none" to /sys/power/pm_test turns the testing off.
When open for reading, /sys/power/pm_test contains a space-separated list of all available tests (including "none" that represents the normal functionality) in which the current test level is indicated by square brackets.
--- kernel/power/main.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++----- kernel/power/power.h | 18 ++++++++ 2 files changed, 120 insertions(+), 9 deletions(-)
kernel/power/main.c +102 -9
@@ -31,6 +31,82 @@ DEFINE_MUTEX(pm_mutex);unsigned int pm_flags;EXPORT_SYMBOL (pm_flags); +#ifdef CONFIG_PM_DEBUG +int pm_test_level =TEST_NONE ; + +static int suspend_test (int level) +{ +if (pm_test_level == level) { +printk (KERN_INFO "suspend debug: Waiting for 5 seconds.\n" ); +mdelay (5000 ); +return 1 ; + } +return 0 ; +} + +static const char *const pm_tests[__TEST_AFTER_LAST] = { + [TEST_NONE ] ="none" , + [TEST_CORE ] ="core" , + [TEST_CPUS ] ="processors" , + [TEST_PLATFORM ] ="platform" , + [TEST_DEVICES ] ="devices" , + [TEST_FREEZER ] ="freezer" , +}; + +static ssize_t pm_test_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +char *s = buf; +int level; + +for (level =TEST_FIRST ; level <=TEST_MAX ; level++) +if (pm_tests[level]) { +if (level == pm_test_level) + s +=sprintf (s,"[%s] " , pm_tests[level]); +else + s +=sprintf (s,"%s " , pm_tests[level]); + } + +if (s != buf) +/* convert the last space to a newline */ + *(s-1 ) ='\n' ; + +return (s - buf); +} + +static ssize_t pm_test_store (struct kobject *kobj,struct kobj_attribute *attr, +const char *buf,size_t n) +{ +const char *const *s; +int level; +char *p; +int len; +int error = -EINVAL ; + + p =memchr (buf,'\n' , n); + len = p ? p - buf : n; + +mutex_lock (&pm_mutex); + + level =TEST_FIRST ; +for (s = &pm_tests[level]; level <=TEST_MAX ; s++, level++) +if (*s && len ==strlen (*s) && !strncmp (buf, *s, len)) { + pm_test_level = level; + error =0 ; +break ; + } + +mutex_unlock (&pm_mutex); + +return error ? error : n; +} + +power_attr (pm_test); +#else /* !CONFIG_PM_DEBUG */ +static inline int suspend_test (int level) {return 0 ; } +#endif /* !CONFIG_PM_DEBUG */ + +#ifdef CONFIG_SUSPEND /* This is just an arbitrary number */
@@ -136,7 +212,10 @@ static int suspend_enter(suspend_state_tprintk (KERN_ERR "Some devices failed to power down\n" ); goto Done; } - error = suspend_ops->enter (state); + +if (!suspend_test (TEST_CORE )) + error = suspend_ops->enter (state); +device_power_up (); Done:arch_suspend_enable_irqs ();
@@ -167,16 +246,25 @@ int suspend_devices_and_enter(suspend_stprintk (KERN_ERR "Some devices failed to suspend\n" ); goto Resume_console; } + +if (suspend_test (TEST_DEVICES )) + goto Resume_devices; +if (suspend_ops->prepare) { error = suspend_ops->prepare ();if (error) goto Resume_devices; } + +if (suspend_test (TEST_PLATFORM )) + goto Finish; + error =disable_nonboot_cpus (); -if (!error) +if (!error && !suspend_test (TEST_CPUS ))suspend_enter (state);enable_nonboot_cpus (); + Finish:if (suspend_ops->finish) suspend_ops->finish (); Resume_devices:
@@ -243,12 +331,17 @@ static int enter_state(suspend_state_t sprintk ("done.\n" );pr_debug ("PM: Preparing system for %s sleep\n" , pm_states[state]); -if ((error =suspend_prepare ())) + error =suspend_prepare (); +if (error) goto Unlock; +if (suspend_test (TEST_FREEZER )) + goto Finish; +pr_debug ("PM: Entering %s sleep\n" , pm_states[state]); error =suspend_devices_and_enter (state); + Finish:pr_debug ("PM: Finishing wakeup.\n" );suspend_finish (); Unlock:
@@ -369,18 +462,18 @@ pm_trace_store(struct kobject *kobj, str }power_attr (pm_trace); +#endif /* CONFIG_PM_TRACE */ static struct attribute * g[] = { &state_attr.attr, +#ifdef CONFIG_PM_TRACE &pm_trace_attr.attr, +#endif +#ifdef CONFIG_PM_DEBUG + &pm_test_attr.attr, +#endifNULL , }; -#else -static struct attribute * g[] = { - &state_attr.attr, -NULL , -}; -#endif /* CONFIG_PM_TRACE */ static struct attribute_group attr_group = { .attrs = g,
kernel/power/power.h +18 -0
@@ -188,3 +188,21 @@ int restore_highmem(void);static inline unsigned int count_highmem_pages (void ) {return 0 ; }static inline int restore_highmem (void ) {return 0 ; }#endif + +/* +* Suspend test levels +*/ +enum { +/* keep first */ +TEST_NONE , +TEST_CORE , +TEST_CPUS , +TEST_PLATFORM , +TEST_DEVICES , +TEST_FREEZER , +/* keep last */ + __TEST_AFTER_LAST +}; + +#define TEST_FIRST TEST_NONE +#define TEST_MAX (__TEST_AFTER_LAST - 1)
Len Brown
reviewerQuoted 7 lines · Rafael J. Wysocki
Hi Len,
Would it be possible to replace commit
a04ca6718960e842624833a01dbd5f10f38f5af1"Suspend: Testing facility (rev. 2)" in the suspend branch with the appended patch?Unfortunately, the original commit uses pointers to 'struct kset' which is no longer valid after the recently merged driver core changes.
Hi Rafael,
The original suspend branch is now available rooted at 2.6.24 as "suspend-2.6.24".
The latest "suspend" branch is now based on today's linus HEAD.
In the suspend branch, I rewound the series until after the original patch, patch -R the original, patch -N the new one, and checked in the the resulting diff (below).
At the expense of the additional trivial patch, this struck me as a good balance between preserving the (tested) history, showing what changed, and minimizing exposure to bisect build breakage.
thanks,
-Len
commit 21779c8de31b1c9e749af676a033109f70156678
Author: Rafael J. Wysocki <[email protected]> Date: Tue Jan 29 00:29:06 2008 +0100
suspend: build fix responding to 2.6.25 kset change
kernel/power/main.c +5 -2
@@ -53,7 +53,8 @@ static const char * const pm_tests[__TEST_AFTER_LAST] = { [TEST_FREEZER] = "freezer", }; -static ssize_t pm_test_show (struct kset *kset,char *buf) +static ssize_t pm_test_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) {char *s = buf;int level;
@@ -73,7 +74,8 @@ static ssize_t pm_test_show(struct kset *kset, char *buf)return (s - buf); } -static ssize_t pm_test_store (struct kset *kset,const char *buf,size_t n) +static ssize_t pm_test_store (struct kobject *kobj,struct kobj_attribute *attr, +const char *buf,size_t n) {const char *const *s;int level;
@@ -104,6 +106,7 @@ power_attr(pm_test);static inline int suspend_test (int level) {return 0 ; }#endif /* !CONFIG_PM_DEBUG */ +#ifdef CONFIG_SUSPEND /* This is just an arbitrary number */
Len Brown
reviewerQuoted 7 lines · Rafael J. Wysocki
Hi Len,
Would it be possible to replace commit
a04ca6718960e842624833a01dbd5f10f38f5af1"Suspend: Testing facility (rev. 2)" in the suspend branch with the appended patch?Unfortunately, the original commit uses pointers to 'struct kset' which is no longer valid after the recently merged driver core changes.
Hi Rafael,
The original suspend branch is now available rooted at 2.6.24 as "suspend-2.6.24".
The latest "suspend" branch is now based on today's linus HEAD.
In the suspend branch, I rewound the series until after the original patch, patch -R the original, patch -N the new one, and checked in the the resulting diff (below).
At the expense of the additional trivial patch, this struck me as a good balance between preserving the (tested) history, showing what changed, and minimizing exposure to bisect build breakage.
thanks,
-Len
commit 21779c8de31b1c9e749af676a033109f70156678
Author: Rafael J. Wysocki <[email protected]> Date: Tue Jan 29 00:29:06 2008 +0100
suspend: build fix responding to 2.6.25 kset change
kernel/power/main.c +5 -2
@@ -53,7 +53,8 @@ static const char * const pm_tests[__TEST_AFTER_LAST] = { [TEST_FREEZER] = "freezer", }; -static ssize_t pm_test_show (struct kset *kset,char *buf) +static ssize_t pm_test_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) {char *s = buf;int level;
@@ -73,7 +74,8 @@ static ssize_t pm_test_show(struct kset *kset, char *buf)return (s - buf); } -static ssize_t pm_test_store (struct kset *kset,const char *buf,size_t n) +static ssize_t pm_test_store (struct kobject *kobj,struct kobj_attribute *attr, +const char *buf,size_t n) {const char *const *s;int level;
@@ -104,6 +106,7 @@ power_attr(pm_test);static inline int suspend_test (int level) {return 0 ; }#endif /* !CONFIG_PM_DEBUG */ +#ifdef CONFIG_SUSPEND /* This is just an arbitrary number */
Quoted 6 lines · Len Brown
Quoted 5 lines · Rafael J. Wysocki
Hi Len,
Would it be possible to replace commit
a04ca6718960e842624833a01dbd5f10f38f5af1"Suspend: Testing facility (rev. 2)" in the suspend branch with the appended patch?
Quoted 8 lines
Quoted 2 lines
Unfortunately, the original commit uses pointers to 'struct kset' which is no longer valid after the recently merged driver core changes.
Hi Rafael,
The original suspend branch is now available rooted at 2.6.24 as "suspend-2.6.24".The latest "suspend" branch is now based on today's linus HEAD.
Thanks a lot for doing that!
Quoted 8 lines
In the suspend branch, I rewound the series until after the original patch, patch -R the original, patch -N the new one, and checked in the the resulting diff (below).
At the expense of the additional trivial patch, this struck me as a good balance between preserving the (tested) history, showing what changed, and minimizing exposure to bisect build breakage.
Yes, this is a good idea to add this additional patch after the original one.
Thanks,
Rafael
Quoted 43 lines
commit
21779c8de31b1c9e749af676a033109f70156678Author: Rafael J. Wysocki <[email protected]> Date: Tue Jan 29 00:29:06 2008 +0100suspend: build fix responding to 2.6.25 kset change
Signed-off-by Rafael J. Wysocki <[email protected]>Signed-off-by Len Brown <[email protected]>kernel/power/main.c +5
-2@@ -53,7 +53,8 @@ static const char * const pm_tests[__TEST_AFTER_LAST] = { [TEST_FREEZER] = "freezer", }; -static ssize_t pm_test_show (struct kset *kset,char *buf) +static ssize_t pm_test_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) {char *s = buf;int level;@@ -73,7 +74,8 @@ static ssize_t pm_test_show(struct kset *kset, char *buf)return (s - buf); } -static ssize_t pm_test_store (struct kset *kset,const char *buf,size_t n) +static ssize_t pm_test_store (struct kobject *kobj,struct kobj_attribute *attr, +const char *buf,size_t n) {const char *const *s;int level;@@ -104,6 +106,7 @@ power_attr(pm_test);static inline int suspend_test (int level) {return 0 ; }#endif /* !CONFIG_PM_DEBUG */ +#ifdef CONFIG_SUSPEND /* This is just an arbitrary number */
Quoted 6 lines · Len Brown
Quoted 5 lines · Rafael J. Wysocki
Hi Len,
Would it be possible to replace commit
a04ca6718960e842624833a01dbd5f10f38f5af1"Suspend: Testing facility (rev. 2)" in the suspend branch with the appended patch?
Quoted 8 lines
Quoted 2 lines
Unfortunately, the original commit uses pointers to 'struct kset' which is no longer valid after the recently merged driver core changes.
Hi Rafael,
The original suspend branch is now available rooted at 2.6.24 as "suspend-2.6.24".The latest "suspend" branch is now based on today's linus HEAD.
Thanks a lot for doing that!
Quoted 8 lines
In the suspend branch, I rewound the series until after the original patch, patch -R the original, patch -N the new one, and checked in the the resulting diff (below).
At the expense of the additional trivial patch, this struck me as a good balance between preserving the (tested) history, showing what changed, and minimizing exposure to bisect build breakage.
Yes, this is a good idea to add this additional patch after the original one.
Thanks,
Rafael
Quoted 43 lines
commit
21779c8de31b1c9e749af676a033109f70156678Author: Rafael J. Wysocki <[email protected]> Date: Tue Jan 29 00:29:06 2008 +0100suspend: build fix responding to 2.6.25 kset change
Signed-off-by Rafael J. Wysocki <[email protected]>Signed-off-by Len Brown <[email protected]>kernel/power/main.c +5
-2@@ -53,7 +53,8 @@ static const char * const pm_tests[__TEST_AFTER_LAST] = { [TEST_FREEZER] = "freezer", }; -static ssize_t pm_test_show (struct kset *kset,char *buf) +static ssize_t pm_test_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) {char *s = buf;int level;@@ -73,7 +74,8 @@ static ssize_t pm_test_show(struct kset *kset, char *buf)return (s - buf); } -static ssize_t pm_test_store (struct kset *kset,const char *buf,size_t n) +static ssize_t pm_test_store (struct kobject *kobj,struct kobj_attribute *attr, +const char *buf,size_t n) {const char *const *s;int level;@@ -104,6 +106,7 @@ power_attr(pm_test);static inline int suspend_test (int level) {return 0 ; }#endif /* !CONFIG_PM_DEBUG */ +#ifdef CONFIG_SUSPEND /* This is just an arbitrary number */