sleepy linux self-test
Subsystems (4)
Quoted 7 lines · David Brownell
Quoted 5 lines · Ingo Molnar
randconfig testing found the following build failure:
kernel/built-in.o: In function `be_sleepy':
sleepy.c:(.init.text+0x1952): undefined reference tortc_class' sleepy.c:(.init.text+0x1963): undefined reference tortc_class_open'
Quoted 9 lines
Because:
Quoted 1 line
CONFIG_RTC_LIB=mI think that the wakealarm test:
Quoted 3 lines
kernel/power/Kconfig +3
-0+config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB
I guess it also should depend on CONFIG_RTC_DRV_CMOS (not being a module) and !CONFIG_RTC.
Quoted 226 lines
should depend on RTC_LIB=y ... which will prevent that build error, but would still allow the RTC to live in a module.
Updated patch appended ... it should address most config issues.
- Dave
====== CUT HERE
Updated verion of Pavel's "sleepy" test. This version doesn't depend on x86-specific RTC support, or suspend-to-RAM capability, and describes itself a bit better.Partially tested on an ARM board ... for some reason system sleep states are currently broken on that system (new behavior since 2.6.24), so this won't yet complete.
Note a generic glitch: the message strings aren't in the same section as the function using them, so this has a bigger runtime footprint than it should ...
--- drivers/char/Kconfig | 5 +- drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 17 ++++++- kernel/power/Makefile | 2 kernel/power/sleepy.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 4 deletions(-)drivers/char/Kconfig +4
-1@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youdrivers/rtc/Kconfig +1
-0@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.kernel/power/Kconfig +15
-2@@ -1,3 +1,6 @@ +# +# Note that power management involves more than just system sleep states... +# config PM bool "Power Management support" depends on !IA64_HP_SIM@@ -74,8 +77,8 @@ config PM_TRACE_RTC RTC across reboots, so that you can debug a machine that just hangs during suspend (or more commonly, during resume). - To use this debugging feature you should attempt to suspend the machine, - then reboot it, then run + To use this debugging feature you should attempt to suspend the + machine, then reboot it, then run dmesg -s 1000000 | grep 'hash matches'@@ -104,6 +107,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENkernel/power/Makefile +1
-1@@ -5,7 +5,7 @@ endif obj-y := main.o obj-$(CONFIG_PM_LEGACY) += pm.o -obj-$(CONFIG_PM_SLEEP) += process.o console.o +obj-$(CONFIG_PM_SLEEP) += process.o console.o sleepy.o obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.okernel/power/sleepy.c new file +113
-1@@ -0,0 +1,113 @@ +/* +* Copyright (c) 2007 Pavel Machek <[email protected]> +* Copyright (c) 2008 David Brownell +* +* This file is released under the GPLv2 +*/ + +#include <linux/module.h> +#include <linux/suspend.h> +#include <linux/kobject.h> +#include <linux/string.h> +#include <linux/delay.h> +#include <linux/errno.h> +#include <linux/init.h> +#include <linux/console.h> +#include <linux/cpu.h> +#include <linux/resume-trace.h> +#include <linux/freezer.h> +#include <linux/vmstat.h> +#include <linux/syscalls.h> +#include <linux/rtc.h> + +#include <asm/percpu.h> + +#include "power.h" + + +static struct rtc_device *rtc; +static suspend_state_t sleepy_state; + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +#ifdef CONFIG_PM_WAKEALARM_TEST + +/* This needs to be long enough for the system to suspend all its devices +* and enter a suspend-to-RAM (or, potentially, standby) state no matter +* what else is going on. But suspending can take arbitrarily long... +*/ +#define ALARM_SECONDS 5 + +static void __init test_wakealarm (void ) +{ +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +pr_err ("PM: can't read %s time, err %d\n" , + rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +ALARM_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +pr_err ("PM: can't set %s wakealarm, err %d\n" , + rtc->dev.bus_id, status); +return ; + } + +pr_info ("PM: wakealarm test with Suspend-to-RAM\n" ); + sleepy_state =PM_SUSPEND_MEM ; + status =pm_suspend (sleepy_state); +if (status == -ENODEV ) { +pr_warning ("PM: no Suspend-To-RAM, trying standby...\n" ); + sleepy_state =PM_SUSPEND_STANDBY ; + status =pm_suspend (sleepy_state); + } +if (status) +pr_err ("PM: wakealarm test failed, error %d\n" , status); +} + +#else + +static void __init test_wakealarm (void ) +{ +/* FIXME sleepy_state is PM_SUSPEND_ON; not useful ... */ +} + +#endif + +static int __init be_sleepy (void ) +{ +char *pony =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); +else +pr_warning ("PM: no wakealarm-capable RTC driver is ready\n" ); + +if (rtc) +test_wakealarm (); +return 0 ; +} +late_initcall (be_sleepy); --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 6 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIBI guess it also should depend on
CONFIG_RTC_DRV_CMOS(not being a module) and !CONFIG_RTC.
No -- we need a *generic* test, not one that's needlessly coupled to PC hardware. Coping with the legacy RTC driver headache is a different issue. And ISTR that initramfs/initrd should let modules get loaded before late_initcall... yes?
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "sleepy.c" file.
- Dave
============ CUT HERE
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some Kconfig tweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.
--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)
drivers/char/Kconfig +4 -1
@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you
drivers/rtc/Kconfig +1 -0
@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.
kernel/power/Kconfig +10 -0
@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKEN
kernel/power/main.c +163 -0
190 lines not on this page · raw message
Quoted 6 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIBI guess it also should depend on
CONFIG_RTC_DRV_CMOS(not being a module) and !CONFIG_RTC.
No -- we need a *generic* test, not one that's needlessly coupled to PC hardware. Coping with the legacy RTC driver headache is a different issue. And ISTR that initramfs/initrd should let modules get loaded before late_initcall... yes?
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "sleepy.c" file.
- Dave
============ CUT HERE
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some Kconfig tweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.
--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)
drivers/char/Kconfig +4 -1
@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you
drivers/rtc/Kconfig +1 -0
@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.
kernel/power/Kconfig +10 -0
@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKEN
kernel/power/main.c +163 -0
190 lines not on this page · raw message
Quoted 12 lines · David Brownell
Quoted 6 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIBI guess it also should depend on
CONFIG_RTC_DRV_CMOS(not being a module) and !CONFIG_RTC.No -- we need a *generic* test, not one that's needlessly coupled to PC hardware. Coping with the legacy RTC driver headache is a different issue. And ISTR that initramfs/initrd should let modules get loaded before
late_initcall... yes?
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.
The changes look good to me.
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Thanks,
Rafael
Quoted 279 lines
============ CUT HERE
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)drivers/char/Kconfig +4
-1@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youdrivers/rtc/Kconfig +1
-0@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENkernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > (TEST_SUSPEND_SECONDS *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Quoted 12 lines · David Brownell
Quoted 6 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIBI guess it also should depend on
CONFIG_RTC_DRV_CMOS(not being a module) and !CONFIG_RTC.No -- we need a *generic* test, not one that's needlessly coupled to PC hardware. Coping with the legacy RTC driver headache is a different issue. And ISTR that initramfs/initrd should let modules get loaded before
late_initcall... yes?
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.
The changes look good to me.
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Thanks,
Rafael
Quoted 279 lines
============ CUT HERE
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)drivers/char/Kconfig +4
-1@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youdrivers/rtc/Kconfig +1
-0@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENkernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > (TEST_SUSPEND_SECONDS *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Quoted 7 lines
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Quoted 2 lines
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Except ... "rtcwake" (from util-linux-ng) already supports such
testing, albeit from userspace. But not the timing tests.
What was the rationale for wanting this done in-kernel? (Other than to know it can work portably.)
- Dave
Quoted 7 lines
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Quoted 2 lines
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Except ... "rtcwake" (from util-linux-ng) already supports such
testing, albeit from userspace. But not the timing tests.
What was the rationale for wanting this done in-kernel? (Other than to know it can work portably.)
- Dave
Quoted 15 lines · David Brownell
Quoted 7 lines
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Quoted 8 lines
Quoted 2 lines
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Except ... "rtcwake" (from util-linux-ng) already supports such
testing, albeit from userspace. But not the timing tests.What was the rationale for wanting this done in-kernel? (Other than to know it can work portably.)
Ingo wants it for automated testing not involving user space modifications.
Thanks,
Rafael
Quoted 15 lines · David Brownell
Quoted 7 lines
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Quoted 8 lines
Quoted 2 lines
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Except ... "rtcwake" (from util-linux-ng) already supports such
testing, albeit from userspace. But not the timing tests.What was the rationale for wanting this done in-kernel? (Other than to know it can work portably.)
Ingo wants it for automated testing not involving user space modifications.
Thanks,
Rafael
Hi!
Quoted 7 lines
Quoted 1 line
The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Well, I'd say that timing has bigger problem, right?
It is
set alarm
suspend system
| poweroff
alarm expires
system resumes
... so you are measuring resume time + sleep time, no?
Quoted 8 lines
Quoted 2 lines
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Except ... "rtcwake" (from util-linux-ng) already supports such
testing, albeit from userspace. But not the timing tests.What was the rationale for wanting this done in-kernel? (Other than to know it can work portably.)
Ingo has to answer this one...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 12 lines
Quoted 7 lines
Quoted 1 line
The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Well, I'd say that timing has bigger problem, right?
It is
Quoted 7 lines
set alarm
suspend system
| poweroff
alarm expires
system resumes... so you are measuring resume time + sleep time, no?
There's no "poweroff" step when entering STR or STANDBY!
But more specifically, I avoided that issue by comparing times between
(a) start and end of the "suspend devices" steps;
(b) start and end of the "resume devices" steps.
Example output, with the relevant lines highlighted by "*":
PM: test RTC wakeup from 'mem' suspend
PM: Syncing filesystems ... done.
PM: Preparing system for mem sleep
Freezing user space processes ... (elapsed 0.00 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
PM: Entering mem sleep
Suspending console(s)
* PM: suspend devices took 0.000 seconds
GPIO-A may wake for 00080000
GPIO-C may wake for 00000008
GPIO-D may wake for 00000020
AT91: PM - wake mask 00000036, pm state 3
AT91: PM - no slow clock mode yet ...
AT91: PM - wakeup 00000002 * PM: resume devices took 0.132 seconds
PM: Finishing wakeup.
Restarting tasks ... done.
The underlying clocksource has resolution of 32 KiHz, while HZ=128; the "suspend" more typically reports 7 msec. And there should be a few more wakeup GPIOs, except I seem to not have enabled gpio_keys. That "wakeup 00000002" means the heavily-overloaded "system" IRQ woke the system ... the RTC is on that IRQ line.
- Dave
Quoted 12 lines
Quoted 7 lines
Quoted 1 line
The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Well, I'd say that timing has bigger problem, right?
It is
Quoted 7 lines
set alarm
suspend system
| poweroff
alarm expires
system resumes... so you are measuring resume time + sleep time, no?
There's no "poweroff" step when entering STR or STANDBY!
But more specifically, I avoided that issue by comparing times between
(a) start and end of the "suspend devices" steps;
(b) start and end of the "resume devices" steps.
Example output, with the relevant lines highlighted by "*":
PM: test RTC wakeup from 'mem' suspend
PM: Syncing filesystems ... done.
PM: Preparing system for mem sleep
Freezing user space processes ... (elapsed 0.00 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
PM: Entering mem sleep
Suspending console(s)
* PM: suspend devices took 0.000 seconds
GPIO-A may wake for 00080000
GPIO-C may wake for 00000008
GPIO-D may wake for 00000020
AT91: PM - wake mask 00000036, pm state 3
AT91: PM - no slow clock mode yet ...
AT91: PM - wakeup 00000002 * PM: resume devices took 0.132 seconds
PM: Finishing wakeup.
Restarting tasks ... done.
The underlying clocksource has resolution of 32 KiHz, while HZ=128; the "suspend" more typically reports 7 msec. And there should be a few more wakeup GPIOs, except I seem to not have enabled gpio_keys. That "wakeup 00000002" means the heavily-overloaded "system" IRQ woke the system ... the RTC is on that IRQ line.
- Dave
Hi!
Quoted 46 lines
Quoted 12 lines
Quoted 7 lines
Quoted 1 line
The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Well, I'd say that timing has bigger problem, right?
It is
Quoted 7 lines
set alarm
suspend system
| poweroff
alarm expires
system resumes... so you are measuring resume time + sleep time, no?
There's no "poweroff" step when entering STR or STANDBY!
But more specifically, I avoided that issue by comparing times between
(a) start and end of the "suspend devices" steps;
(b) start and end of the "resume devices" steps.Example output, with the relevant lines highlighted by "*":
PM: test RTC wakeup from 'mem' suspend
PM: Syncing filesystems ... done.
PM: Preparing system for mem sleep
Freezing user space processes ... (elapsed 0.00 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
PM: Entering mem sleep
Suspending console(s)
* PM: suspend devices took 0.000 secondsGPIO-A may wake for 00080000 GPIO-C may wake for 00000008 GPIO-D may wake for 00000020 AT91: PM - wake mask 00000036, pm state 3 AT91: PM - no slow clock mode yet ... AT91: PM - wakeup 00000002* PM: resume devices took 0.132 seconds
PM: Finishing wakeup.
Restarting tasks ... done.
Quoted 5 lines
The underlying clocksource has resolution of 32 KiHz, while HZ=128; the "suspend" more typically reports 7 msec. And there should be a few more wakeup GPIOs, except I seem to not have enabled
gpio_keys. That "wakeup 00000002" means the heavily-overloaded "system" IRQ woke the system ... the RTC is on that IRQ line.
Aha, that should work, yes. Sorry for noise.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 46 lines
Quoted 12 lines
Quoted 7 lines
Quoted 1 line
The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Well, I'd say that timing has bigger problem, right?
It is
Quoted 7 lines
set alarm
suspend system
| poweroff
alarm expires
system resumes... so you are measuring resume time + sleep time, no?
There's no "poweroff" step when entering STR or STANDBY!
But more specifically, I avoided that issue by comparing times between
(a) start and end of the "suspend devices" steps;
(b) start and end of the "resume devices" steps.Example output, with the relevant lines highlighted by "*":
PM: test RTC wakeup from 'mem' suspend
PM: Syncing filesystems ... done.
PM: Preparing system for mem sleep
Freezing user space processes ... (elapsed 0.00 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
PM: Entering mem sleep
Suspending console(s)
* PM: suspend devices took 0.000 secondsGPIO-A may wake for 00080000 GPIO-C may wake for 00000008 GPIO-D may wake for 00000020 AT91: PM - wake mask 00000036, pm state 3 AT91: PM - no slow clock mode yet ... AT91: PM - wakeup 00000002* PM: resume devices took 0.132 seconds
PM: Finishing wakeup.
Restarting tasks ... done.
Quoted 5 lines
The underlying clocksource has resolution of 32 KiHz, while HZ=128; the "suspend" more typically reports 7 msec. And there should be a few more wakeup GPIOs, except I seem to not have enabled
gpio_keys. That "wakeup 00000002" means the heavily-overloaded "system" IRQ woke the system ... the RTC is on that IRQ line.
Aha, that should work, yes. Sorry for noise.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 7 lines
Quoted 1 line
The changes look good to me.
They feel unfinished to me though. :)
Like using "jiffies" instead of a clocksource, which makes trouble since the timing covers periods with IRQs disabled. And the test mode parameter needs work.
Well, I'd say that timing has bigger problem, right?
It is
set alarm
suspend system
| poweroff
alarm expires
system resumes
... so you are measuring resume time + sleep time, no?
Quoted 8 lines
Quoted 2 lines
Well, it would be nice to have this feature in as soon as reasonably possible, so that people can include suspend tests in the automated testing.
Except ... "rtcwake" (from util-linux-ng) already supports such
testing, albeit from userspace. But not the timing tests.What was the rationale for wanting this done in-kernel? (Other than to know it can work portably.)
Ingo has to answer this one...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIBI guess it also should depend on
CONFIG_RTC_DRV_CMOS(not being a module) and !CONFIG_RTC.No -- we need a *generic* test, not one that's needlessly coupled to PC hardware. Coping with the legacy RTC driver headache is a different issue. And ISTR that initramfs/initrd should let modules get loaded before
late_initcall... yes?
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.
What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
Pavel
Quoted 277 lines
============ CUT HERE
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)drivers/char/Kconfig +4
-1@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youdrivers/rtc/Kconfig +1
-0@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENkernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > (TEST_SUSPEND_SECONDS *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+config PM_WAKEALARM_TEST + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIBI guess it also should depend on
CONFIG_RTC_DRV_CMOS(not being a module) and !CONFIG_RTC.No -- we need a *generic* test, not one that's needlessly coupled to PC hardware. Coping with the legacy RTC driver headache is a different issue. And ISTR that initramfs/initrd should let modules get loaded before
late_initcall... yes?
Quoted 5 lines
See the appended; it includes more of Ingo's suggestions.
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.
What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
Pavel
Quoted 277 lines
============ CUT HERE
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)drivers/char/Kconfig +4
-1@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youdrivers/rtc/Kconfig +1
-0@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENkernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > (TEST_SUSPEND_SECONDS *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 1/1 suspend/resume self-test
Quoted 6 lines · Pavel Machek
Quoted 3 lines
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
it's working fine here, i've had it in my test-setup for a long time, and it triggers every now and then.
We should merge the patch below. My only gripe that should be solved in an add-on patch is that right now it triggers with an about 1:100 chance in randconfig tests. The reason is the insane amount of user-selected options to get this vital functionality done. Could we _PLEASE_ get a prominent "new, cool RTC driver stuff" config option that just select's all the other options?
Quoted 5 lines
Quoted 5 lines
drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)
this cannot really go via x86.git.
Linus, could you please apply the debug patch below? It's really useful and it is catching suspend/resume bugs as well.
Ingo
------------>
Subject: suspend/resume self-test
From: David Brownell <[email protected]>
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some Kconfig tweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.
--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)
drivers/char/Kconfig +4 -1
@@ -706,9 +706,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you
drivers/rtc/Kconfig +1 -0
@@ -294,6 +294,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.
kernel/power/Kconfig +10 -0
@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKEN
kernel/power/main.c +163 -0
190 lines not on this page · raw message
PATCH 1/1 suspend/resume self-test
In reply to Pavel MachekQuoted 6 lines · Pavel Machek
Quoted 3 lines
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
it's working fine here, i've had it in my test-setup for a long time, and it triggers every now and then.
We should merge the patch below. My only gripe that should be solved in an add-on patch is that right now it triggers with an about 1:100 chance in randconfig tests. The reason is the insane amount of user-selected options to get this vital functionality done. Could we _PLEASE_ get a prominent "new, cool RTC driver stuff" config option that just select's all the other options?
Quoted 5 lines
Quoted 5 lines
drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)
this cannot really go via x86.git.
Linus, could you please apply the debug patch below? It's really useful and it is catching suspend/resume bugs as well.
Ingo
------------>
Subject: suspend/resume self-test
From: David Brownell <[email protected]>
Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some Kconfig tweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.
--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)
drivers/char/Kconfig +4 -1
@@ -706,9 +706,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you
drivers/rtc/Kconfig +1 -0
@@ -294,6 +294,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.
kernel/power/Kconfig +10 -0
@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKEN
kernel/power/main.c +163 -0
190 lines not on this page · raw message
Re: [patch] suspend/resume self-test
Hi!
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
it's working fine here, i've had it in my test-setup for a long time, and it triggers every now and then.
Quoted 6 lines
We should merge the patch below. My only gripe that should be solved in an add-on patch is that right now it triggers with an about 1:100 chance in randconfig tests. The reason is the insane amount of user-selected options to get this vital functionality done. Could we _PLEASE_ get a prominent "new, cool RTC driver stuff" config option that just select's all the other options?
Meaning "only 1% of tests have right options for this to trigger"?
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)this cannot really go via x86.git.
Linus, could you please apply the debug patch below? It's really useful and it is catching suspend/resume bugs as well.
Yes, that would be very nice.
Quoted 25 lines
Subject: suspend/resume self-test
From: David Brownell <[email protected]>Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Quoted 7 lines
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.Signed-off-by Ingo Molnar <[email protected]>
Quoted 256 lines
--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)Index: linux/drivers/char/Kconfig
===================================================================drivers/char/Kconfig +4
-1@@ -706,9 +706,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youIndex: linux/drivers/rtc/Kconfig
===================================================================drivers/rtc/Kconfig +1
-0@@ -294,6 +294,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.Index: linux/kernel/power/Kconfig
===================================================================kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENIndex:
linux/kernel/power/main.c
===================================================================kernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > ((TEST_SUSPEND_SECONDS +5 ) *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] suspend/resume self-test
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
I think "no test" should be the default; STR working sanely on x86 is unfortunately too much a surprise. Someone more active in PM testing should update that.
Quoted 3 lines
Quoted 3 lines
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.
That's already been split out in a separate patch, now in MM. Though it may deserve another tweak, forcing off *all* legacy RTC drivers if the new framework is enabled.
Re: [patch] suspend/resume self-test
In reply to Pavel MachekQuoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
I think "no test" should be the default; STR working sanely on x86 is unfortunately too much a surprise. Someone more active in PM testing should update that.
Quoted 3 lines
Quoted 3 lines
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.
That's already been split out in a separate patch, now in MM. Though it may deserve another tweak, forcing off *all* legacy RTC drivers if the new framework is enabled.
Re: [patch] suspend/resume self-test
Quoted 5 lines · David Brownell
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
I think "no test" should be the default;
Agreed.
Quoted 1 line
STR working sanely on x86 is unfortunately too much a surprise.
Well, out of 4 boxes I have, one doesn't resume from suspend, but this is the one that's terminally broken otherwise. :-)
Quoted 10 lines
Someone more active in PM testing should update that.
Quoted 3 lines
Quoted 3 lines
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.That's already been split out in a separate patch, now in MM. Though it may deserve another tweak, forcing off *all* legacy RTC drivers if the new framework is enabled.
Yes, the legacy drivers shoule depend on !(new framework).
Thanks,
Rafael
Re: [patch] suspend/resume self-test
In reply to David BrownellQuoted 5 lines · David Brownell
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
I think "no test" should be the default;
Agreed.
Quoted 1 line
STR working sanely on x86 is unfortunately too much a surprise.
Well, out of 4 boxes I have, one doesn't resume from suspend, but this is the one that's terminally broken otherwise. :-)
Quoted 10 lines
Someone more active in PM testing should update that.
Quoted 3 lines
Quoted 3 lines
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.That's already been split out in a separate patch, now in MM. Though it may deserve another tweak, forcing off *all* legacy RTC drivers if the new framework is enabled.
Yes, the legacy drivers shoule depend on !(new framework).
Thanks,
Rafael
Re: [patch] suspend/resume self-test
In reply to David BrownellQuoted 7 lines · David Brownell
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
I think "no test" should be the default; STR working sanely on x86 is unfortunately too much a surprise. Someone more active in PM testing should update that.
All i'm asking for is to make the self-test easily accessible. Not for it to blow up in the face of users who do not ask for it.
And, at least to me, there seems to be a rather apparent correlation between "suspend/resume regressions caught as early as possible" and the future, desired state of: "STR working sanely on x86" ;-)
You really seem to treat S2R suckiness as a fact of life, but it isnt. Yes, it's a hard field for a number of reasons, but we could be doing _a lot_ better. One of them would be this "notice s2r breakage when i create or add the patch that breaks it" angle.
Ingo
Re: [patch] suspend/resume self-test
In reply to David BrownellQuoted 7 lines · David Brownell
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
I think "no test" should be the default; STR working sanely on x86 is unfortunately too much a surprise. Someone more active in PM testing should update that.
All i'm asking for is to make the self-test easily accessible. Not for it to blow up in the face of users who do not ask for it.
And, at least to me, there seems to be a rather apparent correlation between "suspend/resume regressions caught as early as possible" and the future, desired state of: "STR working sanely on x86" ;-)
You really seem to treat S2R suckiness as a fact of life, but it isnt. Yes, it's a hard field for a number of reasons, but we could be doing _a lot_ better. One of them would be this "notice s2r breakage when i create or add the patch that breaks it" angle.
Ingo
Re: [patch] suspend/resume self-test
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · David Brownell
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Quoted 6 lines
Quoted 3 lines
I think "no test" should be the default; STR working sanely on x86 is unfortunately too much a surprise. Someone more active in PM testing should update that.
All i'm asking for is to make the self-test easily accessible. Not for it to blow up in the face of users who do not ask for it.
I'm all for that, but also I don't want to see it blow up regularly in the face of people who just enable all the selftest options. The other tests have a much better expectation of working "by default".
Quoted 3 lines
And, at least to me, there seems to be a rather apparent correlation between "suspend/resume regressions caught as early as possible" and the future, desired state of: "STR working sanely on x86" ;-)
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
Quoted 1 line
You really seem to treat S2R suckiness as a fact of life, but it isnt.
Until it starts working on a given platform, it *IS* a fact of life.
Once it works, then it's fair to enter "no regressions" mode. Despite all the recent improvements, I think it's unwise to pretend that STR works properly on most systems.
Quoted 3 lines
Yes, it's a hard field for a number of reasons, but we could be doing _a
lot_better. One of them would be this "notice s2r breakage when i create or add the patch that breaks it" angle.
Right, and the best way to ensure that it's only *regressions* that break things is to expect someone to have configured the kernel command line appropriately (in grub or whatever).
Another way to achieve that is to include the test code based on one config option, and change the test *mode* based on another one. That way a distro could include that in standard kernels with "no test" mode as the default, but it would be easy to enable only for oneshot tests or field troubleshooting ... while developers could turn on the more dangerous "always test STR" (or standby, or hibernate) mode, if they were helping to find and fix problems surfaced by such tests.
- Dave
Re: [patch] suspend/resume self-test
In reply to Ingo MolnarQuoted 7 lines · Ingo Molnar
Quoted 4 lines · David Brownell
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Quoted 6 lines
Quoted 3 lines
I think "no test" should be the default; STR working sanely on x86 is unfortunately too much a surprise. Someone more active in PM testing should update that.
All i'm asking for is to make the self-test easily accessible. Not for it to blow up in the face of users who do not ask for it.
I'm all for that, but also I don't want to see it blow up regularly in the face of people who just enable all the selftest options. The other tests have a much better expectation of working "by default".
Quoted 3 lines
And, at least to me, there seems to be a rather apparent correlation between "suspend/resume regressions caught as early as possible" and the future, desired state of: "STR working sanely on x86" ;-)
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
Quoted 1 line
You really seem to treat S2R suckiness as a fact of life, but it isnt.
Until it starts working on a given platform, it *IS* a fact of life.
Once it works, then it's fair to enter "no regressions" mode. Despite all the recent improvements, I think it's unwise to pretend that STR works properly on most systems.
Quoted 3 lines
Yes, it's a hard field for a number of reasons, but we could be doing _a
lot_better. One of them would be this "notice s2r breakage when i create or add the patch that breaks it" angle.
Right, and the best way to ensure that it's only *regressions* that break things is to expect someone to have configured the kernel command line appropriately (in grub or whatever).
Another way to achieve that is to include the test code based on one config option, and change the test *mode* based on another one. That way a distro could include that in standard kernels with "no test" mode as the default, but it would be easy to enable only for oneshot tests or field troubleshooting ... while developers could turn on the more dangerous "always test STR" (or standby, or hibernate) mode, if they were helping to find and fix problems surfaced by such tests.
- Dave
Re: [patch] suspend/resume self-test
Quoted 19 lines · David Brownell
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · David Brownell
Quoted 3 lines
Quoted 3 lines
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Quoted 6 lines
Quoted 3 lines
I think "no test" should be the default; STR working sanely on x86 is unfortunately too much a surprise. Someone more active in PM testing should update that.
All i'm asking for is to make the self-test easily accessible. Not for it to blow up in the face of users who do not ask for it.
I'm all for that, but also I don't want to see it blow up regularly in the face of people who just enable all the selftest options. The other tests have a much better expectation of working "by default".
Quoted 8 lines
Quoted 3 lines
And, at least to me, there seems to be a rather apparent correlation between "suspend/resume regressions caught as early as possible" and the future, desired state of: "STR working sanely on x86" ;-)
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
David is right here. At minimum, s2ram needs acpi_sleep=... options to tell it how to set up the video. That is not issue for you, but it means we should not be doing it by default.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] suspend/resume self-test
Quoted 8 lines · Pavel Machek
Quoted 4 lines
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
David is right here. At minimum, s2ram needs acpi_sleep=... options to tell it how to set up the video. That is not issue for you, but it means we should not be doing it by default.
nowhere did i suggest that it should be default-enabled ...
i just suggest the obvious: please make it a trivial, 2 seconds flip of a switch, instead of a 60 minutes hunting which i had to do to enable the S2RAM self-test: which also meant i had to write a few patches to print out what the code does and why it does not work, to finally enable this critical test infrastructure.
damn, with that kind of attitude towards people who _want to help_, no wonder s2ram still sucks ;-)
Ingo
Re: [patch] suspend/resume self-test
In reply to Pavel MachekQuoted 8 lines · Pavel Machek
Quoted 4 lines
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
David is right here. At minimum, s2ram needs acpi_sleep=... options to tell it how to set up the video. That is not issue for you, but it means we should not be doing it by default.
nowhere did i suggest that it should be default-enabled ...
i just suggest the obvious: please make it a trivial, 2 seconds flip of a switch, instead of a 60 minutes hunting which i had to do to enable the S2RAM self-test: which also meant i had to write a few patches to print out what the code does and why it does not work, to finally enable this critical test infrastructure.
damn, with that kind of attitude towards people who _want to help_, no wonder s2ram still sucks ;-)
Ingo
Re: [patch] suspend/resume self-test
Quoted 7 lines · Ingo Molnar
Quoted 5 lines · Pavel Machek
Quoted 4 lines
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
Quoted 5 lines
Quoted 3 lines
David is right here. At minimum, s2ram needs acpi_sleep=... options to tell it how to set up the video. That is not issue for you, but it means we should not be doing it by default.
nowhere did i suggest that it should be default-enabled ...
The patch you asked to be merged *DID* have it be default-enabled! So you did more than just "suggest"... if that option is enabled in Kconfig, this test is always forced on and it will cause failures on systems where STR has never worked.
The patch comments even pointed out that flaw.
Re: [patch] suspend/resume self-test
In reply to Ingo MolnarQuoted 7 lines · Ingo Molnar
Quoted 5 lines · Pavel Machek
Quoted 4 lines
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
Quoted 5 lines
Quoted 3 lines
David is right here. At minimum, s2ram needs acpi_sleep=... options to tell it how to set up the video. That is not issue for you, but it means we should not be doing it by default.
nowhere did i suggest that it should be default-enabled ...
The patch you asked to be merged *DID* have it be default-enabled! So you did more than just "suggest"... if that option is enabled in Kconfig, this test is always forced on and it will cause failures on systems where STR has never worked.
The patch comments even pointed out that flaw.
Re: [patch] suspend/resume self-test
Quoted 6 lines · David Brownell
Quoted 1 line
nowhere did i suggest that it should be default-enabled ...
The patch you asked to be merged *DID* have it be default-enabled! So you did more than just "suggest"... if that option is enabled in
Kconfig, this test is always forced on and it will cause failures on systems where STR has never worked.
i think you dont understand what "default enabled" means in this context. Default enabled means the Kconfig entry has a "default y" line
- which it did not have in the patch i sent.
if a tester enables the .config option then it is very much expected to be triggered, just like the other .config debug options. Of course, the tester specifically enabled it, so that's what we want to happen. Not some other "yes_i_really_meant_it" boot option ... There can also be _another_ .config option that turns off the 'run by default' property - but if someone selects the _default off_ feature and enables it, just like i did, then the feature is very much expected to run.
you really seem to have deep misunderstandings about how testers use Linux, what it takes to build up a proper debug infrastructure and how to utilize all these things to make Linux better. You come from the embedded world where everything is configured together specifically, where people know what they are using and were every feature is well accounted for. But you seem to have little insight into how distributions utilize kernel features and what it takes to accept the help of testers who dont know the field that well but still want to help out - as long as we let them.
These are well-established practices we use in all other debug features that help Linux today, and what you are asking for is weird, unusual and wrong. Please take a look at how all the other debug stuff works. Rule #1: testers dont have to beg the kernel for 1 hour and have to write 2 patches to let the test code be run finally ... ;-) This isnt even about any nuances where reasonable people might disagree, this is really basic testing-101 stuff.
Ingo
Re: [patch] suspend/resume self-test
In reply to David BrownellQuoted 6 lines · David Brownell
Quoted 1 line
nowhere did i suggest that it should be default-enabled ...
The patch you asked to be merged *DID* have it be default-enabled! So you did more than just "suggest"... if that option is enabled in
Kconfig, this test is always forced on and it will cause failures on systems where STR has never worked.
i think you dont understand what "default enabled" means in this context. Default enabled means the Kconfig entry has a "default y" line
- which it did not have in the patch i sent.
if a tester enables the .config option then it is very much expected to be triggered, just like the other .config debug options. Of course, the tester specifically enabled it, so that's what we want to happen. Not some other "yes_i_really_meant_it" boot option ... There can also be _another_ .config option that turns off the 'run by default' property - but if someone selects the _default off_ feature and enables it, just like i did, then the feature is very much expected to run.
you really seem to have deep misunderstandings about how testers use Linux, what it takes to build up a proper debug infrastructure and how to utilize all these things to make Linux better. You come from the embedded world where everything is configured together specifically, where people know what they are using and were every feature is well accounted for. But you seem to have little insight into how distributions utilize kernel features and what it takes to accept the help of testers who dont know the field that well but still want to help out - as long as we let them.
These are well-established practices we use in all other debug features that help Linux today, and what you are asking for is weird, unusual and wrong. Please take a look at how all the other debug stuff works. Rule #1: testers dont have to beg the kernel for 1 hour and have to write 2 patches to let the test code be run finally ... ;-) This isnt even about any nuances where reasonable people might disagree, this is really basic testing-101 stuff.
Ingo
Re: [patch] suspend/resume self-test
In reply to David BrownellQuoted 7 lines · David Brownell
Quoted 3 lines
And, at least to me, there seems to be a rather apparent correlation between "suspend/resume regressions caught as early as possible" and the future, desired state of: "STR working sanely on x86" ;-)
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
yes, but that's not your problem, that's the STR folks' problem.
Quoted 3 lines
Right, and the best way to ensure that it's only *regressions* that break things is to expect someone to have configured the kernel command line appropriately (in grub or whatever).
a simple .config flag is perfectly fine for that, as long as it's default disabled and properly demarked. We have literally _dozens_ of "dangerous" test options and _nobody_ complains about them being dangerous ... They do their primary job of triggering bugs sooner, faster and harder, resulting in bugs getting fixed sooner, faster and harder.
Quoted 7 lines
Another way to achieve that is to include the test code based on one config option, and change the test *mode* based on another one. That way a distro could include that in standard kernels with "no test" mode as the default, but it would be easy to enable only for oneshot tests or field troubleshooting ... while developers could turn on the more dangerous "always test STR" (or standby, or hibernate) mode, if they were helping to find and fix problems surfaced by such tests.
no distro would enable this option, it just adds a needless 5-6 seconds delay to the bootup, and a needless "s2ram blows up sooner than it should" risk. _I_ want to enable this option, and want to see it trigger more often than just once out of a hundred randconfig setups.
really, you are making rookie mistakes in this area and you are doing injustice to the code you wrote and maintain :-) As i said it before, externally it looks like as if you intentionally avoided your code from being used, from people who _want_ to use your code. _I_ had to fight for almost an hour (!) until i figured out the zillions of .config variants that were finally able to get my test-system to boot-time suspend and resume all by itself. It's totally non-obvious. As far as the general Linux community goes, it's almost as if your code did not even exist, so well hidden and obscured it is.
Ingo
Re: [patch] suspend/resume self-test
In reply to David BrownellQuoted 7 lines · David Brownell
Quoted 3 lines
And, at least to me, there seems to be a rather apparent correlation between "suspend/resume regressions caught as early as possible" and the future, desired state of: "STR working sanely on x86" ;-)
Thing is, this will catch not just regressions ... but cases where STR never worked in the first place. Video problems, etc. Also various system startup races, as in the PCMCIA and MMC/SD/SDIO cases I noted.
yes, but that's not your problem, that's the STR folks' problem.
Quoted 3 lines
Right, and the best way to ensure that it's only *regressions* that break things is to expect someone to have configured the kernel command line appropriately (in grub or whatever).
a simple .config flag is perfectly fine for that, as long as it's default disabled and properly demarked. We have literally _dozens_ of "dangerous" test options and _nobody_ complains about them being dangerous ... They do their primary job of triggering bugs sooner, faster and harder, resulting in bugs getting fixed sooner, faster and harder.
Quoted 7 lines
Another way to achieve that is to include the test code based on one config option, and change the test *mode* based on another one. That way a distro could include that in standard kernels with "no test" mode as the default, but it would be easy to enable only for oneshot tests or field troubleshooting ... while developers could turn on the more dangerous "always test STR" (or standby, or hibernate) mode, if they were helping to find and fix problems surfaced by such tests.
no distro would enable this option, it just adds a needless 5-6 seconds delay to the bootup, and a needless "s2ram blows up sooner than it should" risk. _I_ want to enable this option, and want to see it trigger more often than just once out of a hundred randconfig setups.
really, you are making rookie mistakes in this area and you are doing injustice to the code you wrote and maintain :-) As i said it before, externally it looks like as if you intentionally avoided your code from being used, from people who _want_ to use your code. _I_ had to fight for almost an hour (!) until i figured out the zillions of .config variants that were finally able to get my test-system to boot-time suspend and resume all by itself. It's totally non-obvious. As far as the general Linux community goes, it's almost as if your code did not even exist, so well hidden and obscured it is.
Ingo
Re: [patch] suspend/resume self-test
In reply to Ingo MolnarHi!
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
it's working fine here, i've had it in my test-setup for a long time, and it triggers every now and then.
Quoted 6 lines
We should merge the patch below. My only gripe that should be solved in an add-on patch is that right now it triggers with an about 1:100 chance in randconfig tests. The reason is the insane amount of user-selected options to get this vital functionality done. Could we _PLEASE_ get a prominent "new, cool RTC driver stuff" config option that just select's all the other options?
Meaning "only 1% of tests have right options for this to trigger"?
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)this cannot really go via x86.git.
Linus, could you please apply the debug patch below? It's really useful and it is catching suspend/resume bugs as well.
Yes, that would be very nice.
Quoted 25 lines
Subject: suspend/resume self-test
From: David Brownell <[email protected]>Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Quoted 7 lines
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.Signed-off-by Ingo Molnar <[email protected]>
Quoted 256 lines
--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)Index: linux/drivers/char/Kconfig
===================================================================drivers/char/Kconfig +4
-1@@ -706,9 +706,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youIndex: linux/drivers/rtc/Kconfig
===================================================================drivers/rtc/Kconfig +1
-0@@ -294,6 +294,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.Index: linux/kernel/power/Kconfig
===================================================================kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENIndex:
linux/kernel/power/main.c
===================================================================kernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > ((TEST_SUSPEND_SECONDS +5 ) *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] suspend/resume self-test
In reply to Ingo MolnarQuoted 20 lines · Ingo Molnar
Quoted 6 lines · Pavel Machek
Quoted 3 lines
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
it's working fine here, i've had it in my test-setup for a long time, and it triggers every now and then.
We should merge the patch below. My only gripe that should be solved in an add-on patch is that right now it triggers with an about 1:100 chance in randconfig tests. The reason is the insane amount of user-selected options to get this vital functionality done. Could we _PLEASE_ get a prominent "new, cool RTC driver stuff" config option that just select's all the other options?
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)this cannot really go via x86.git.
In fact, it should go through the ACPI tree.
Thanks,
Rafael
Quoted 290 lines
------------>
Subject: suspend/resume self-test
From: David Brownell <[email protected]>Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.Signed-off-by Ingo Molnar <[email protected]>--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)Index: linux/drivers/char/Kconfig
===================================================================drivers/char/Kconfig +4
-1@@ -706,9 +706,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youIndex: linux/drivers/rtc/Kconfig
===================================================================drivers/rtc/Kconfig +1
-0@@ -294,6 +294,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.Index: linux/kernel/power/Kconfig
===================================================================kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENIndex:
linux/kernel/power/main.c
===================================================================kernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > ((TEST_SUSPEND_SECONDS +5 ) *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Re: [patch] suspend/resume self-test
In reply to Ingo MolnarQuoted 20 lines · Ingo Molnar
Quoted 6 lines · Pavel Machek
Quoted 3 lines
Since this is increasingly unrelated to the "sleepy linux" concept (a version of what systems like OLPC, N700, and N800 are doing), I got rid of the "
sleepy.c" file.What was the decision here? Ingo, did you merge this for 2.6.26, or just for your test farm?
it's working fine here, i've had it in my test-setup for a long time, and it triggers every now and then.
We should merge the patch below. My only gripe that should be solved in an add-on patch is that right now it triggers with an about 1:100 chance in randconfig tests. The reason is the insane amount of user-selected options to get this vital functionality done. Could we _PLEASE_ get a prominent "new, cool RTC driver stuff" config option that just select's all the other options?
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)this cannot really go via x86.git.
In fact, it should go through the ACPI tree.
Thanks,
Rafael
Quoted 290 lines
------------>
Subject: suspend/resume self-test
From: David Brownell <[email protected]>Boot-time test for system suspend states (STR or standby). The generic RTC framework triggers wakeup alarms, used to exit those states.
- Measures some aspects of suspend time; uses "jiffies". This should probably use a clocksource instead, since those often work properly even while IRQs are disabled.
- Includes a command line parameter, which needs work yet ... it currently turns this test off, but it should also let the target state be specified (and maybe even default to "no test").
Lightly tested on an ARM system, which reported that suspending devices took 7 msec and resuming them took 132 msec:
* The PCMCIA stack misbehaved a bit. It didn't finish enumerating the card before it suspended, so the wakeup event came from the CF card IRQ not from the RTC!
* The MMC stack misbehaved more seriously. It wants to remove devices during the suspend sequence (quite needlessly, on this hardware), which now makes Linux unhappy.
Workaround in both cases was to take the memory card out before booting.
Also includes some
Kconfigtweaks to help reduce configuration bugs on x86, by avoiding the legacy RTC driver when the generic RTC framework is enabled ... those should become a separate patch.Signed-off-by Ingo Molnar <[email protected]>--- drivers/char/Kconfig | 5 + drivers/rtc/Kconfig | 1 kernel/power/Kconfig | 10 +++ kernel/power/main.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)Index: linux/drivers/char/Kconfig
===================================================================drivers/char/Kconfig +4
-1@@ -706,9 +706,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), youIndex: linux/drivers/rtc/Kconfig
===================================================================drivers/rtc/Kconfig +1
-0@@ -294,6 +294,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.Index: linux/kernel/power/Kconfig
===================================================================kernel/power/Kconfig +10
-0@@ -104,6 +104,16 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (e.g. the ACPI S3 state). +config PM_TEST_SUSPEND + bool "Test suspend/resume and wakealarm during bootup" + depends on SUSPEND && PM_DEBUG && RTC_LIB=y + ---help--- + This option will suspend your machine during bootup, and make + it wake up a few seconds later using the RTC's wakeup alarm. + + You probably want to have your system's RTC driver statically + linked, ensuring that it's available when this test runs. + config SUSPEND_FREEZER bool "Enable freezer for suspend to RAM/standby" \ if ARCH_WANTS_FREEZER_CONTROL || BROKENIndex:
linux/kernel/power/main.c
===================================================================kernel/power/main.c +163
-0@@ -132,6 +132,52 @@ static inline int suspend_test(int level#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_TEST_SUSPEND + +/* +* We test the system suspend code by setting an RTC wakealarm a short +* time in the future, then suspending. Suspending the devices won't +* normally take long ... some systems only need a few milliseconds. +* +* The time it takes is system-specific though, so when we test this +* during system bootup we allow a LOT of time. +*/ +#define TEST_SUSPEND_SECONDS 5 + +static unsigned long suspend_test_start_time; + +static void suspend_test_start (void ) +{ +/* FIXME Use better timebase than "jiffies", ideally a clocksource. +* What we want is a hardware counter that will work correctly even +* during the irqs-are-off stages of the suspend/resume cycle... +*/ + suspend_test_start_time = jiffies; +} + +static void suspend_test_finish (const char *label) +{ +long nj = jiffies - suspend_test_start_time; +unsigned msec; + + msec =jiffies_to_msecs ((nj >=0 ) ? nj : -nj); +pr_info ("PM: %s took %d.%03d seconds\n" , label, + msec /1000 , msec %1000 ); +WARN_ON_ONCE (msec > ((TEST_SUSPEND_SECONDS +5 ) *1000 )); +} + +#else + +static void suspend_test_start (void ) +{ +} + +static void suspend_test_finish (const char *label) +{ +} + +#endif +/* This is just an arbitrary number */ #define FREE_PAGE_NUMBER (100)@@ -264,11 +310,14 @@ int suspend_devices_and_enter(suspend_st goto Close; }suspend_console (); + +suspend_test_start (); error =device_suspend (PMSG_SUSPEND );if (error) {printk (KERN_ERR "PM: Some devices failed to suspend\n" ); goto Resume_console; } +suspend_test_finish ("suspend devices" );if (suspend_test (TEST_DEVICES )) goto Resume_devices;@@ -291,7 +340,9 @@ int suspend_devices_and_enter(suspend_stif (suspend_ops->finish) suspend_ops->finish (); Resume_devices: +suspend_test_start ();device_resume (); +suspend_test_finish ("resume devices" ); Resume_console:resume_console (); Close:@@ -515,3 +566,115 @@ static int __init pm_init(void) }core_initcall (pm_init); + + +#ifdef CONFIG_PM_TEST_SUSPEND + +#include <linux/rtc.h> + +/* +* To test system suspend, we need a hands-off mechanism to resume the +* system. RTCs with wakeup alarms are the the most common mechanism +* that's self-contained. +*/ + +static void __init test_wakealarm (struct rtc_device *rtc,suspend_state_t state) +{ +static char err_readtime []__initdata = +KERN_ERR "PM: can't read %s time, err %d\n" ; +static char err_wakealarm []__initdata = +KERN_ERR "PM: can't set %s wakealarm, err %d\n" ; +static char err_suspend []__initdata = +KERN_ERR "PM: suspend test failed, error %d\n" ; +static char info_test []__initdata = +KERN_INFO "PM: test RTC wakeup from '%s' suspend\n" ; + +unsigned long now; +struct rtc_wkalrm alm; +int status; + +/* this may fail if the RTC hasn't been initialized */ + status =rtc_read_time (rtc, &alm.time); +if (status <0 ) { +printk (err_readtime, rtc->dev.bus_id, status); +return ; + } +rtc_tm_to_time (&alm.time, &now); + +memset (&alm,0 ,sizeof alm); +rtc_time_to_tm (now +TEST_SUSPEND_SECONDS , &alm.time); + alm.enabled = true; + + status =rtc_set_alarm (rtc, &alm); +if (status <0 ) { +printk (err_wakealarm, rtc->dev.bus_id, status); +return ; + } + +if (state ==PM_SUSPEND_MEM ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); +if (status == -ENODEV ) + state =PM_SUSPEND_STANDBY ; + } +if (state ==PM_SUSPEND_STANDBY ) { +printk (info_test, pm_states[state]); + status =pm_suspend (state); + } +if (status <0 ) +printk (err_suspend, status); +} + +static int __init has_wakealarm (struct device *dev,void *name_ptr) +{ +struct rtc_device *candidate =to_rtc_device (dev); + +if (!candidate->ops->set_alarm) +return 0 ; +if (!device_may_wakeup (candidate->dev.parent)) +return 0 ; + + *(char **)name_ptr = dev->bus_id; +return 1 ; +} + +/* +* We normally test Suspend-to-RAM, with standby as a backup when +* the system doesn't support that state. But we also need to be +* able to disable the powerup test, and tell it to ignore STR since +* the RTC may not work then. +*/ +static suspend_state_t test_state__initdata =PM_SUSPEND_MEM ; + +static int __init setup_test_suspend (char *value) +{ +/* FIXME accept "standby", etc */ + test_state =PM_SUSPEND_ON ; +return 0 ; +} +__setup ("test_suspend" , setup_test_suspend); + +static int __init test_suspend (void ) +{ +static char warn_no_rtc[]__initdata = +KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n" ; + +char *pony =NULL ; +struct rtc_device *rtc =NULL ; + +class_find_device (rtc_class, &pony, has_wakealarm); +if (pony) + rtc =rtc_class_open (pony); + +if (rtc) { +if (test_state !=PM_SUSPEND_ON ) +test_wakealarm (rtc, test_state); +rtc_class_close (rtc); + }else +printk (warn_no_rtc); + +return 0 ; +} +late_initcall (test_suspend); + +#endif /* CONFIG_PM_TEST_SUSPEND */
Hi!
Quoted 8 lines
Quoted 6 lines
[ 23.893598] Calling initcall 0xc0c518b0: be_sleepy+0x0/0x170() [ 23.901601] PM: no wakelarm-capable RTC [ 23.905599] initcall 0xc0c518b0: be_sleepy+0x0/0x170() returned 0. [ 23.910879] initcall 0xc0c518b0 ran for 3 msecs: be_sleepy+0x0/0x170()so close, yet so far away :-)
good news: the suspend+resume self-test works perfectly now! :-)
Good. What's next here? Will you just merge it to -x86, meaning it is planned for 2.6.26?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 8 lines
Quoted 6 lines
[ 23.893598] Calling initcall 0xc0c518b0: be_sleepy+0x0/0x170() [ 23.901601] PM: no wakelarm-capable RTC [ 23.905599] initcall 0xc0c518b0: be_sleepy+0x0/0x170() returned 0. [ 23.910879] initcall 0xc0c518b0 ran for 3 msecs: be_sleepy+0x0/0x170()so close, yet so far away :-)
good news: the suspend+resume self-test works perfectly now! :-)
Good. What's next here? Will you just merge it to -x86, meaning it is planned for 2.6.26?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 3 lines · Ingo Molnar
Quoted 3 lines
[ 23.509562] Calling initcall
0xc0c49e00: be_sleepy+0x0/0x170() [ 23.515837] PM: no wakelarm-capable RTC
[ 23.517562] initcall0xc0c49e00: be_sleepy+0x0/0x170() returned 0.
Because CONFIG_RTC_DRV_CMOS was not configured, though you had several other RTC drivers ready.
Quoted 1 line
#
CONFIG_RTC_DRV_CMOSis not set
Then later you had that enabled, but you also had the legacy driver enabled:
Quoted 1 line
CONFIG_RTC=y
So that was the driver which succesfully bound to the RTC (since it's probed first) and prevented the more generic code from kicking in.
Nobody has yet submitted a patch to help arbitrate between the legacy and "newfangled" RTC drivers. The general "how to Kconfig" policy has been to expect a lot (too much?) from users, but this type of annoyance is too common.
Maybe we need something to more actively avoid the "two drivers" on PC hardware ... like the appended. (The "comment" is there as a reminder to folk who still look to that menu for RTC stuff.)
- Dave
drivers/char/Kconfig +4 -1
@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you
drivers/rtc/Kconfig +1 -0
@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.
Quoted 3 lines · Ingo Molnar
Quoted 3 lines
[ 23.509562] Calling initcall
0xc0c49e00: be_sleepy+0x0/0x170() [ 23.515837] PM: no wakelarm-capable RTC
[ 23.517562] initcall0xc0c49e00: be_sleepy+0x0/0x170() returned 0.
Because CONFIG_RTC_DRV_CMOS was not configured, though you had several other RTC drivers ready.
Quoted 1 line
#
CONFIG_RTC_DRV_CMOSis not set
Then later you had that enabled, but you also had the legacy driver enabled:
Quoted 1 line
CONFIG_RTC=y
So that was the driver which succesfully bound to the RTC (since it's probed first) and prevented the more generic code from kicking in.
Nobody has yet submitted a patch to help arbitrate between the legacy and "newfangled" RTC drivers. The general "how to Kconfig" policy has been to expect a lot (too much?) from users, but this type of annoyance is too common.
Maybe we need something to more actively avoid the "two drivers" on PC hardware ... like the appended. (The "comment" is there as a reminder to folk who still look to that menu for RTC stuff.)
- Dave
drivers/char/Kconfig +4 -1
@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you
drivers/rtc/Kconfig +1 -0
@@ -281,6 +281,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards.
drivers/char/Kconfig config NVRAM · line 723
Quoted 13 lines
drivers/char/Kconfig +4
-1@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS
This looks like a prime candidate for a HAVE_RTC config variable So you do:
config RTC
tristate "Enhanced Real Time Clock Support"
+ depends on HAVE_RTC && !RTC_DEV_CMOS
config HAVE_RTC
bool
(No "depends on" allowed!)
And then the architectures that do support the RTC Framework do an:
(arch/x86/Kconfig as an example):
config X86
+ select HAVE_RTC
So when PPC suddenly supports it they add this single select statement and no more Kconfig magic needed.
See Documentation/kbuild/kconfig-language.txt for a bit more elaborate description.
Sam
drivers/char/Kconfig config NVRAM · line 723
Quoted 13 lines
drivers/char/Kconfig +4
-1@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram. +comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOS
This looks like a prime candidate for a HAVE_RTC config variable So you do:
config RTC
tristate "Enhanced Real Time Clock Support"
+ depends on HAVE_RTC && !RTC_DEV_CMOS
config HAVE_RTC
bool
(No "depends on" allowed!)
And then the architectures that do support the RTC Framework do an:
(arch/x86/Kconfig as an example):
config X86
+ select HAVE_RTC
So when PPC suddenly supports it they add this single select statement and no more Kconfig magic needed.
See Documentation/kbuild/kconfig-language.txt for a bit more elaborate description.
Sam
Quoted 6 lines · Sam Ravnborg
Quoted 6 lines
drivers/char/Kconfig +0
-0@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram.
Quoted 9 lines
drivers/char/Kconfig config NVRAM · line 723
Quoted 7 lines
drivers/char/Kconfig +4
-1+comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOSThis looks like a prime candidate for a
HAVE_RTCconfig variable
In drivers/rtc/Kconfig there's *currently* a list of about three dozen (!) different RTC drivers ... some of which support quite a few different variants.
I'd be glad to see someone clean up the config mess with respect to systems using MC146818 compatible chips, but that shouldn't begin by assuming the numerous non-MC146818 chips are somehow not real RTCs. ;)
- Dave
Quoted 6 lines · Sam Ravnborg
Quoted 6 lines
drivers/char/Kconfig +0
-0@@ -715,9 +715,12 @@ config NVRAM To compile this driver as a module, choose M here: the module will be called nvram.
Quoted 9 lines
drivers/char/Kconfig config NVRAM · line 723
Quoted 7 lines
drivers/char/Kconfig +4
-1+comment "You are using the RTC framework, not the legacy CMOS RTC driver" + depends on RTC_DRV_CMOS + config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !RTC_DRV_CMOSThis looks like a prime candidate for a
HAVE_RTCconfig variable
In drivers/rtc/Kconfig there's *currently* a list of about three dozen (!) different RTC drivers ... some of which support quite a few different variants.
I'd be glad to see someone clean up the config mess with respect to systems using MC146818 compatible chips, but that shouldn't begin by assuming the numerous non-MC146818 chips are somehow not real RTCs. ;)
- Dave
Quoted 11 lines · David Brownell
Quoted 9 lines · Ingo Molnar
Quoted 6 lines
Quoted 2 lines
Yep, you are right, but that is the easy issue to fix.
Which is why I was puzzled that you didn't start out doing it the "right" way ... even just hard-wiring the dubious assumption that "rtc0" is the right RTC to use. :)
because this was mostly about an quick & easy hack to see whether it makes sense at all to automate the testing of suspend/resume.
Quoted 6 lines
I think you should have written "quick and dirty". ;)
It would have been easier to just use the public interface and hard-wire "rtc0". But going directly to the hardware was dirtier, and more in the spirit of "hack that obviously shouldn't go upstream until it gets done properly".
Yes, it was "quick and dirty". And I do not think it is going upstream in this form...?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 17 lines
drivers/rtc/rtc-cmos.c static inline int is_intr(u8 rtc_intr) · line 84
Quoted 11 lines
drivers/rtc/rtc-cmos.c +1
-1@@ -78,7 +78,7 @@ static inline int is_intr(u8 rtc_intr)/*----------------------------------------------------------------*/ -static int cmos_read_time (struct device *dev,struct rtc_time *t) +int cmos_read_time (struct device *dev,struct rtc_time *t) { ... etc ...You should be using the standard RTC library calls, exported from
drivers/rtc/interface.c... and making sure this mechanism will work with any wakeup-capable RTC. Otherwise you'll end being needlessly x86-specific, or reinventing those calls.
Quoted 2 lines
Plus, the way you're doing it now is violating the locking protocol used by that driver.
Yep, you are right, but that is the easy issue to fix. There's hard
issue: I need
struct rtc_device *rtc
for the rtc that can be used for system resume, and I'd like to get it without violating too many layers. How to do that?
Ideally, I need
set_alarm(int)
...that will magically pick the right rtc device to talk to, and set alarm on it. I don't see how to implement it with current code.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html