update: i've tested Maxim's v2 patch on both a hpet-capable and a hpet-less system, and it works fine here. on a dual-core hpet-capable system, running a NO_HZ+!HIGH_RES_TIMERS kernel: europe:~> grep Clock /proc/timer_list Clock Event Device: hpet Clock Event Device: lapic Clock Event Device: lapic s2ram works fine now - it hung on resume before. on a dual-core non-hpet system, with a NO_HZ+!HIGH_RES_TIMERS kernel: neptune:~> grep Clock /proc/timer_list Clock Event Device: pit Clock Event Device: lapic Clock Event Device: lapic s2ram worked fine before - and it still works now. (The combination of NO_HZ+!HIGH_RES_TIMERS was the most fragile wrt. suspend because in the !HIGH_RES_TIMERS there's just a single instance after resume that we touch the timer hardware, and we very much rely on the periodic interrupt being set to the precise value.) So this is a go on my systems - good work Maxim! (I've reproduced Maxim's patch below with minor patch-metadata updates.) Ingo ----------------------------> Subject: [patch] add suspend/resume for HPET From: Maxim Levitsky <maximlevitsky@xxxxxxxxx> This adds support for suspend/resume on i386 for HPET. Signed-off-by: Ingo Molnar <mingo@xxxxxxx> Signed-off-by: Maxim Levitsky <maximlevitsky@xxxxxxxxx> --- arch/i386/kernel/hpet.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) Index: linux/arch/i386/kernel/hpet.c =================================================================== --- linux.orig/arch/i386/kernel/hpet.c +++ linux/arch/i386/kernel/hpet.c @@ -3,6 +3,8 @@ #include <linux/errno.h> #include <linux/hpet.h> #include <linux/init.h> +#include <linux/sysdev.h> +#include <linux/pm.h> #include <asm/hpet.h> #include <asm/io.h> @@ -307,6 +309,7 @@ int __init hpet_enable(void) out_nohpet: iounmap(hpet_virt_address); hpet_virt_address = NULL; + boot_hpet_disable = 1; return 0; } @@ -523,3 +526,68 @@ irqreturn_t hpet_rtc_interrupt(int irq, return IRQ_HANDLED; } #endif + + +/* + * Suspend/resume part + */ + +#ifdef CONFIG_PM + +static int hpet_suspend(struct sys_device *sys_device, pm_message_t state) +{ + unsigned long cfg = hpet_readl(HPET_CFG); + + cfg &= ~(HPET_CFG_ENABLE|HPET_CFG_LEGACY); + hpet_writel(cfg, HPET_CFG); + + return 0; +} + +static int hpet_resume(struct sys_device *sys_device) +{ + unsigned int id; + + hpet_start_counter(); + + id = hpet_readl(HPET_ID); + + if (id & HPET_ID_LEGSUP) + hpet_enable_int(); + + return 0; +} + +static struct sysdev_class hpet_class = { + set_kset_name("hpet"), + .suspend = hpet_suspend, + .resume = hpet_resume, +}; + +static struct sys_device hpet_device = { + .id = 0, + .cls = &hpet_class, +}; + + +static __init int hpet_register_sysfs(void) +{ + int err; + + if (!is_hpet_capable()) + return 0; + + err = sysdev_class_register(&hpet_class); + + if (!err) { + err = sysdev_register(&hpet_device); + if (err) + sysdev_class_unregister(&hpet_class); + } + + return err; +} + +device_initcall(hpet_register_sysfs); + +#endif - To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html