aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2007-07-21 07:37:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-21 20:49:15 -0400
commit18de5bc4c1f1f1fa5e14f354a7603bd6e9d4e3b6 (patch)
treecb0ff399fb3f368adecf213318e32a499ada6ff9 /arch/i386
parent93da56efcf8c6a111f0349f6b7651172d4745ca0 (diff)
clockevents: fix resume logic
We need to make sure, that the clockevent devices are resumed, before the tick is resumed. The current resume logic does not guarantee this. Add CLOCK_EVT_MODE_RESUME and call the set mode functions of the clock event devices before resuming the tick / oneshot functionality. Fixup the existing users. Thanks to Nigel Cunningham for tracking down a long standing thinko, which affected the jinxed VAIO. [akpm@linux-foundation.org: xen build fix] Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: john stultz <johnstul@us.ibm.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/i386')
-rw-r--r--arch/i386/kernel/apic.c3
-rw-r--r--arch/i386/kernel/hpet.c71
-rw-r--r--arch/i386/kernel/i8253.c26
-rw-r--r--arch/i386/kernel/vmiclock.c1
-rw-r--r--arch/i386/xen/time.c3
5 files changed, 24 insertions, 80 deletions
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 67824f3bb974..610f44b24367 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -263,6 +263,9 @@ static void lapic_timer_setup(enum clock_event_mode mode,
263 v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR); 263 v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
264 apic_write_around(APIC_LVTT, v); 264 apic_write_around(APIC_LVTT, v);
265 break; 265 break;
266 case CLOCK_EVT_MODE_RESUME:
267 /* Nothing to do here */
268 break;
266 } 269 }
267 270
268 local_irq_restore(flags); 271 local_irq_restore(flags);
diff --git a/arch/i386/kernel/hpet.c b/arch/i386/kernel/hpet.c
index 17d73459fc5f..cfbf792a0bf4 100644
--- a/arch/i386/kernel/hpet.c
+++ b/arch/i386/kernel/hpet.c
@@ -187,6 +187,10 @@ static void hpet_set_mode(enum clock_event_mode mode,
187 cfg &= ~HPET_TN_ENABLE; 187 cfg &= ~HPET_TN_ENABLE;
188 hpet_writel(cfg, HPET_T0_CFG); 188 hpet_writel(cfg, HPET_T0_CFG);
189 break; 189 break;
190
191 case CLOCK_EVT_MODE_RESUME:
192 hpet_enable_int();
193 break;
190 } 194 }
191} 195}
192 196
@@ -217,6 +221,7 @@ static struct clocksource clocksource_hpet = {
217 .mask = HPET_MASK, 221 .mask = HPET_MASK,
218 .shift = HPET_SHIFT, 222 .shift = HPET_SHIFT,
219 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 223 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
224 .resume = hpet_start_counter,
220}; 225};
221 226
222/* 227/*
@@ -291,7 +296,6 @@ int __init hpet_enable(void)
291 296
292 clocksource_register(&clocksource_hpet); 297 clocksource_register(&clocksource_hpet);
293 298
294
295 if (id & HPET_ID_LEGSUP) { 299 if (id & HPET_ID_LEGSUP) {
296 hpet_enable_int(); 300 hpet_enable_int();
297 hpet_reserve_platform_timers(id); 301 hpet_reserve_platform_timers(id);
@@ -524,68 +528,3 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
524 return IRQ_HANDLED; 528 return IRQ_HANDLED;
525} 529}
526#endif 530#endif
527
528
529/*
530 * Suspend/resume part
531 */
532
533#ifdef CONFIG_PM
534
535static int hpet_suspend(struct sys_device *sys_device, pm_message_t state)
536{
537 unsigned long cfg = hpet_readl(HPET_CFG);
538
539 cfg &= ~(HPET_CFG_ENABLE|HPET_CFG_LEGACY);
540 hpet_writel(cfg, HPET_CFG);
541
542 return 0;
543}
544
545static int hpet_resume(struct sys_device *sys_device)
546{
547 unsigned int id;
548
549 hpet_start_counter();
550
551 id = hpet_readl(HPET_ID);
552
553 if (id & HPET_ID_LEGSUP)
554 hpet_enable_int();
555
556 return 0;
557}
558
559static struct sysdev_class hpet_class = {
560 set_kset_name("hpet"),
561 .suspend = hpet_suspend,
562 .resume = hpet_resume,
563};
564
565static struct sys_device hpet_device = {
566 .id = 0,
567 .cls = &hpet_class,
568};
569
570
571static __init int hpet_register_sysfs(void)
572{
573 int err;
574
575 if (!is_hpet_capable())
576 return 0;
577
578 err = sysdev_class_register(&hpet_class);
579
580 if (!err) {
581 err = sysdev_register(&hpet_device);
582 if (err)
583 sysdev_class_unregister(&hpet_class);
584 }
585
586 return err;
587}
588
589device_initcall(hpet_register_sysfs);
590
591#endif
diff --git a/arch/i386/kernel/i8253.c b/arch/i386/kernel/i8253.c
index f8a3c4054c70..931eabe1e560 100644
--- a/arch/i386/kernel/i8253.c
+++ b/arch/i386/kernel/i8253.c
@@ -3,11 +3,11 @@
3 * 3 *
4 */ 4 */
5#include <linux/clockchips.h> 5#include <linux/clockchips.h>
6#include <linux/spinlock.h> 6#include <linux/init.h>
7#include <linux/interrupt.h>
7#include <linux/jiffies.h> 8#include <linux/jiffies.h>
8#include <linux/sysdev.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/init.h> 10#include <linux/spinlock.h>
11 11
12#include <asm/smp.h> 12#include <asm/smp.h>
13#include <asm/delay.h> 13#include <asm/delay.h>
@@ -41,26 +41,24 @@ static void init_pit_timer(enum clock_event_mode mode,
41 case CLOCK_EVT_MODE_PERIODIC: 41 case CLOCK_EVT_MODE_PERIODIC:
42 /* binary, mode 2, LSB/MSB, ch 0 */ 42 /* binary, mode 2, LSB/MSB, ch 0 */
43 outb_p(0x34, PIT_MODE); 43 outb_p(0x34, PIT_MODE);
44 udelay(10);
45 outb_p(LATCH & 0xff , PIT_CH0); /* LSB */ 44 outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
46 udelay(10);
47 outb(LATCH >> 8 , PIT_CH0); /* MSB */ 45 outb(LATCH >> 8 , PIT_CH0); /* MSB */
48 break; 46 break;
49 47
50 /*
51 * Avoid unnecessary state transitions, as it confuses
52 * Geode / Cyrix based boxen.
53 */
54 case CLOCK_EVT_MODE_SHUTDOWN: 48 case CLOCK_EVT_MODE_SHUTDOWN:
55 if (evt->mode == CLOCK_EVT_MODE_UNUSED)
56 break;
57 case CLOCK_EVT_MODE_UNUSED: 49 case CLOCK_EVT_MODE_UNUSED:
58 if (evt->mode == CLOCK_EVT_MODE_SHUTDOWN) 50 outb_p(0x30, PIT_MODE);
59 break; 51 outb_p(0, PIT_CH0); /* LSB */
52 outb_p(0, PIT_CH0); /* MSB */
53 break;
54
60 case CLOCK_EVT_MODE_ONESHOT: 55 case CLOCK_EVT_MODE_ONESHOT:
61 /* One shot setup */ 56 /* One shot setup */
62 outb_p(0x38, PIT_MODE); 57 outb_p(0x38, PIT_MODE);
63 udelay(10); 58 break;
59
60 case CLOCK_EVT_MODE_RESUME:
61 /* Nothing to do here */
64 break; 62 break;
65 } 63 }
66 spin_unlock_irqrestore(&i8253_lock, flags); 64 spin_unlock_irqrestore(&i8253_lock, flags);
diff --git a/arch/i386/kernel/vmiclock.c b/arch/i386/kernel/vmiclock.c
index f9b845f4e692..d23077cca45b 100644
--- a/arch/i386/kernel/vmiclock.c
+++ b/arch/i386/kernel/vmiclock.c
@@ -142,6 +142,7 @@ static void vmi_timer_set_mode(enum clock_event_mode mode,
142 142
143 switch (mode) { 143 switch (mode) {
144 case CLOCK_EVT_MODE_ONESHOT: 144 case CLOCK_EVT_MODE_ONESHOT:
145 case CLOCK_EVT_MODE_RESUME:
145 break; 146 break;
146 case CLOCK_EVT_MODE_PERIODIC: 147 case CLOCK_EVT_MODE_PERIODIC:
147 cycles_per_hz = vmi_timer_ops.get_cycle_frequency(); 148 cycles_per_hz = vmi_timer_ops.get_cycle_frequency();
diff --git a/arch/i386/xen/time.c b/arch/i386/xen/time.c
index 51fdabf1fd4d..dfd6db69ead5 100644
--- a/arch/i386/xen/time.c
+++ b/arch/i386/xen/time.c
@@ -412,6 +412,7 @@ static void xen_timerop_set_mode(enum clock_event_mode mode,
412 break; 412 break;
413 413
414 case CLOCK_EVT_MODE_ONESHOT: 414 case CLOCK_EVT_MODE_ONESHOT:
415 case CLOCK_EVT_MODE_RESUME:
415 break; 416 break;
416 417
417 case CLOCK_EVT_MODE_UNUSED: 418 case CLOCK_EVT_MODE_UNUSED:
@@ -474,6 +475,8 @@ static void xen_vcpuop_set_mode(enum clock_event_mode mode,
474 HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL)) 475 HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
475 BUG(); 476 BUG();
476 break; 477 break;
478 case CLOCK_EVT_MODE_RESUME:
479 break;
477 } 480 }
478} 481}
479 482