* [patch-mm 00/33] x86_64 clock events conversion - V5
@ 2007-07-15 16:10 Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 01/33] clockevents: Remove unused inline function Thomas Gleixner
` (32 more replies)
0 siblings, 33 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen
This is a replacement patch series for the patches in -mm.
Functional changes since last version:
- hpet legacy problem solved
- apic calibration reverted to original x8664 code
Otherwise the code is the same as before, but the patches got split up
further. Linus, thanks for the hints.
The series is fully bisectable and hopefully easier to review now.
tglx
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 01/33] clockevents: Remove unused inline function
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-17 12:33 ` Andi Kleen
2007-07-15 16:10 ` [patch-mm 02/33] clockevents: Allow build w/o run-tine usage for migration purposes Thomas Gleixner
` (31 subsequent siblings)
32 siblings, 1 reply; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen
[-- Attachment #1: clockevents-remove-unused-inline-function.patch --]
[-- Type: text/plain, Size: 722 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/linux/clockchips.h | 1 -
1 file changed, 1 deletion(-)
Index: linux-2.6.22-rc6-mm/include/linux/clockchips.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/linux/clockchips.h 2007-07-15 09:44:00.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/linux/clockchips.h 2007-07-15 17:49:11.000000000 +0200
@@ -131,7 +131,6 @@ extern void clockevents_notify(unsigned
#else
-static inline void clockevents_resume_events(void) { }
#define clockevents_notify(reason, arg) do { } while (0)
#endif
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 02/33] clockevents: Allow build w/o run-tine usage for migration purposes
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 01/33] clockevents: Remove unused inline function Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 03/33] i386: remove pit_interrupt_hook Thomas Gleixner
` (30 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen
[-- Attachment #1: clockevents-allow-build-without-runtime-use.patch --]
[-- Type: text/plain, Size: 3278 bytes --]
Migration aid to allow preparatory patches which introduce not yet
used parts of clock events code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/linux/clockchips.h | 8 ++++++--
kernel/time/Kconfig | 5 +++++
kernel/time/Makefile | 2 +-
kernel/time/clockevents.c | 3 ++-
4 files changed, 14 insertions(+), 4 deletions(-)
Index: linux-2.6.22-rc6-mm/kernel/time/Kconfig
===================================================================
--- linux-2.6.22-rc6-mm.orig/kernel/time/Kconfig 2007-07-15 09:43:59.000000000 +0200
+++ linux-2.6.22-rc6-mm/kernel/time/Kconfig 2007-07-15 09:44:08.000000000 +0200
@@ -23,3 +23,8 @@ config HIGH_RES_TIMERS
hardware is not capable then this option only increases
the size of the kernel image.
+config GENERIC_CLOCKEVENTS_BUILD
+ bool
+ default y
+ depends on GENERIC_CLOCKEVENTS || GENERIC_CLOCKEVENTS_MIGR
+
Index: linux-2.6.22-rc6-mm/kernel/time/Makefile
===================================================================
--- linux-2.6.22-rc6-mm.orig/kernel/time/Makefile 2007-07-15 09:43:59.000000000 +0200
+++ linux-2.6.22-rc6-mm/kernel/time/Makefile 2007-07-15 09:44:08.000000000 +0200
@@ -1,6 +1,6 @@
obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o
-obj-$(CONFIG_GENERIC_CLOCKEVENTS) += clockevents.o
+obj-$(CONFIG_GENERIC_CLOCKEVENTS_BUILD) += clockevents.o
obj-$(CONFIG_GENERIC_CLOCKEVENTS) += tick-common.o
obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += tick-broadcast.o
obj-$(CONFIG_TICK_ONESHOT) += tick-oneshot.o
Index: linux-2.6.22-rc6-mm/include/linux/clockchips.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/linux/clockchips.h 2007-07-15 09:44:07.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/linux/clockchips.h 2007-07-15 09:44:08.000000000 +0200
@@ -8,7 +8,7 @@
#ifndef _LINUX_CLOCKCHIPS_H
#define _LINUX_CLOCKCHIPS_H
-#ifdef CONFIG_GENERIC_CLOCKEVENTS
+#ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD
#include <linux/clocksource.h>
#include <linux/cpumask.h>
@@ -127,9 +127,13 @@ extern void clockevents_unregister_notif
extern int clockevents_program_event(struct clock_event_device *dev,
ktime_t expires, ktime_t now);
+#ifdef CONFIG_GENERIC_CLOCKEVENTS
extern void clockevents_notify(unsigned long reason, void *arg);
-
#else
+# define clockevents_notify(reason, arg) do { } while (0)
+#endif
+
+#else /* CONFIG_GENERIC_CLOCKEVENTS_BUILD */
#define clockevents_notify(reason, arg) do { } while (0)
Index: linux-2.6.22-rc6-mm/kernel/time/clockevents.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/kernel/time/clockevents.c 2007-07-15 09:43:59.000000000 +0200
+++ linux-2.6.22-rc6-mm/kernel/time/clockevents.c 2007-07-15 16:30:12.000000000 +0200
@@ -245,6 +245,7 @@ void clockevents_release_device(struct c
spin_unlock(&clockevents_lock);
}
+#ifdef CONFIG_GENERIC_CLOCKEVENTS
/**
* clockevents_notify - notification about relevant events
*/
@@ -273,4 +274,4 @@ void clockevents_notify(unsigned long re
spin_unlock(&clockevents_lock);
}
EXPORT_SYMBOL_GPL(clockevents_notify);
-
+#endif
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 03/33] i386: remove pit_interrupt_hook
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 01/33] clockevents: Remove unused inline function Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 02/33] clockevents: Allow build w/o run-tine usage for migration purposes Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 04/33] X86_64: hpet tsc calibration fix broken smi detection logic Thomas Gleixner
` (29 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: i386-remove-pit-interrupt-hook.patch --]
[-- Type: text/plain, Size: 2237 bytes --]
From: Chris Wright <chrisw@sous-sol.org>
Remove pit_interrupt_hook as it adds just an extra layer.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/asm-i386/i8253.h | 11 -----------
include/asm-i386/mach-default/do_timer.h | 2 +-
include/asm-i386/mach-voyager/do_timer.h | 2 +-
3 files changed, 2 insertions(+), 13 deletions(-)
Index: linux-2.6.22-rc6-mm/include/asm-i386/i8253.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/i8253.h 2007-07-15 09:37:52.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/i8253.h 2007-07-15 17:49:01.000000000 +0200
@@ -12,17 +12,6 @@ extern spinlock_t i8253_lock;
extern struct clock_event_device *global_clock_event;
-/**
- * pit_interrupt_hook - hook into timer tick
- * @regs: standard registers from interrupt
- *
- * Call the global clock event handler.
- **/
-static inline void pit_interrupt_hook(void)
-{
- global_clock_event->event_handler(global_clock_event);
-}
-
extern void setup_pit_timer(void);
#endif /* __ASM_I8253_H__ */
Index: linux-2.6.22-rc6-mm/include/asm-i386/mach-default/do_timer.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/mach-default/do_timer.h 2007-04-26 05:08:32.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/mach-default/do_timer.h 2007-07-15 09:44:10.000000000 +0200
@@ -12,5 +12,5 @@
static inline void do_timer_interrupt_hook(void)
{
- pit_interrupt_hook();
+ global_clock_event->event_handler(global_clock_event);
}
Index: linux-2.6.22-rc6-mm/include/asm-i386/mach-voyager/do_timer.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/mach-voyager/do_timer.h 2007-04-26 05:08:32.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/mach-voyager/do_timer.h 2007-07-15 09:44:10.000000000 +0200
@@ -12,7 +12,7 @@
**/
static inline void do_timer_interrupt_hook(void)
{
- pit_interrupt_hook();
+ global_clock_event->event_handler(global_clock_event);
voyager_timer_interrupt();
}
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 04/33] X86_64: hpet tsc calibration fix broken smi detection logic
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (2 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 03/33] i386: remove pit_interrupt_hook Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 05/33] x86_64: Untangle asm/hpet.h from asm/timex.h Thomas Gleixner
` (28 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-hpet-tsc-calibration-fix-broken-smi-detection-logic.patch --]
[-- Type: text/plain, Size: 1380 bytes --]
The current SMI detection logic in read_hpet_tsc() makes sure,
that when a SMI happens between the read of the HPET counter and
the read of the TSC, this wrong value is used for TSC calibration.
This is not the intention of the function. The comparison must ensure,
that we do _NOT_ use such a value.
Fix the check to use calibration values where delta of the two TSC reads
is smaller than a reasonable threshold.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/hpet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/hpet.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/hpet.c 2007-07-15 17:26:54.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/hpet.c 2007-07-15 17:49:05.000000000 +0200
@@ -190,7 +190,7 @@ int hpet_reenable(void)
*/
#define TICK_COUNT 100000000
-#define TICK_MIN 5000
+#define SMI_THRESHOLD 50000
#define MAX_TRIES 5
/*
@@ -205,7 +205,7 @@ static void __init read_hpet_tsc(int *hp
tsc1 = get_cycles_sync();
hpet1 = hpet_readl(HPET_COUNTER);
tsc2 = get_cycles_sync();
- if (tsc2 - tsc1 > TICK_MIN)
+ if ((tsc2 - tsc1) < SMI_THRESHOLD)
break;
}
*hpet = hpet1;
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 05/33] x86_64: Untangle asm/hpet.h from asm/timex.h
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (3 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 04/33] X86_64: hpet tsc calibration fix broken smi detection logic Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 06/33] x86_64: use generic cmos update Thomas Gleixner
` (27 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright, john stultz
[-- Attachment #1: x86_64-untangle-asm-hpeth-from-asm-timexh.patch --]
[-- Type: text/plain, Size: 2730 bytes --]
From: Chris Wright <chrisw@sous-sol.org>
When making changes to x86_64 timers, I noticed that touching hpet.h triggered
an unreasonably large rebuild. Untangling it from timex.h quiets the extra
rebuild quite a bit.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: john stultz <johnstul@us.ibm.com>
---
drivers/char/rtc.c | 2 +-
include/asm-x86_64/apic.h | 2 ++
include/asm-x86_64/hpet.h | 1 -
include/asm-x86_64/timex.h | 1 -
4 files changed, 3 insertions(+), 3 deletions(-)
Index: linux-2.6.22-rc6-mm/drivers/char/rtc.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/drivers/char/rtc.c 2007-07-15 17:26:53.000000000 +0200
+++ linux-2.6.22-rc6-mm/drivers/char/rtc.c 2007-07-15 17:29:06.000000000 +0200
@@ -82,7 +82,7 @@
#include <asm/uaccess.h>
#include <asm/system.h>
-#if defined(__i386__)
+#ifdef CONFIG_X86
#include <asm/hpet.h>
#endif
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/apic.h 2007-07-15 17:26:53.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h 2007-07-15 17:49:06.000000000 +0200
@@ -86,6 +86,8 @@ extern void setup_apic_routing(void);
extern void setup_APIC_extened_lvt(unsigned char lvt_off, unsigned char vector,
unsigned char msg_type, unsigned char mask);
+extern int apic_is_clustered_box(void);
+
#define K8_APIC_EXT_LVT_BASE 0x500
#define K8_APIC_EXT_INT_MSG_FIX 0x0
#define K8_APIC_EXT_INT_MSG_SMI 0x2
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/hpet.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/hpet.h 2007-07-15 17:26:53.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/hpet.h 2007-07-15 17:49:05.000000000 +0200
@@ -55,7 +55,6 @@
extern int is_hpet_enabled(void);
extern int hpet_rtc_timer_init(void);
-extern int apic_is_clustered_box(void);
extern int hpet_arch_init(void);
extern int hpet_timer_stop_set_go(unsigned long tick);
extern int hpet_reenable(void);
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/timex.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/timex.h 2007-07-15 17:26:53.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/timex.h 2007-07-15 17:29:06.000000000 +0200
@@ -9,7 +9,6 @@
#include <asm/8253pit.h>
#include <asm/msr.h>
#include <asm/vsyscall.h>
-#include <asm/hpet.h>
#include <asm/system.h>
#include <asm/processor.h>
#include <asm/tsc.h>
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 06/33] x86_64: use generic cmos update
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (4 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 05/33] x86_64: Untangle asm/hpet.h from asm/timex.h Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 07/33] x86_64: Use generic xtime init Thomas Gleixner
` (26 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright, john stultz
[-- Attachment #1: x86_64-use-generic-cmos-update.patch --]
[-- Type: text/plain, Size: 2923 bytes --]
Use the generic cmos update function in kernel/time/ntp.c
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: john stultz <johnstul@us.ibm.com>
---
arch/x86_64/Kconfig | 4 ++++
arch/x86_64/kernel/time.c | 25 +++++++++----------------
2 files changed, 13 insertions(+), 16 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/Kconfig
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/Kconfig 2007-07-15 17:26:51.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/Kconfig 2007-07-15 17:48:54.000000000 +0200
@@ -32,6 +32,10 @@ config GENERIC_TIME_VSYSCALL
bool
default y
+config GENERIC_CMOS_UPDATE
+ bool
+ default y
+
config ZONE_DMA32
bool
default y
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/time.c 2007-07-15 17:26:51.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c 2007-07-15 17:49:08.000000000 +0200
@@ -82,8 +82,9 @@ EXPORT_SYMBOL(profile_pc);
* sheet for details.
*/
-static void set_rtc_mmss(unsigned long nowtime)
+static int set_rtc_mmss(unsigned long nowtime)
{
+ int retval = 0;
int real_seconds, real_minutes, cmos_minutes;
unsigned char control, freq_select;
@@ -123,6 +124,7 @@ static void set_rtc_mmss(unsigned long n
if (abs(real_minutes - cmos_minutes) >= 30) {
printk(KERN_WARNING "time.c: can't update CMOS clock "
"from %d to %d\n", cmos_minutes, real_minutes);
+ retval = -1;
} else {
BIN_TO_BCD(real_seconds);
BIN_TO_BCD(real_minutes);
@@ -142,12 +144,17 @@ static void set_rtc_mmss(unsigned long n
CMOS_WRITE(freq_select, RTC_FREQ_SELECT);
spin_unlock(&rtc_lock);
+
+ return retval;
}
+int update_persistent_clock(struct timespec now)
+{
+ return set_rtc_mmss(now.tv_sec);
+}
void main_timer_handler(void)
{
- static unsigned long rtc_update = 0;
/*
* Here we are in the timer irq handler. We have irqs locally disabled (so we
* don't need spin_lock_irqsave()) but we don't know if the timer_bh is running
@@ -175,20 +182,6 @@ void main_timer_handler(void)
if (!using_apic_timer)
smp_local_timer_interrupt();
-/*
- * If we have an externally synchronized Linux clock, then update CMOS clock
- * accordingly every ~11 minutes. set_rtc_mmss() will be called in the jiffy
- * closest to exactly 500 ms before the next second. If the update fails, we
- * don't care, as it'll be updated on the next turn, and the problem (time way
- * off) isn't likely to go away much sooner anyway.
- */
-
- if (ntp_synced() && xtime.tv_sec > rtc_update &&
- abs(xtime.tv_nsec - 500000000) <= tick_nsec / 2) {
- set_rtc_mmss(xtime.tv_sec);
- rtc_update = xtime.tv_sec + 660;
- }
-
write_sequnlock(&xtime_lock);
}
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 07/33] x86_64: Use generic xtime init
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (5 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 06/33] x86_64: use generic cmos update Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 08/33] x86_64: Remove dead code and other janitor work in tsc.c Thomas Gleixner
` (25 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-use-generic-xtime-init.patch --]
[-- Type: text/plain, Size: 2514 bytes --]
xtime can be initialized including the cmos update from the generic
timekeeping code. Remove the arch specific implementation.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/time.c | 40 +---------------------------------------
1 file changed, 1 insertion(+), 39 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/time.c 2007-07-15 17:30:43.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c 2007-07-15 17:49:03.000000000 +0200
@@ -195,7 +195,7 @@ static irqreturn_t timer_interrupt(int i
return IRQ_HANDLED;
}
-static unsigned long get_cmos_time(void)
+unsigned long read_persistent_clock(void)
{
unsigned int year, mon, day, hour, min, sec;
unsigned long flags;
@@ -369,11 +369,6 @@ void __init time_init(void)
{
if (nohpet)
hpet_address = 0;
- xtime.tv_sec = get_cmos_time();
- xtime.tv_nsec = 0;
-
- set_normalized_timespec(&wall_to_monotonic,
- -xtime.tv_sec, -xtime.tv_nsec);
if (hpet_arch_init())
hpet_address = 0;
@@ -410,54 +405,21 @@ void __init time_init(void)
setup_irq(0, &irq0);
}
-
-static long clock_cmos_diff;
-static unsigned long sleep_start;
-
/*
* sysfs support for the timer.
*/
static int timer_suspend(struct sys_device *dev, pm_message_t state)
{
- /*
- * Estimate time zone so that set_time can update the clock
- */
- long cmos_time = get_cmos_time();
-
- clock_cmos_diff = -cmos_time;
- clock_cmos_diff += get_seconds();
- sleep_start = cmos_time;
return 0;
}
static int timer_resume(struct sys_device *dev)
{
- unsigned long flags;
- unsigned long sec;
- unsigned long ctime = get_cmos_time();
- long sleep_length = (ctime - sleep_start) * HZ;
-
- if (sleep_length < 0) {
- printk(KERN_WARNING "Time skew detected in timer resume!\n");
- /* The time after the resume must not be earlier than the time
- * before the suspend or some nasty things will happen
- */
- sleep_length = 0;
- ctime = sleep_start;
- }
if (hpet_address)
hpet_reenable();
else
i8254_timer_resume();
-
- sec = ctime + clock_cmos_diff;
- write_seqlock_irqsave(&xtime_lock,flags);
- xtime.tv_sec = sec;
- xtime.tv_nsec = 0;
- jiffies += sleep_length;
- write_sequnlock_irqrestore(&xtime_lock,flags);
- touch_softlockup_watchdog();
return 0;
}
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 08/33] x86_64: Remove dead code and other janitor work in tsc.c
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (6 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 07/33] x86_64: Use generic xtime init Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 09/33] x86_64: Fix APIC typo Thomas Gleixner
` (24 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright, john stultz
[-- Attachment #1: x86_64-remove-dead-code-and-other-janitor-work-in-tscc.patch --]
[-- Type: text/plain, Size: 2881 bytes --]
Remove unused code and variables and do some codingstyle / whitespace
cleanups while at it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: john stultz <johnstul@us.ibm.com>
---
arch/x86_64/kernel/tsc.c | 41 +++++++++++------------------------------
1 file changed, 11 insertions(+), 30 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/tsc.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/tsc.c 2007-07-15 17:26:50.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/tsc.c 2007-07-15 17:49:03.000000000 +0200
@@ -35,25 +35,9 @@ static inline int check_tsc_unstable(voi
* first tick after the change will be slightly wrong.
*/
-#include <linux/workqueue.h>
-
-static unsigned int cpufreq_delayed_issched = 0;
-static unsigned int cpufreq_init = 0;
-static struct work_struct cpufreq_delayed_get_work;
-
-static void handle_cpufreq_delayed_get(struct work_struct *v)
-{
- unsigned int cpu;
- for_each_online_cpu(cpu) {
- cpufreq_get(cpu);
- }
- cpufreq_delayed_issched = 0;
-}
-
-static unsigned int ref_freq = 0;
-static unsigned long loops_per_jiffy_ref = 0;
-
-static unsigned long tsc_khz_ref = 0;
+static unsigned int ref_freq;
+static unsigned long loops_per_jiffy_ref;
+static unsigned long tsc_khz_ref;
static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
void *data)
@@ -97,10 +81,8 @@ static struct notifier_block time_cpufre
static int __init cpufreq_tsc(void)
{
- INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get);
- if (!cpufreq_register_notifier(&time_cpufreq_notifier_block,
- CPUFREQ_TRANSITION_NOTIFIER))
- cpufreq_init = 1;
+ cpufreq_register_notifier(&time_cpufreq_notifier_block,
+ CPUFREQ_TRANSITION_NOTIFIER);
return 0;
}
@@ -108,8 +90,6 @@ core_initcall(cpufreq_tsc);
#endif
-static int tsc_unstable = 0;
-
/*
* Make an educated guess if the TSC is trustworthy and synchronized
* over all CPUs.
@@ -122,17 +102,18 @@ __cpuinit int unsynchronized_tsc(void)
#endif
/* Most intel systems have synchronized TSCs except for
multi node systems */
- if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
#ifdef CONFIG_ACPI
/* But TSC doesn't tick in C3 so don't use it there */
- if (acpi_gbl_FADT.header.length > 0 && acpi_gbl_FADT.C3latency < 1000)
+ if (acpi_gbl_FADT.header.length > 0 &&
+ acpi_gbl_FADT.C3latency < 1000)
return 1;
#endif
- return 0;
+ return 0;
}
- /* Assume multi socket systems are not synchronized */
- return num_present_cpus() > 1;
+ /* Assume multi socket systems are not synchronized */
+ return num_present_cpus() > 1;
}
int __init notsc_setup(char *s)
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 09/33] x86_64: Fix APIC typo
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (7 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 08/33] x86_64: Remove dead code and other janitor work in tsc.c Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 10/33] x86_64: fiuxp pt_reqs leftovers Thomas Gleixner
` (23 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-fix-apic-typo.patch --]
[-- Type: text/plain, Size: 2662 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 4 ++--
arch/x86_64/kernel/mce_amd.c | 6 +++---
include/asm-x86_64/apic.h | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:26:49.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:49:04.000000000 +0200
@@ -990,8 +990,8 @@ int setup_profiling_timer(unsigned int m
return -EINVAL;
}
-void setup_APIC_extened_lvt(unsigned char lvt_off, unsigned char vector,
- unsigned char msg_type, unsigned char mask)
+void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector,
+ unsigned char msg_type, unsigned char mask)
{
unsigned long reg = (lvt_off << 4) + K8_APIC_EXT_LVT_BASE;
unsigned int v = (mask << 16) | (msg_type << 8) | vector;
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/mce_amd.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/mce_amd.c 2007-07-15 17:26:49.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/mce_amd.c 2007-07-15 17:31:31.000000000 +0200
@@ -157,9 +157,9 @@ void __cpuinit mce_amd_feature_init(stru
high |= K8_APIC_EXT_LVT_ENTRY_THRESHOLD << 20;
wrmsr(address, low, high);
- setup_APIC_extened_lvt(K8_APIC_EXT_LVT_ENTRY_THRESHOLD,
- THRESHOLD_APIC_VECTOR,
- K8_APIC_EXT_INT_MSG_FIX, 0);
+ setup_APIC_extended_lvt(K8_APIC_EXT_LVT_ENTRY_THRESHOLD,
+ THRESHOLD_APIC_VECTOR,
+ K8_APIC_EXT_INT_MSG_FIX, 0);
threshold_defaults.address = address;
threshold_restart_bank(&threshold_defaults, 0, 0);
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/apic.h 2007-07-15 17:29:06.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h 2007-07-15 17:48:53.000000000 +0200
@@ -83,8 +83,8 @@ extern void disable_APIC_timer(void);
extern void enable_APIC_timer(void);
extern void setup_apic_routing(void);
-extern void setup_APIC_extened_lvt(unsigned char lvt_off, unsigned char vector,
- unsigned char msg_type, unsigned char mask);
+extern void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector,
+ unsigned char msg_type, unsigned char mask);
extern int apic_is_clustered_box(void);
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 10/33] x86_64: fiuxp pt_reqs leftovers
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (8 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 09/33] x86_64: Fix APIC typo Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 11/33] x86_64: share hpet.h with i386 Thomas Gleixner
` (22 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-fix-irq-regs-leftovers.patch --]
[-- Type: text/plain, Size: 865 bytes --]
The hpet_rtc_interrupt handler still uses pt_regs. Fix it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/hpet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/hpet.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/hpet.c 2007-07-15 17:27:01.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/hpet.c 2007-07-15 17:49:03.000000000 +0200
@@ -439,7 +439,7 @@ int hpet_rtc_dropped_irq(void)
return 1;
}
-irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
{
struct rtc_time curr_time;
unsigned long rtc_int_flag = 0;
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 11/33] x86_64: share hpet.h with i386
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (9 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 10/33] x86_64: fiuxp pt_reqs leftovers Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 12/33] x86_64: apic.c coding style janitor work Thomas Gleixner
` (21 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-share-hpet-h.patch --]
[-- Type: text/plain, Size: 8118 bytes --]
hpet.h in asm-i386 and asm-x86_64 contain tons of duplicated stuff.
Consolidate into one shared header file.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/asm-i386/hpet.h | 124 +++++++++++++++++-----------------------------
include/asm-x86_64/hpet.h | 61 ----------------------
2 files changed, 48 insertions(+), 137 deletions(-)
Index: linux-2.6.22-rc6-mm/include/asm-i386/hpet.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/hpet.h 2007-07-15 17:26:45.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/hpet.h 2007-07-15 17:48:49.000000000 +0200
@@ -4,112 +4,82 @@
#ifdef CONFIG_HPET_TIMER
-#include <linux/errno.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/param.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/time.h>
-#include <linux/delay.h>
-#include <linux/init.h>
-#include <linux/smp.h>
-
-#include <asm/io.h>
-#include <asm/smp.h>
-#include <asm/irq.h>
-#include <asm/msr.h>
-#include <asm/delay.h>
-#include <asm/mpspec.h>
-#include <asm/uaccess.h>
-#include <asm/processor.h>
-
-#include <linux/timex.h>
-
/*
* Documentation on HPET can be found at:
* http://www.intel.com/ial/home/sp/pcmmspec.htm
* ftp://download.intel.com/ial/home/sp/mmts098.pdf
*/
-#define HPET_MMAP_SIZE 1024
+#define HPET_MMAP_SIZE 1024
-#define HPET_ID 0x000
-#define HPET_PERIOD 0x004
-#define HPET_CFG 0x010
-#define HPET_STATUS 0x020
-#define HPET_COUNTER 0x0f0
-#define HPET_T0_CFG 0x100
-#define HPET_T0_CMP 0x108
-#define HPET_T0_ROUTE 0x110
-#define HPET_T1_CFG 0x120
-#define HPET_T1_CMP 0x128
-#define HPET_T1_ROUTE 0x130
-#define HPET_T2_CFG 0x140
-#define HPET_T2_CMP 0x148
-#define HPET_T2_ROUTE 0x150
-
-#define HPET_ID_LEGSUP 0x00008000
-#define HPET_ID_NUMBER 0x00001f00
-#define HPET_ID_REV 0x000000ff
+#define HPET_ID 0x000
+#define HPET_PERIOD 0x004
+#define HPET_CFG 0x010
+#define HPET_STATUS 0x020
+#define HPET_COUNTER 0x0f0
+#define HPET_T0_CFG 0x100
+#define HPET_T0_CMP 0x108
+#define HPET_T0_ROUTE 0x110
+#define HPET_T1_CFG 0x120
+#define HPET_T1_CMP 0x128
+#define HPET_T1_ROUTE 0x130
+#define HPET_T2_CFG 0x140
+#define HPET_T2_CMP 0x148
+#define HPET_T2_ROUTE 0x150
+
+#define HPET_ID_REV 0x000000ff
+#define HPET_ID_NUMBER 0x00001f00
+#define HPET_ID_64BIT 0x00002000
+#define HPET_ID_LEGSUP 0x00008000
+#define HPET_ID_VENDOR 0xffff0000
#define HPET_ID_NUMBER_SHIFT 8
+#define HPET_ID_VENDOR_SHIFT 16
-#define HPET_CFG_ENABLE 0x001
-#define HPET_CFG_LEGACY 0x002
+#define HPET_ID_VENDOR_8086 0x8086
+
+#define HPET_CFG_ENABLE 0x001
+#define HPET_CFG_LEGACY 0x002
#define HPET_LEGACY_8254 2
#define HPET_LEGACY_RTC 8
-#define HPET_TN_ENABLE 0x004
-#define HPET_TN_PERIODIC 0x008
-#define HPET_TN_PERIODIC_CAP 0x010
-#define HPET_TN_SETVAL 0x040
-#define HPET_TN_32BIT 0x100
-
-/* Use our own asm for 64 bit multiply/divide */
-#define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in) \
- __asm__ __volatile__("mull %2" \
- :"=a" (eax_out), "=d" (edx_out) \
- :"r" (reg_in), "0" (eax_in))
-
-#define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in) \
- __asm__ __volatile__("divl %2" \
- :"=a" (eax_out), "=d" (edx_out) \
- :"r" (reg_in), "0" (eax_in), "1" (edx_in))
+#define HPET_TN_LEVEL 0x0002
+#define HPET_TN_ENABLE 0x0004
+#define HPET_TN_PERIODIC 0x0008
+#define HPET_TN_PERIODIC_CAP 0x0010
+#define HPET_TN_64BIT_CAP 0x0020
+#define HPET_TN_SETVAL 0x0040
+#define HPET_TN_32BIT 0x0100
+#define HPET_TN_ROUTE 0x3e00
+#define HPET_TN_FSB 0x4000
+#define HPET_TN_FSB_CAP 0x8000
+#define HPET_TN_ROUTE_SHIFT 9
-#define KERNEL_TICK_USEC (1000000UL/HZ) /* tick value in microsec */
/* Max HPET Period is 10^8 femto sec as in HPET spec */
-#define HPET_MAX_PERIOD (100000000UL)
+#define HPET_MAX_PERIOD 100000000UL
/*
* Min HPET period is 10^5 femto sec just for safety. If it is less than this,
* then 32 bit HPET counter wrapsaround in less than 0.5 sec.
*/
-#define HPET_MIN_PERIOD (100000UL)
-#define HPET_TICK_RATE (HZ * 100000UL)
+#define HPET_MIN_PERIOD 100000UL
-extern unsigned long hpet_address; /* hpet memory map physical address */
+/* hpet memory map physical address */
+extern unsigned long hpet_address;
extern int is_hpet_enabled(void);
-
-#ifdef CONFIG_X86_64
-extern unsigned long hpet_tick; /* hpet clks count per tick */
-extern int hpet_use_timer;
-extern int hpet_rtc_timer_init(void);
extern int hpet_enable(void);
-extern int is_hpet_capable(void);
-extern int hpet_readl(unsigned long a);
-#else
-extern int hpet_enable(void);
-#endif
#ifdef CONFIG_HPET_EMULATE_RTC
+
+#include <linux/interrupt.h>
+
extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
-extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec);
+extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min,
+ unsigned char sec);
extern int hpet_set_periodic_freq(unsigned long freq);
extern int hpet_rtc_dropped_irq(void);
extern int hpet_rtc_timer_init(void);
extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
+
#endif /* CONFIG_HPET_EMULATE_RTC */
#else
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/hpet.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/hpet.h 2007-07-15 17:29:06.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/hpet.h 2007-07-15 17:48:54.000000000 +0200
@@ -1,59 +1,10 @@
#ifndef _ASM_X8664_HPET_H
#define _ASM_X8664_HPET_H 1
-/*
- * Documentation on HPET can be found at:
- * http://www.intel.com/ial/home/sp/pcmmspec.htm
- * ftp://download.intel.com/ial/home/sp/mmts098.pdf
- */
-
-#define HPET_MMAP_SIZE 1024
-
-#define HPET_ID 0x000
-#define HPET_PERIOD 0x004
-#define HPET_CFG 0x010
-#define HPET_STATUS 0x020
-#define HPET_COUNTER 0x0f0
-#define HPET_Tn_OFFSET 0x20
-#define HPET_Tn_CFG(n) (0x100 + (n) * HPET_Tn_OFFSET)
-#define HPET_Tn_ROUTE(n) (0x104 + (n) * HPET_Tn_OFFSET)
-#define HPET_Tn_CMP(n) (0x108 + (n) * HPET_Tn_OFFSET)
-#define HPET_T0_CFG HPET_Tn_CFG(0)
-#define HPET_T0_CMP HPET_Tn_CMP(0)
-#define HPET_T1_CFG HPET_Tn_CFG(1)
-#define HPET_T1_CMP HPET_Tn_CMP(1)
-
-#define HPET_ID_VENDOR 0xffff0000
-#define HPET_ID_LEGSUP 0x00008000
-#define HPET_ID_64BIT 0x00002000
-#define HPET_ID_NUMBER 0x00001f00
-#define HPET_ID_REV 0x000000ff
-#define HPET_ID_NUMBER_SHIFT 8
-
-#define HPET_ID_VENDOR_SHIFT 16
-#define HPET_ID_VENDOR_8086 0x8086
-
-#define HPET_CFG_ENABLE 0x001
-#define HPET_CFG_LEGACY 0x002
-#define HPET_LEGACY_8254 2
-#define HPET_LEGACY_RTC 8
-
-#define HPET_TN_LEVEL 0x0002
-#define HPET_TN_ENABLE 0x0004
-#define HPET_TN_PERIODIC 0x0008
-#define HPET_TN_PERIODIC_CAP 0x0010
-#define HPET_TN_64BIT_CAP 0x0020
-#define HPET_TN_SETVAL 0x0040
-#define HPET_TN_32BIT 0x0100
-#define HPET_TN_ROUTE 0x3e00
-#define HPET_TN_FSB 0x4000
-#define HPET_TN_FSB_CAP 0x8000
-
-#define HPET_TN_ROUTE_SHIFT 9
+#include <asm-i386/hpet.h>
#define HPET_TICK_RATE (HZ * 100000UL)
-extern int is_hpet_enabled(void);
extern int hpet_rtc_timer_init(void);
extern int hpet_arch_init(void);
extern int hpet_timer_stop_set_go(unsigned long tick);
@@ -61,17 +12,7 @@ extern int hpet_reenable(void);
extern unsigned int hpet_calibrate_tsc(void);
extern int hpet_use_timer;
-extern unsigned long hpet_address;
extern unsigned long hpet_period;
extern unsigned long hpet_tick;
-#ifdef CONFIG_HPET_EMULATE_RTC
-extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
-extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
-extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec);
-extern int hpet_set_periodic_freq(unsigned long freq);
-extern int hpet_rtc_dropped_irq(void);
-extern int hpet_rtc_timer_init(void);
-#endif /* CONFIG_HPET_EMULATE_RTC */
-
#endif
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 12/33] x86_64: apic.c coding style janitor work
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (10 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 11/33] x86_64: share hpet.h with i386 Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 13/33] x86_64: time.c white space wreckage cleanup Thomas Gleixner
` (20 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-apic-whitespace-comment-and-remove-unused-code.patch --]
[-- Type: text/plain, Size: 5188 bytes --]
Fix coding style, white space wreckage and remove unused code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 73 ++++++++++++++++++----------------------------
1 file changed, 30 insertions(+), 43 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:31:31.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:59.000000000 +0200
@@ -92,8 +92,9 @@ unsigned int safe_apic_wait_icr_idle(voi
void enable_NMI_through_LVT0 (void * dummy)
{
unsigned int v;
-
- v = APIC_DM_NMI; /* unmask and set to NMI */
+
+ /* unmask and set to NMI */
+ v = APIC_DM_NMI;
apic_write(APIC_LVT0, v);
}
@@ -120,7 +121,7 @@ void ack_bad_irq(unsigned int irq)
* holds up an irq slot - in excessive cases (when multiple
* unexpected vectors occur) that might lock up the APIC
* completely.
- * But don't ack when the APIC is disabled. -AK
+ * But don't ack when the APIC is disabled. -AK
*/
if (!disable_apic)
ack_APIC_irq();
@@ -616,7 +617,7 @@ early_param("apic", apic_set_verbosity);
* Detect and enable local APICs on non-SMP boards.
* Original code written by Keir Fraser.
* On AMD64 we trust the BIOS - if it says no APIC it is likely
- * not correctly set up (usually the APIC timer won't work etc.)
+ * not correctly set up (usually the APIC timer won't work etc.)
*/
static int __init detect_init_APIC (void)
@@ -789,13 +790,13 @@ static void setup_APIC_timer(unsigned in
local_irq_save(flags);
/* wait for irq slice */
- if (hpet_address && hpet_use_timer) {
- int trigger = hpet_readl(HPET_T0_CMP);
- while (hpet_readl(HPET_COUNTER) >= trigger)
- /* do nothing */ ;
- while (hpet_readl(HPET_COUNTER) < trigger)
- /* do nothing */ ;
- } else {
+ if (hpet_address && hpet_use_timer) {
+ int trigger = hpet_readl(HPET_T0_CMP);
+ while (hpet_readl(HPET_COUNTER) >= trigger)
+ /* do nothing */ ;
+ while (hpet_readl(HPET_COUNTER) < trigger)
+ /* do nothing */ ;
+ } else {
int c1, c2;
outb_p(0x00, 0x43);
c2 = inb_p(0x40);
@@ -881,10 +882,10 @@ static unsigned int calibration_result;
void __init setup_boot_APIC_clock (void)
{
- if (disable_apic_timer) {
- printk(KERN_INFO "Disabling APIC timer\n");
- return;
- }
+ if (disable_apic_timer) {
+ printk(KERN_INFO "Disabling APIC timer\n");
+ return;
+ }
printk(KERN_INFO "Using local APIC timer interrupts.\n");
using_apic_timer = 1;
@@ -1128,20 +1129,6 @@ asmlinkage void smp_spurious_interrupt(v
if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
ack_APIC_irq();
-#if 0
- static unsigned long last_warning;
- static unsigned long skipped;
-
- /* see sw-dev-man vol 3, chapter 7.4.13.5 */
- if (time_before(last_warning+30*HZ,jiffies)) {
- printk(KERN_INFO "spurious APIC interrupt on CPU#%d, %ld skipped.\n",
- smp_processor_id(), skipped);
- last_warning = jiffies;
- skipped = 0;
- } else {
- skipped++;
- }
-#endif
irq_exit();
}
@@ -1173,11 +1160,11 @@ asmlinkage void smp_error_interrupt(void
7: Illegal register address
*/
printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n",
- smp_processor_id(), v , v1);
+ smp_processor_id(), v , v1);
irq_exit();
}
-int disable_apic;
+int disable_apic;
/*
* This initializes the IO-APIC and APIC hardware if this is
@@ -1185,11 +1172,11 @@ int disable_apic;
*/
int __init APIC_init_uniprocessor (void)
{
- if (disable_apic) {
+ if (disable_apic) {
printk(KERN_INFO "Apic disabled\n");
- return -1;
+ return -1;
}
- if (!cpu_has_apic) {
+ if (!cpu_has_apic) {
disable_apic = 1;
printk(KERN_INFO "Apic disabled by BIOS\n");
return -1;
@@ -1211,8 +1198,8 @@ int __init APIC_init_uniprocessor (void)
return 0;
}
-static __init int setup_disableapic(char *str)
-{
+static __init int setup_disableapic(char *str)
+{
disable_apic = 1;
clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
return 0;
@@ -1220,10 +1207,10 @@ static __init int setup_disableapic(char
early_param("disableapic", setup_disableapic);
/* same as disableapic, for compatibility */
-static __init int setup_nolapic(char *str)
-{
+static __init int setup_nolapic(char *str)
+{
return setup_disableapic(str);
-}
+}
early_param("nolapic", setup_nolapic);
static int __init parse_lapic_timer_c2_ok(char *arg)
@@ -1233,13 +1220,13 @@ static int __init parse_lapic_timer_c2_o
}
early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok);
-static __init int setup_noapictimer(char *str)
-{
+static __init int setup_noapictimer(char *str)
+{
if (str[0] != ' ' && str[0] != 0)
return 0;
disable_apic_timer = 1;
return 1;
-}
+}
static __init int setup_apicmaintimer(char *str)
{
@@ -1264,5 +1251,5 @@ static __init int setup_apicpmtimer(char
}
__setup("apicpmtimer", setup_apicpmtimer);
-__setup("noapictimer", setup_noapictimer);
+__setup("noapictimer", setup_noapictimer);
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 13/33] x86_64: time.c white space wreckage cleanup
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (11 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 12/33] x86_64: apic.c coding style janitor work Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 14/33] x86_64: Consolidate tsc calibration Thomas Gleixner
` (19 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-timec-fix-whitespace-wreckage.patch --]
[-- Type: text/plain, Size: 4473 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/time.c | 88 +++++++++++++++++++++++-----------------------
1 file changed, 44 insertions(+), 44 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/time.c 2007-07-15 17:30:59.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c 2007-07-15 17:49:03.000000000 +0200
@@ -222,7 +222,7 @@ unsigned long read_persistent_clock(void
/*
* We know that x86-64 always uses BCD format, no need to check the
* config register.
- */
+ */
BCD_TO_BIN(sec);
BCD_TO_BIN(min);
@@ -235,11 +235,11 @@ unsigned long read_persistent_clock(void
BCD_TO_BIN(century);
year += century * 100;
printk(KERN_INFO "Extended CMOS year: %d\n", century * 100);
- } else {
+ } else {
/*
* x86-64 systems only exists since 2002.
* This will work up to Dec 31, 2100
- */
+ */
year += 2000;
}
@@ -251,45 +251,45 @@ unsigned long read_persistent_clock(void
#define TICK_COUNT 100000000
static unsigned int __init tsc_calibrate_cpu_khz(void)
{
- int tsc_start, tsc_now;
- int i, no_ctr_free;
- unsigned long evntsel3 = 0, pmc3 = 0, pmc_now = 0;
- unsigned long flags;
-
- for (i = 0; i < 4; i++)
- if (avail_to_resrv_perfctr_nmi_bit(i))
- break;
- no_ctr_free = (i == 4);
- if (no_ctr_free) {
- i = 3;
- rdmsrl(MSR_K7_EVNTSEL3, evntsel3);
- wrmsrl(MSR_K7_EVNTSEL3, 0);
- rdmsrl(MSR_K7_PERFCTR3, pmc3);
- } else {
- reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i);
- reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
- }
- local_irq_save(flags);
- /* start meauring cycles, incrementing from 0 */
- wrmsrl(MSR_K7_PERFCTR0 + i, 0);
- wrmsrl(MSR_K7_EVNTSEL0 + i, 1 << 22 | 3 << 16 | 0x76);
- rdtscl(tsc_start);
- do {
- rdmsrl(MSR_K7_PERFCTR0 + i, pmc_now);
- tsc_now = get_cycles_sync();
- } while ((tsc_now - tsc_start) < TICK_COUNT);
-
- local_irq_restore(flags);
- if (no_ctr_free) {
- wrmsrl(MSR_K7_EVNTSEL3, 0);
- wrmsrl(MSR_K7_PERFCTR3, pmc3);
- wrmsrl(MSR_K7_EVNTSEL3, evntsel3);
- } else {
- release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
- release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
- }
+ int tsc_start, tsc_now;
+ int i, no_ctr_free;
+ unsigned long evntsel3 = 0, pmc3 = 0, pmc_now = 0;
+ unsigned long flags;
+
+ for (i = 0; i < 4; i++)
+ if (avail_to_resrv_perfctr_nmi_bit(i))
+ break;
+ no_ctr_free = (i == 4);
+ if (no_ctr_free) {
+ i = 3;
+ rdmsrl(MSR_K7_EVNTSEL3, evntsel3);
+ wrmsrl(MSR_K7_EVNTSEL3, 0);
+ rdmsrl(MSR_K7_PERFCTR3, pmc3);
+ } else {
+ reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i);
+ reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
+ }
+ local_irq_save(flags);
+ /* start meauring cycles, incrementing from 0 */
+ wrmsrl(MSR_K7_PERFCTR0 + i, 0);
+ wrmsrl(MSR_K7_EVNTSEL0 + i, 1 << 22 | 3 << 16 | 0x76);
+ rdtscl(tsc_start);
+ do {
+ rdmsrl(MSR_K7_PERFCTR0 + i, pmc_now);
+ tsc_now = get_cycles_sync();
+ } while ((tsc_now - tsc_start) < TICK_COUNT);
+
+ local_irq_restore(flags);
+ if (no_ctr_free) {
+ wrmsrl(MSR_K7_EVNTSEL3, 0);
+ wrmsrl(MSR_K7_PERFCTR3, pmc3);
+ wrmsrl(MSR_K7_EVNTSEL3, evntsel3);
+ } else {
+ release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
+ release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
+ }
- return pmc_now * tsc_khz / (tsc_now - tsc_start);
+ return pmc_now * tsc_khz / (tsc_now - tsc_start);
}
/*
@@ -317,7 +317,7 @@ static unsigned int __init pit_calibrate
end = get_cycles_sync();
spin_unlock_irqrestore(&i8253_lock, flags);
-
+
return (end - start) / 50;
}
@@ -362,7 +362,7 @@ static struct irqaction irq0 = {
.handler = timer_interrupt,
.flags = IRQF_DISABLED | IRQF_IRQPOLL,
.mask = CPU_MASK_NONE,
- .name = "timer"
+ .name = "timer"
};
void __init time_init(void)
@@ -375,7 +375,7 @@ void __init time_init(void)
if (hpet_use_timer) {
/* set tick_nsec to use the proper rate for HPET */
- tick_nsec = TICK_NSEC_HPET;
+ tick_nsec = TICK_NSEC_HPET;
tsc_khz = hpet_calibrate_tsc();
timename = "HPET";
} else {
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 14/33] x86_64: Consolidate tsc calibration
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (12 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 13/33] x86_64: time.c white space wreckage cleanup Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-17 12:51 ` Andi Kleen
2007-07-15 16:10 ` [patch-mm 15/33] i386: prepare sharing the hpet code with x86_64 Thomas Gleixner
` (18 subsequent siblings)
32 siblings, 1 reply; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-consolidate-tsc-calibration.patch --]
[-- Type: text/plain, Size: 7267 bytes --]
Move the TSC calibration code to tsc.c. Reimplement it so the
pm timer can be used as a reference as well.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/hpet.c | 49 -------------------------
arch/x86_64/kernel/time.c | 33 +---------------
arch/x86_64/kernel/tsc.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++
include/asm-i386/tsc.h | 4 ++
4 files changed, 96 insertions(+), 80 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/hpet.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/hpet.c 2007-07-15 17:33:08.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/hpet.c 2007-07-15 17:48:53.000000000 +0200
@@ -184,55 +184,6 @@ int hpet_reenable(void)
return hpet_timer_stop_set_go(hpet_tick);
}
-/*
- * calibrate_tsc() calibrates the processor TSC in a very simple way, comparing
- * it to the HPET timer of known frequency.
- */
-
-#define TICK_COUNT 100000000
-#define SMI_THRESHOLD 50000
-#define MAX_TRIES 5
-
-/*
- * Some platforms take periodic SMI interrupts with 5ms duration. Make sure none
- * occurs between the reads of the hpet & TSC.
- */
-static void __init read_hpet_tsc(int *hpet, int *tsc)
-{
- int tsc1, tsc2, hpet1, i;
-
- for (i = 0; i < MAX_TRIES; i++) {
- tsc1 = get_cycles_sync();
- hpet1 = hpet_readl(HPET_COUNTER);
- tsc2 = get_cycles_sync();
- if ((tsc2 - tsc1) < SMI_THRESHOLD)
- break;
- }
- *hpet = hpet1;
- *tsc = tsc2;
-}
-
-unsigned int __init hpet_calibrate_tsc(void)
-{
- int tsc_start, hpet_start;
- int tsc_now, hpet_now;
- unsigned long flags;
-
- local_irq_save(flags);
-
- read_hpet_tsc(&hpet_start, &tsc_start);
-
- do {
- local_irq_disable();
- read_hpet_tsc(&hpet_now, &tsc_now);
- local_irq_restore(flags);
- } while ((tsc_now - tsc_start) < TICK_COUNT &&
- (hpet_now - hpet_start) < TICK_COUNT);
-
- return (tsc_now - tsc_start) * 1000000000L
- / ((hpet_now - hpet_start) * hpet_period / 1000);
-}
-
#ifdef CONFIG_HPET_EMULATE_RTC
/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
* is enabled, we support RTC interrupt functionality in software.
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/time.c 2007-07-15 17:34:06.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c 2007-07-15 17:49:00.000000000 +0200
@@ -292,35 +292,6 @@ static unsigned int __init tsc_calibrate
return pmc_now * tsc_khz / (tsc_now - tsc_start);
}
-/*
- * pit_calibrate_tsc() uses the speaker output (channel 2) of
- * the PIT. This is better than using the timer interrupt output,
- * because we can read the value of the speaker with just one inb(),
- * where we need three i/o operations for the interrupt channel.
- * We count how many ticks the TSC does in 50 ms.
- */
-
-static unsigned int __init pit_calibrate_tsc(void)
-{
- unsigned long start, end;
- unsigned long flags;
-
- spin_lock_irqsave(&i8253_lock, flags);
-
- outb((inb(0x61) & ~0x02) | 0x01, 0x61);
-
- outb(0xb0, 0x43);
- outb((PIT_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
- outb((PIT_TICK_RATE / (1000 / 50)) >> 8, 0x42);
- start = get_cycles_sync();
- while ((inb(0x61) & 0x20) == 0);
- end = get_cycles_sync();
-
- spin_unlock_irqrestore(&i8253_lock, flags);
-
- return (end - start) / 50;
-}
-
#define PIT_MODE 0x43
#define PIT_CH0 0x40
@@ -376,14 +347,14 @@ void __init time_init(void)
if (hpet_use_timer) {
/* set tick_nsec to use the proper rate for HPET */
tick_nsec = TICK_NSEC_HPET;
- tsc_khz = hpet_calibrate_tsc();
timename = "HPET";
} else {
pit_init();
- tsc_khz = pit_calibrate_tsc();
timename = "PIT";
}
+ tsc_calibrate();
+
cpu_khz = tsc_khz;
if (cpu_has(&boot_cpu_data, X86_FEATURE_CONSTANT_TSC) &&
boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/tsc.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/tsc.c 2007-07-15 17:31:15.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/tsc.c 2007-07-15 17:34:42.000000000 +0200
@@ -6,7 +6,9 @@
#include <linux/time.h>
#include <linux/acpi.h>
#include <linux/cpufreq.h>
+#include <linux/acpi_pmtmr.h>
+#include <asm/hpet.h>
#include <asm/timex.h>
static int notsc __initdata = 0;
@@ -90,6 +92,94 @@ core_initcall(cpufreq_tsc);
#endif
+#define MAX_RETRIES 5
+#define SMI_TRESHOLD 50000
+
+/*
+ * Read TSC and the reference counters. Take care of SMI disturbance
+ */
+static unsigned long __init tsc_read_refs(unsigned long *pm,
+ unsigned long *hpet)
+{
+ unsigned long t1, t2;
+ int i;
+
+ for (i = 0; i < MAX_RETRIES; i++) {
+ t1 = get_cycles_sync();
+ if (hpet)
+ *hpet = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
+ else
+ *pm = acpi_pm_read_early();
+ t2 = get_cycles_sync();
+ if ((t2 - t1) < SMI_TRESHOLD)
+ return t2;
+ }
+ return ULONG_MAX;
+}
+
+/**
+ * tsc_calibrate - calibrate the tsc on boot
+ */
+void __init tsc_calibrate(void)
+{
+ unsigned long flags, tsc1, tsc2, tr1, tr2, pm1, pm2, hpet1, hpet2;
+ int hpet = is_hpet_enabled();
+
+ local_irq_save(flags);
+
+ tsc1 = tsc_read_refs(&pm1, hpet ? &hpet1 : NULL);
+
+ outb((inb(0x61) & ~0x02) | 0x01, 0x61);
+
+ outb(0xb0, 0x43);
+ outb((CLOCK_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
+ outb((CLOCK_TICK_RATE / (1000 / 50)) >> 8, 0x42);
+ tr1 = get_cycles_sync();
+ while ((inb(0x61) & 0x20) == 0);
+ tr2 = get_cycles_sync();
+
+ tsc2 = tsc_read_refs(&pm2, hpet ? &hpet2 : NULL);
+
+ local_irq_restore(flags);
+
+ /*
+ * Preset the result with the raw and inaccurate PIT
+ * calibration value
+ */
+ tsc_khz = (tr2 - tr1) / 50;
+
+ /* hpet or pmtimer available ? */
+ if (!hpet && !pm1 && !pm2) {
+ printk(KERN_INFO "TSC calibrated against PIT\n");
+ return;
+ }
+
+ /* Check, whether the sampling was disturbed by an SMI */
+ if (tsc1 == ULONG_MAX || tsc2 == ULONG_MAX) {
+ printk(KERN_WARNING "TSC calibration disturbed by SMI, "
+ "using PIT calibration result\n");
+ return;
+ }
+
+ tsc2 = (tsc2 - tsc1) * 1000000L;
+
+ if (hpet) {
+ printk(KERN_INFO "TSC calibrated against HPET\n");
+ if (hpet2 < hpet1)
+ hpet2 += 0x100000000;
+ hpet2 -= hpet1;
+ tsc1 = (hpet2 * hpet_readl(HPET_PERIOD)) / 1000000;
+ } else {
+ printk(KERN_INFO "TSC calibrated against PM_TIMER\n");
+ if (pm2 < pm1)
+ pm2 += ACPI_PM_OVRRUN;
+ pm2 -= pm1;
+ tsc1 = (pm2 * 1000000000) / PMTMR_TICKS_PER_SEC;
+ }
+
+ tsc_khz = tsc2 / tsc1;
+}
+
/*
* Make an educated guess if the TSC is trustworthy and synchronized
* over all CPUs.
Index: linux-2.6.22-rc6-mm/include/asm-i386/tsc.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/tsc.h 2007-07-15 17:26:45.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/tsc.h 2007-07-15 17:34:42.000000000 +0200
@@ -71,4 +71,8 @@ extern void init_tsc_clocksource(void);
extern void check_tsc_sync_source(int cpu);
extern void check_tsc_sync_target(void);
+#ifdef CONFIG_X86_64
+extern void tsc_calibrate(void);
+#endif
+
#endif
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 15/33] i386: prepare sharing the hpet code with x86_64
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (13 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 14/33] x86_64: Consolidate tsc calibration Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 16/33] i386: hpet add x8664 bits Thomas Gleixner
` (17 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: i386-prepare-sharing-hpet-code.patch --]
[-- Type: text/plain, Size: 2721 bytes --]
The hpet implementations of i386 and x8664 has been mostly the same
before the clock events conversion of i386. The clock events
conversion of i386 hpet is already done. So it makes sense to share
the code for the x86_64 clock events conversion.
Abstract out the mapping functions.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/i386/kernel/hpet.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/i386/kernel/hpet.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/i386/kernel/hpet.c 2007-07-15 17:26:45.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/i386/kernel/hpet.c 2007-07-15 17:49:01.000000000 +0200
@@ -3,14 +3,14 @@
#include <linux/errno.h>
#include <linux/hpet.h>
#include <linux/init.h>
+#include <linux/ioport.h>
#include <linux/sysdev.h>
#include <linux/pm.h>
#include <asm/hpet.h>
+#include <asm/i8253.h>
#include <asm/io.h>
-extern struct clock_event_device *global_clock_event;
-
#define HPET_MASK CLOCKSOURCE_MASK(32)
#define HPET_SHIFT 22
@@ -21,7 +21,7 @@ extern struct clock_event_device *global
* HPET address is set in acpi/boot.c, when an ACPI entry exists
*/
unsigned long hpet_address;
-static void __iomem * hpet_virt_address;
+static void __iomem *hpet_virt_address;
static inline unsigned long hpet_readl(unsigned long a)
{
@@ -33,6 +33,17 @@ static inline void hpet_writel(unsigned
writel(d, hpet_virt_address + a);
}
+static inline void hpet_set_mapping(void)
+{
+ hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
+}
+
+static inline void hpet_clear_mapping(void)
+{
+ iounmap(hpet_virt_address);
+ hpet_virt_address = NULL;
+}
+
/*
* HPET command line enable / disable
*/
@@ -82,7 +93,7 @@ static void hpet_reserve_platform_timers
memset(&hd, 0, sizeof (hd));
hd.hd_phys_address = hpet_address;
- hd.hd_address = hpet_virt_address;
+ hd.hd_address = hpet;
hd.hd_nirqs = nrtimers;
hd.hd_flags = HPET_DATA_PLATFORM;
hpet_reserve_timer(&hd, 0);
@@ -237,7 +248,7 @@ int __init hpet_enable(void)
if (!is_hpet_capable())
return 0;
- hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
+ hpet_set_mapping();
/*
* Read the period and check for a sane value:
@@ -333,13 +344,11 @@ int __init hpet_enable(void)
return 0;
out_nohpet:
- iounmap(hpet_virt_address);
- hpet_virt_address = NULL;
+ hpet_clear_mapping();
boot_hpet_disable = 1;
return 0;
}
-
#ifdef CONFIG_HPET_EMULATE_RTC
/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 16/33] i386: hpet add x8664 bits
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (14 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 15/33] i386: prepare sharing the hpet code with x86_64 Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 17/33] i386: prepare sharing the PIT code Thomas Gleixner
` (16 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen
[-- Attachment #1: i386-hpet-add-x8664-hpet-bits.patch --]
[-- Type: text/plain, Size: 3718 bytes --]
Add the x8664 specific bits (mapping) to share the hpet code later.
Move the reserve_platform_timer call to late init. This is necessary
for x86_64, as hpet enable() is called before memory is setup. i386
calls it in late_time_init, but it does not hurt to do it later for
both.
Pull in the x8664 hpet disable command line option as well.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/i386/kernel/hpet.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
Index: linux-2.6.22-rc6-mm/arch/i386/kernel/hpet.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/i386/kernel/hpet.c 2007-07-15 17:39:01.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/i386/kernel/hpet.c 2007-07-15 17:48:49.000000000 +0200
@@ -7,6 +7,7 @@
#include <linux/sysdev.h>
#include <linux/pm.h>
+#include <asm/fixmap.h>
#include <asm/hpet.h>
#include <asm/i8253.h>
#include <asm/io.h>
@@ -23,6 +24,10 @@
unsigned long hpet_address;
static void __iomem *hpet_virt_address;
+/* Temporary hack. Cleanup after x86_64 clock events conversion */
+#undef hpet_readl
+#undef hpet_writel
+
static inline unsigned long hpet_readl(unsigned long a)
{
return readl(hpet_virt_address + a);
@@ -33,6 +38,24 @@ static inline void hpet_writel(unsigned
writel(d, hpet_virt_address + a);
}
+#ifdef CONFIG_X86_64
+
+#include <asm/pgtable.h>
+
+static inline void hpet_set_mapping(void)
+{
+ set_fixmap_nocache(FIX_HPET_BASE, hpet_address);
+ __set_fixmap(VSYSCALL_HPET, hpet_address, PAGE_KERNEL_VSYSCALL_NOCACHE);
+ hpet_virt_address = (void __iomem *)fix_to_virt(FIX_HPET_BASE);
+}
+
+static inline void hpet_clear_mapping(void)
+{
+ hpet_virt_address = NULL;
+}
+
+#else
+
static inline void hpet_set_mapping(void)
{
hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
@@ -43,6 +66,7 @@ static inline void hpet_clear_mapping(vo
iounmap(hpet_virt_address);
hpet_virt_address = NULL;
}
+#endif
/*
* HPET command line enable / disable
@@ -59,6 +83,13 @@ static int __init hpet_setup(char* str)
}
__setup("hpet=", hpet_setup);
+static int __init disable_hpet(char *str)
+{
+ boot_hpet_disable = 1;
+ return 1;
+}
+__setup("nohpet", disable_hpet);
+
static inline int is_hpet_capable(void)
{
return (!boot_hpet_disable && hpet_address);
@@ -225,6 +256,13 @@ static cycle_t read_hpet(void)
return (cycle_t)hpet_readl(HPET_COUNTER);
}
+#ifdef CONFIG_X86_64
+static cycle_t __vsyscall_fn vread_hpet(void)
+{
+ return readl((const void __iomem *)fix_to_virt(VSYSCALL_HPET) + 0xf0);
+}
+#endif
+
static struct clocksource clocksource_hpet = {
.name = "hpet",
.rating = 250,
@@ -233,6 +271,9 @@ static struct clocksource clocksource_hp
.shift = HPET_SHIFT,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
.resume = hpet_start_counter,
+#ifdef CONFIG_X86_64
+ .vread = vread_hpet,
+#endif
};
/*
@@ -331,7 +372,6 @@ int __init hpet_enable(void)
if (id & HPET_ID_LEGSUP) {
hpet_enable_int();
- hpet_reserve_platform_timers(id);
/*
* Start hpet with the boot cpu mask and make it
* global after the IO_APIC has been initialized.
@@ -349,6 +389,22 @@ out_nohpet:
return 0;
}
+/*
+ * Needs to be late, as the reserve_timer code calls kalloc !
+ *
+ * Not a problem on i386 as hpet_enable is called from late_time_init,
+ * but on x86_64 it is necessary !
+ */
+static __init int hpet_late_init(void)
+{
+ if (!is_hpet_capable())
+ return -ENODEV;
+
+ hpet_reserve_platform_timers(hpet_readl(HPET_ID));
+ return 0;
+}
+fs_initcall(hpet_late_init);
+
#ifdef CONFIG_HPET_EMULATE_RTC
/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 17/33] i386: prepare sharing the PIT code
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (15 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 16/33] i386: hpet add x8664 bits Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 18/33] x86_64: use shared i8253.h Thomas Gleixner
` (15 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: i386-prepare-sharing-pit-code.patch --]
[-- Type: text/plain, Size: 1900 bytes --]
PIT clock events work already and the PIT handling is the same for
i386 and x86_64. x86_64 does not support PIT as a clock source, so
disable the PIT clocksource for x86_64.
Prepare i8253.h to be shared with x8664
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/i386/kernel/i8253.c | 3 +++
include/asm-i386/i8253.h | 6 ++++--
2 files changed, 7 insertions(+), 2 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/i386/kernel/i8253.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/i386/kernel/i8253.c 2007-07-15 17:26:45.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/i386/kernel/i8253.c 2007-07-15 17:39:21.000000000 +0200
@@ -120,6 +120,7 @@ void __init setup_pit_timer(void)
global_clock_event = &pit_clockevent;
}
+#ifndef CONFIG_X86_64
/*
* Since the PIT overflows every tick, its not very useful
* to just read by itself. So use jiffies to emulate a free
@@ -204,3 +205,5 @@ static int __init init_pit_clocksource(v
return clocksource_register(&clocksource_pit);
}
arch_initcall(init_pit_clocksource);
+
+#endif
Index: linux-2.6.22-rc6-mm/include/asm-i386/i8253.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/i8253.h 2007-07-15 17:26:45.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/i8253.h 2007-07-15 17:48:50.000000000 +0200
@@ -1,8 +1,6 @@
#ifndef __ASM_I8253_H__
#define __ASM_I8253_H__
-#include <linux/clockchips.h>
-
/* i8253A PIT registers */
#define PIT_MODE 0x43
#define PIT_CH0 0x40
@@ -10,8 +8,12 @@
extern spinlock_t i8253_lock;
+#ifdef CONFIG_GENERIC_CLOCKEVENTS
+
extern struct clock_event_device *global_clock_event;
extern void setup_pit_timer(void);
+#endif
+
#endif /* __ASM_I8253_H__ */
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 18/33] x86_64: use shared i8253.h
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (16 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 17/33] i386: prepare sharing the PIT code Thomas Gleixner
@ 2007-07-15 16:10 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 19/33] x86_64: prepare apic code for clock events Thomas Gleixner
` (14 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:10 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-use-i386-i8253-h.patch --]
[-- Type: text/plain, Size: 1622 bytes --]
Use the i386 i8253.h include file for x86_64 as well to share the
exports and the PIT constants.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/time.c | 4 ----
include/asm-x86_64/i8253.h | 8 ++------
2 files changed, 2 insertions(+), 10 deletions(-)
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/i8253.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/i8253.h 2007-07-15 17:26:45.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/i8253.h 2007-07-15 17:39:28.000000000 +0200
@@ -1,6 +1,2 @@
-#ifndef __ASM_I8253_H__
-#define __ASM_I8253_H__
-
-extern spinlock_t i8253_lock;
-
-#endif /* __ASM_I8253_H__ */
+#include <asm-i386/i8253.h>
+#include <asm/8253pit.h>
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/time.c 2007-07-15 17:34:42.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c 2007-07-15 17:48:54.000000000 +0200
@@ -32,7 +32,6 @@
#include <acpi/achware.h> /* for PM timer frequency */
#include <acpi/acpi_bus.h>
#endif
-#include <asm/8253pit.h>
#include <asm/i8253.h>
#include <asm/pgtable.h>
#include <asm/vsyscall.h>
@@ -292,9 +291,6 @@ static unsigned int __init tsc_calibrate
return pmc_now * tsc_khz / (tsc_now - tsc_start);
}
-#define PIT_MODE 0x43
-#define PIT_CH0 0x40
-
static void __pit_init(int val, u8 mode)
{
unsigned long flags;
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 19/33] x86_64: prepare apic code for clock events
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (17 preceding siblings ...)
2007-07-15 16:10 ` [patch-mm 18/33] x86_64: use shared i8253.h Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 20/33] x86_64: remove pit synchronization Thomas Gleixner
` (13 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-preparatory-apic-set-lvtt.patch --]
[-- Type: text/plain, Size: 2443 bytes --]
Change __setup_APIC_LVTT so it takes the arguments which are necessary
for the later clock events switch.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:33:43.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:59.000000000 +0200
@@ -760,14 +760,14 @@ void __init init_apic_mappings(void)
#define APIC_DIVISOR 16
-static void __setup_APIC_LVTT(unsigned int clocks)
+static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
{
unsigned int lvtt_value, tmp_value;
- int cpu = smp_processor_id();
-
- lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
- if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
+ lvtt_value = LOCAL_TIMER_VECTOR;
+ if (!oneshot)
+ lvtt_value |= APIC_LVT_TIMER_PERIODIC;
+ if (!irqen)
lvtt_value |= APIC_LVT_MASKED;
apic_write(APIC_LVTT, lvtt_value);
@@ -780,12 +780,14 @@ static void __setup_APIC_LVTT(unsigned i
& ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
| APIC_TDR_DIV_16);
- apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
+ if (!oneshot)
+ apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
}
static void setup_APIC_timer(unsigned int clocks)
{
unsigned long flags;
+ int irqen;
local_irq_save(flags);
@@ -808,7 +810,10 @@ static void setup_APIC_timer(unsigned in
c2 |= inb_p(0x40) << 8;
} while (c2 - c1 < 300);
}
- __setup_APIC_LVTT(clocks);
+
+ irqen = ! cpu_isset(smp_processor_id(),
+ timer_interrupt_broadcast_ipi_mask);
+ __setup_APIC_LVTT(clocks, 0, irqen);
/* Turn off PIT interrupt if we use APIC timer as main timer.
Only works with the PM timer right now
TBD fix it for HPET too. */
@@ -846,8 +851,10 @@ static int __init calibrate_APIC_clock(v
* Put whatever arbitrary (but long enough) timeout
* value into the APIC clock, we just want to get the
* counter running for calibration.
+ *
+ * No interrupt enable !
*/
- __setup_APIC_LVTT(4000000000);
+ __setup_APIC_LVTT(4000000000, 0, 0);
apic_start = apic_read(APIC_TMCCT);
#ifdef CONFIG_X86_PM_TIMER
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 20/33] x86_64: remove pit synchronization
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (18 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 19/33] x86_64: prepare apic code for clock events Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 21/33] x86_64: Move apic calibration code around Thomas Gleixner
` (12 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-apic-remove-bogus-pit-synchronization.patch --]
[-- Type: text/plain, Size: 1540 bytes --]
The APIC timer setup code synchronizes the local APIC timer to the
PIT/HPET. This is pointless as the PIT and the local APIC timer
frequency are not correlated and the APIC timer calibration can never
be accurate enough to avoid that the local APIC timer and the PIT/HPET
drift apart.
Simply remove it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 20 --------------------
1 file changed, 20 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:39:44.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:58.000000000 +0200
@@ -791,26 +791,6 @@ static void setup_APIC_timer(unsigned in
local_irq_save(flags);
- /* wait for irq slice */
- if (hpet_address && hpet_use_timer) {
- int trigger = hpet_readl(HPET_T0_CMP);
- while (hpet_readl(HPET_COUNTER) >= trigger)
- /* do nothing */ ;
- while (hpet_readl(HPET_COUNTER) < trigger)
- /* do nothing */ ;
- } else {
- int c1, c2;
- outb_p(0x00, 0x43);
- c2 = inb_p(0x40);
- c2 |= inb_p(0x40) << 8;
- do {
- c1 = c2;
- outb_p(0x00, 0x43);
- c2 = inb_p(0x40);
- c2 |= inb_p(0x40) << 8;
- } while (c2 - c1 < 300);
- }
-
irqen = ! cpu_isset(smp_processor_id(),
timer_interrupt_broadcast_ipi_mask);
__setup_APIC_LVTT(clocks, 0, irqen);
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 21/33] x86_64: Move apic calibration code around
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (19 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 20/33] x86_64: remove pit synchronization Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 22/33] x86_64: Remove APIC_DIVISOR Thomas Gleixner
` (11 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-apic-shuffle-calibration-around.patch --]
[-- Type: text/plain, Size: 2210 bytes --]
Let the calibration code fill in calibration_result directly and
move the variable on top of the file.
Fixup a printk w/o log level while at it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:40:05.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:57.000000000 +0200
@@ -56,6 +56,8 @@ static struct resource lapic_resource =
.flags = IORESOURCE_MEM | IORESOURCE_BUSY,
};
+static unsigned int calibration_result;
+
/*
* cpu_mask that denotes the CPUs that needs timer interrupt coming in as
* IPIs in place of local APIC timers
@@ -822,7 +824,7 @@ static void setup_APIC_timer(unsigned in
#define TICK_COUNT 100000000
-static int __init calibrate_APIC_clock(void)
+static void __init calibrate_APIC_clock(void)
{
unsigned apic, apic_start;
unsigned long tsc, tsc_start;
@@ -856,17 +858,14 @@ static int __init calibrate_APIC_clock(v
result = (apic_start - apic) * 1000L * tsc_khz /
(tsc - tsc_start);
}
- printk("result %d\n", result);
-
+ printk(KERN_DEBUG "APIC timer calibration result %d\n", result);
printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
result / 1000 / 1000, result / 1000 % 1000);
- return result * APIC_DIVISOR / HZ;
+ calibration_result = result * APIC_DIVISOR / HZ;
}
-static unsigned int calibration_result;
-
void __init setup_boot_APIC_clock (void)
{
if (disable_apic_timer) {
@@ -879,7 +878,7 @@ void __init setup_boot_APIC_clock (void)
local_irq_disable();
- calibration_result = calibrate_APIC_clock();
+ calibrate_APIC_clock();
/*
* Now set up the timer for real.
*/
@@ -986,8 +985,6 @@ void setup_APIC_extended_lvt(unsigned ch
apic_write(reg, v);
}
-#undef APIC_DIVISOR
-
/*
* Local timer interrupt handler. It does both profiling and
* process statistics/rescheduling.
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 22/33] x86_64: Remove APIC_DIVISOR
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (20 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 21/33] x86_64: Move apic calibration code around Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 23/33] x86_64: apic change setup_APIC_timer calling convention Thomas Gleixner
` (10 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-apic-calibration-remove-divisor.patch --]
[-- Type: text/plain, Size: 1792 bytes --]
APIC_DIVISOR is rather useless. It makes the calibration result more
accurate in the first place, but we discard this later when we write
the value to the APIC timer by dividing the calibration value by
APIC_DIVISOR.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:40:59.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:57.000000000 +0200
@@ -760,8 +760,6 @@ void __init init_apic_mappings(void)
* P5 APIC double write bug.
*/
-#define APIC_DIVISOR 16
-
static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
{
unsigned int lvtt_value, tmp_value;
@@ -783,7 +781,7 @@ static void __setup_APIC_LVTT(unsigned i
| APIC_TDR_DIV_16);
if (!oneshot)
- apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
+ apic_write(APIC_TMICT, clocks);
}
static void setup_APIC_timer(unsigned int clocks)
@@ -836,7 +834,7 @@ static void __init calibrate_APIC_clock(
*
* No interrupt enable !
*/
- __setup_APIC_LVTT(4000000000, 0, 0);
+ __setup_APIC_LVTT(250000000, 0, 0);
apic_start = apic_read(APIC_TMCCT);
#ifdef CONFIG_X86_PM_TIMER
@@ -863,7 +861,7 @@ static void __init calibrate_APIC_clock(
printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
result / 1000 / 1000, result / 1000 % 1000);
- calibration_result = result * APIC_DIVISOR / HZ;
+ calibration_result = result / HZ;
}
void __init setup_boot_APIC_clock (void)
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 23/33] x86_64: apic change setup_APIC_timer calling convention
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (21 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 22/33] x86_64: Remove APIC_DIVISOR Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 24/33] x86_64: remove nested irq disables Thomas Gleixner
` (9 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-apic-change-setup-calling-convention.patch --]
[-- Type: text/plain, Size: 1698 bytes --]
setup_APIC_timer takes the file global calibration result as an argument.
Remove it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:41:16.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:56.000000000 +0200
@@ -784,7 +784,7 @@ static void __setup_APIC_LVTT(unsigned i
apic_write(APIC_TMICT, clocks);
}
-static void setup_APIC_timer(unsigned int clocks)
+static void setup_APIC_timer(void)
{
unsigned long flags;
int irqen;
@@ -793,7 +793,7 @@ static void setup_APIC_timer(unsigned in
irqen = ! cpu_isset(smp_processor_id(),
timer_interrupt_broadcast_ipi_mask);
- __setup_APIC_LVTT(clocks, 0, irqen);
+ __setup_APIC_LVTT(calibration_result, 0, irqen);
/* Turn off PIT interrupt if we use APIC timer as main timer.
Only works with the PM timer right now
TBD fix it for HPET too. */
@@ -880,7 +880,7 @@ void __init setup_boot_APIC_clock (void)
/*
* Now set up the timer for real.
*/
- setup_APIC_timer(calibration_result);
+ setup_APIC_timer();
local_irq_enable();
}
@@ -888,7 +888,7 @@ void __init setup_boot_APIC_clock (void)
void __cpuinit setup_secondary_APIC_clock(void)
{
local_irq_disable(); /* FIXME: Do we need this? --RR */
- setup_APIC_timer(calibration_result);
+ setup_APIC_timer();
local_irq_enable();
}
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 24/33] x86_64: remove nested irq disables
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (22 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 23/33] x86_64: apic change setup_APIC_timer calling convention Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 25/33] x86_64: prepare idle loop for dynamic ticks Thomas Gleixner
` (8 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-apic-remove-nested-irq-disable.patch --]
[-- Type: text/plain, Size: 1793 bytes --]
setup_APIC_timer disables interrupts anyway. So no need to do the same
in setup_boot_APIC_clock and setup_secondary_APIC_clock. Disable
interrupts explicit in the calibration code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:41:32.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:54.000000000 +0200
@@ -827,6 +827,9 @@ static void __init calibrate_APIC_clock(
unsigned apic, apic_start;
unsigned long tsc, tsc_start;
int result;
+
+ local_irq_disable();
+
/*
* Put whatever arbitrary (but long enough) timeout
* value into the APIC clock, we just want to get the
@@ -856,6 +859,9 @@ static void __init calibrate_APIC_clock(
result = (apic_start - apic) * 1000L * tsc_khz /
(tsc - tsc_start);
}
+
+ local_irq_enable();
+
printk(KERN_DEBUG "APIC timer calibration result %d\n", result);
printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
@@ -874,22 +880,16 @@ void __init setup_boot_APIC_clock (void)
printk(KERN_INFO "Using local APIC timer interrupts.\n");
using_apic_timer = 1;
- local_irq_disable();
-
calibrate_APIC_clock();
/*
* Now set up the timer for real.
*/
setup_APIC_timer();
-
- local_irq_enable();
}
void __cpuinit setup_secondary_APIC_clock(void)
{
- local_irq_disable(); /* FIXME: Do we need this? --RR */
setup_APIC_timer();
- local_irq_enable();
}
void disable_APIC_timer(void)
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 25/33] x86_64: prepare idle loop for dynamic ticks
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (23 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 24/33] x86_64: remove nested irq disables Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 26/33] x86_64: apic add clock event functions Thomas Gleixner
` (7 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-prep-idle-loop-for-dynticks.patch --]
[-- Type: text/plain, Size: 1257 bytes --]
From: Chris Wright <chrisw@sous-sol.org>
Add tick_nohz_{stop,restart}_sched_tick to idle loop in prepartion for turning
on dynticks. These are just noops until NO_HZ is enabled.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/process.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/process.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/process.c 2007-07-15 17:01:24.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/process.c 2007-07-15 17:42:36.000000000 +0200
@@ -37,6 +37,7 @@
#include <linux/notifier.h>
#include <linux/kprobes.h>
#include <linux/kdebug.h>
+#include <linux/tick.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
@@ -208,6 +209,7 @@ void cpu_idle (void)
__get_cpu_var(cpu_idle_state) = 0;
check_pgt_cache();
+ tick_nohz_stop_sched_tick();
rmb();
idle = pm_idle;
if (!idle)
@@ -228,6 +230,7 @@ void cpu_idle (void)
__exit_idle();
}
+ tick_nohz_restart_sched_tick();
preempt_enable_no_resched();
schedule();
preempt_disable();
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 26/33] x86_64: apic add clock event functions
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (24 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 25/33] x86_64: prepare idle loop for dynamic ticks Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 27/33] x86_64: convert to clock events Thomas Gleixner
` (6 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-apic-add-clockevents-functions.patch --]
[-- Type: text/plain, Size: 4044 bytes --]
Add the clock event functions to apic.c. Still unused, but setup of
the factors integrated into the calibration code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/Kconfig | 6 +++
arch/x86_64/kernel/apic.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+)
Index: linux-2.6.22-rc6-mm/arch/x86_64/Kconfig
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/Kconfig 2007-07-15 17:30:43.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/Kconfig 2007-07-15 17:48:54.000000000 +0200
@@ -28,6 +28,10 @@ config GENERIC_TIME
bool
default y
+config GENERIC_CLOCKEVENTS_MIGR
+ bool
+ default y
+
config GENERIC_TIME_VSYSCALL
bool
default y
@@ -138,6 +142,8 @@ source "init/Kconfig"
menu "Processor type and features"
+source "kernel/time/Kconfig"
+
choice
prompt "Subarchitecture Type"
default X86_PC
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:42:19.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:54.000000000 +0200
@@ -25,6 +25,7 @@
#include <linux/sysdev.h>
#include <linux/module.h>
#include <linux/ioport.h>
+#include <linux/clockchips.h>
#include <asm/atomic.h>
#include <asm/smp.h>
@@ -58,6 +59,77 @@ static struct resource lapic_resource =
static unsigned int calibration_result;
+static int lapic_next_event(unsigned long delta,
+ struct clock_event_device *evt);
+static void lapic_timer_setup(enum clock_event_mode mode,
+ struct clock_event_device *evt);
+
+static void lapic_timer_broadcast(cpumask_t mask);
+
+static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen);
+
+static struct clock_event_device lapic_clockevent = {
+ .name = "lapic",
+ .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT
+ | CLOCK_EVT_FEAT_C3STOP | CLOCK_EVT_FEAT_DUMMY,
+ .shift = 32,
+ .set_mode = lapic_timer_setup,
+ .set_next_event = lapic_next_event,
+ .broadcast = lapic_timer_broadcast,
+ .rating = 100,
+ .irq = -1,
+};
+static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
+
+static int lapic_next_event(unsigned long delta,
+ struct clock_event_device *evt)
+{
+ apic_write(APIC_TMICT, delta);
+ return 0;
+}
+
+static void lapic_timer_setup(enum clock_event_mode mode,
+ struct clock_event_device *evt)
+{
+ unsigned long flags;
+ unsigned int v;
+
+ /* Lapic used as dummy for broadcast ? */
+ if (evt->features & CLOCK_EVT_FEAT_DUMMY)
+ return;
+
+ local_irq_save(flags);
+
+ switch (mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ case CLOCK_EVT_MODE_ONESHOT:
+ __setup_APIC_LVTT(calibration_result,
+ mode != CLOCK_EVT_MODE_PERIODIC, 1);
+ break;
+ case CLOCK_EVT_MODE_UNUSED:
+ case CLOCK_EVT_MODE_SHUTDOWN:
+ v = apic_read(APIC_LVTT);
+ v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
+ apic_write(APIC_LVTT, v);
+ break;
+ case CLOCK_EVT_MODE_RESUME:
+ /* Nothing to do here */
+ break;
+ }
+
+ local_irq_restore(flags);
+}
+
+/*
+ * Local APIC timer broadcast function
+ */
+static void lapic_timer_broadcast(cpumask_t mask)
+{
+#ifdef CONFIG_SMP
+ send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
+#endif
+}
+
/*
* cpu_mask that denotes the CPUs that needs timer interrupt coming in as
* IPIs in place of local APIC timers
@@ -867,6 +939,13 @@ static void __init calibrate_APIC_clock(
printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
result / 1000 / 1000, result / 1000 % 1000);
+ /* Calculate the scaled math multiplication factor */
+ lapic_clockevent.mult = div_sc(result, NSEC_PER_SEC, 32);
+ lapic_clockevent.max_delta_ns =
+ clockevent_delta2ns(0x7FFFFF, &lapic_clockevent);
+ lapic_clockevent.min_delta_ns =
+ clockevent_delta2ns(0xF, &lapic_clockevent);
+
calibration_result = result / HZ;
}
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 27/33] x86_64: convert to clock events
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (25 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 26/33] x86_64: apic add clock event functions Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 28/33] x86_64: remove now unused code Thomas Gleixner
` (5 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-convert-to-clockevents.patch --]
[-- Type: text/plain, Size: 13376 bytes --]
Finally switch to the clockevents code. Share code with i386 for
hpet and PIT.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/Kconfig | 10 +++
arch/x86_64/kernel/Makefile | 4 +
arch/x86_64/kernel/apic.c | 90 +++++++++++++++++++----------------
arch/x86_64/kernel/i8259.c | 46 ------------------
arch/x86_64/kernel/smpboot.c | 4 -
arch/x86_64/kernel/time.c | 109 +++++--------------------------------------
include/asm-x86_64/hpet.h | 16 ------
7 files changed, 76 insertions(+), 203 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/Kconfig
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/Kconfig 2007-07-15 17:42:51.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/Kconfig 2007-07-15 17:43:10.000000000 +0200
@@ -28,7 +28,15 @@ config GENERIC_TIME
bool
default y
-config GENERIC_CLOCKEVENTS_MIGR
+config GENERIC_CLOCKEVENTS
+ bool
+ default y
+
+config GENERIC_CLOCKEVENTS_BROADCAST
+ bool
+ default y
+
+config NONIRQ_WAKEUP
bool
default y
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/Makefile
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/Makefile 2007-07-15 16:59:23.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/Makefile 2007-07-15 17:43:10.000000000 +0200
@@ -9,7 +9,7 @@ obj-y := process.o signal.o entry.o trap
x8664_ksyms.o i387.o syscall.o vsyscall.o \
setup64.o bootflag.o e820.o reboot.o quirks.o i8237.o \
pci-dma.o pci-nommu.o alternative.o hpet.o tsc.o bugs.o \
- perfctr-watchdog.o sched-clock.o
+ perfctr-watchdog.o sched-clock.o i8253.o
obj-$(CONFIG_STACKTRACE) += stacktrace.o
obj-$(CONFIG_X86_MCE) += mce.o therm_throt.o
@@ -49,6 +49,8 @@ obj-y += pcspeaker.o
CFLAGS_vsyscall.o := $(PROFILING) -g0
+i8253-y += ../../i386/kernel/i8253.o
+hpet-y += ../../i386/kernel/hpet.o
therm_throt-y += ../../i386/kernel/cpu/mcheck/therm_throt.o
bootflag-y += ../../i386/kernel/bootflag.o
legacy_serial-y += ../../i386/kernel/legacy_serial.o
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:42:51.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:53.000000000 +0200
@@ -858,25 +858,12 @@ static void __setup_APIC_LVTT(unsigned i
static void setup_APIC_timer(void)
{
- unsigned long flags;
- int irqen;
+ struct clock_event_device *levt = &__get_cpu_var(lapic_events);
- local_irq_save(flags);
+ memcpy(levt, &lapic_clockevent, sizeof(*levt));
+ levt->cpumask = cpumask_of_cpu(smp_processor_id());
- irqen = ! cpu_isset(smp_processor_id(),
- timer_interrupt_broadcast_ipi_mask);
- __setup_APIC_LVTT(calibration_result, 0, irqen);
- /* Turn off PIT interrupt if we use APIC timer as main timer.
- Only works with the PM timer right now
- TBD fix it for HPET too. */
- if ((pmtmr_ioport != 0) &&
- smp_processor_id() == boot_cpu_id &&
- apic_runs_main_timer == 1 &&
- !cpu_isset(boot_cpu_id, timer_interrupt_broadcast_ipi_mask)) {
- stop_timer_interrupt();
- apic_runs_main_timer++;
- }
- local_irq_restore(flags);
+ clockevents_register_device(levt);
}
/*
@@ -951,18 +938,34 @@ static void __init calibrate_APIC_clock(
void __init setup_boot_APIC_clock (void)
{
+ /*
+ * The local apic timer can be disabled via the kernel commandline.
+ * Register the lapic timer as a dummy clock event source on SMP
+ * systems, so the broadcast mechanism is used. On UP systems simply
+ * ignore it.
+ */
if (disable_apic_timer) {
printk(KERN_INFO "Disabling APIC timer\n");
+ /* No broadcast on UP ! */
+ if (num_possible_cpus() > 1)
+ setup_APIC_timer();
return;
}
printk(KERN_INFO "Using local APIC timer interrupts.\n");
- using_apic_timer = 1;
-
calibrate_APIC_clock();
+
/*
- * Now set up the timer for real.
+ * If nmi_watchdog is set to IO_APIC, we need the
+ * PIT/HPET going. Otherwise register lapic as a dummy
+ * device.
*/
+ if (nmi_watchdog != NMI_IO_APIC)
+ lapic_clockevent.features &= ~CLOCK_EVT_FEAT_DUMMY;
+ else
+ printk(KERN_WARNING "APIC timer registered as dummy,"
+ " due to nmi_watchdog=1!\n");
+
setup_APIC_timer();
}
@@ -1074,22 +1077,34 @@ void setup_APIC_extended_lvt(unsigned ch
void smp_local_timer_interrupt(void)
{
- profile_tick(CPU_PROFILING);
-#ifdef CONFIG_SMP
- update_process_times(user_mode(get_irq_regs()));
-#endif
- if (apic_runs_main_timer > 1 && smp_processor_id() == boot_cpu_id)
- main_timer_handler();
+ int cpu = smp_processor_id();
+ struct clock_event_device *evt = &per_cpu(lapic_events, cpu);
+
/*
- * We take the 'long' return path, and there every subsystem
- * grabs the appropriate locks (kernel lock/ irq lock).
+ * Normally we should not be here till LAPIC has been initialized but
+ * in some cases like kdump, its possible that there is a pending LAPIC
+ * timer interrupt from previous kernel's context and is delivered in
+ * new kernel the moment interrupts are enabled.
*
- * We might want to decouple profiling from the 'long path',
- * and do the profiling totally in assembly.
- *
- * Currently this isn't too much of an issue (performance wise),
- * we can take more than 100K local irqs per second on a 100 MHz P5.
+ * Interrupts are enabled early and LAPIC is setup much later, hence
+ * its possible that when we get here evt->event_handler is NULL.
+ * Check for event_handler being NULL and discard the interrupt as
+ * spurious.
+ */
+ if (!evt->event_handler) {
+ printk(KERN_WARNING
+ "Spurious LAPIC timer interrupt on cpu %d\n", cpu);
+ /* Switch it off */
+ lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt);
+ return;
+ }
+
+ /*
+ * the NMI deadlock-detector uses this.
*/
+ add_pda(apic_timer_irqs, 1);
+
+ evt->event_handler(evt);
}
/*
@@ -1105,11 +1120,6 @@ void smp_apic_timer_interrupt(struct pt_
struct pt_regs *old_regs = set_irq_regs(regs);
/*
- * the NMI deadlock-detector uses this.
- */
- add_pda(apic_timer_irqs, 1);
-
- /*
* NOTE! We'd better ACK the irq immediately,
* because timer handling can be slow.
*/
@@ -1292,7 +1302,7 @@ static __init int setup_noapictimer(char
static __init int setup_apicmaintimer(char *str)
{
apic_runs_main_timer = 1;
- nohpet = 1;
+
return 1;
}
__setup("apicmaintimer", setup_apicmaintimer);
@@ -1308,7 +1318,7 @@ static __init int setup_apicpmtimer(char
{
apic_calibrate_pmtmr = 1;
notsc_setup(NULL);
- return setup_apicmaintimer(NULL);
+ return 0;
}
__setup("apicpmtimer", setup_apicpmtimer);
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/i8259.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/i8259.c 2007-07-15 16:59:23.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/i8259.c 2007-07-15 17:43:10.000000000 +0200
@@ -444,46 +444,6 @@ void __init init_ISA_irqs (void)
}
}
-static void setup_timer_hardware(void)
-{
- outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */
- udelay(10);
- outb_p(LATCH & 0xff , 0x40); /* LSB */
- udelay(10);
- outb(LATCH >> 8 , 0x40); /* MSB */
-}
-
-static int timer_resume(struct sys_device *dev)
-{
- setup_timer_hardware();
- return 0;
-}
-
-void i8254_timer_resume(void)
-{
- setup_timer_hardware();
-}
-
-static struct sysdev_class timer_sysclass = {
- set_kset_name("timer_pit"),
- .resume = timer_resume,
-};
-
-static struct sys_device device_timer = {
- .id = 0,
- .cls = &timer_sysclass,
-};
-
-static int __init init_timer_sysfs(void)
-{
- int error = sysdev_class_register(&timer_sysclass);
- if (!error)
- error = sysdev_register(&device_timer);
- return error;
-}
-
-device_initcall(init_timer_sysfs);
-
void __init init_IRQ(void)
{
int i;
@@ -533,12 +493,6 @@ void __init init_IRQ(void)
set_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
set_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
- /*
- * Set the clock to HZ Hz, we already have a valid
- * vector now:
- */
- setup_timer_hardware();
-
if (!acpi_ioapic)
setup_irq(2, &irq2);
}
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/smpboot.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/smpboot.c 2007-07-15 16:59:23.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/smpboot.c 2007-07-15 17:43:10.000000000 +0200
@@ -223,8 +223,6 @@ void __cpuinit smp_callin(void)
local_irq_disable();
Dprintk("Stack at about %p\n",&cpuid);
- disable_APIC_timer();
-
/*
* Save our processor parameters
*/
@@ -348,8 +346,6 @@ void __cpuinit start_secondary(void)
enable_8259A_irq(0);
}
- enable_APIC_timer();
-
/*
* The sibling maps must be set before turing the online map on for
* this cpu
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/time.c 2007-07-15 17:39:28.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c 2007-07-15 17:48:53.000000000 +0200
@@ -28,6 +28,8 @@
#include <linux/cpu.h>
#include <linux/kallsyms.h>
#include <linux/acpi.h>
+#include <linux/clockchips.h>
+
#ifdef CONFIG_ACPI
#include <acpi/achware.h> /* for PM timer frequency */
#include <acpi/acpi_bus.h>
@@ -46,12 +48,8 @@
#include <asm/nmi.h>
#include <asm/vgtod.h>
-static char *timename = NULL;
-
DEFINE_SPINLOCK(rtc_lock);
EXPORT_SYMBOL(rtc_lock);
-DEFINE_SPINLOCK(i8253_lock);
-EXPORT_SYMBOL(i8253_lock);
volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES;
@@ -194,6 +192,13 @@ static irqreturn_t timer_interrupt(int i
return IRQ_HANDLED;
}
+static irqreturn_t timer_event_interrupt(int irq, void *dev_id)
+{
+ global_clock_event->event_handler(global_clock_event);
+
+ return IRQ_HANDLED;
+}
+
unsigned long read_persistent_clock(void)
{
unsigned int year, mon, day, hour, min, sec;
@@ -291,63 +296,19 @@ static unsigned int __init tsc_calibrate
return pmc_now * tsc_khz / (tsc_now - tsc_start);
}
-static void __pit_init(int val, u8 mode)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&i8253_lock, flags);
- outb_p(mode, PIT_MODE);
- outb_p(val & 0xff, PIT_CH0); /* LSB */
- outb_p(val >> 8, PIT_CH0); /* MSB */
- spin_unlock_irqrestore(&i8253_lock, flags);
-}
-
-void __init pit_init(void)
-{
- __pit_init(LATCH, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
-}
-
-void pit_stop_interrupt(void)
-{
- __pit_init(0, 0x30); /* mode 0 */
-}
-
-void stop_timer_interrupt(void)
-{
- char *name;
- if (hpet_address) {
- name = "HPET";
- hpet_timer_stop_set_go(0);
- } else {
- name = "PIT";
- pit_stop_interrupt();
- }
- printk(KERN_INFO "timer: %s interrupt stopped.\n", name);
-}
-
static struct irqaction irq0 = {
- .handler = timer_interrupt,
- .flags = IRQF_DISABLED | IRQF_IRQPOLL,
+ .handler = timer_event_interrupt,
+ .flags = IRQF_DISABLED | IRQF_IRQPOLL | IRQF_NOBALANCING,
.mask = CPU_MASK_NONE,
.name = "timer"
};
void __init time_init(void)
{
- if (nohpet)
- hpet_address = 0;
-
- if (hpet_arch_init())
- hpet_address = 0;
+ if (!hpet_enable())
+ setup_pit_timer();
- if (hpet_use_timer) {
- /* set tick_nsec to use the proper rate for HPET */
- tick_nsec = TICK_NSEC_HPET;
- timename = "HPET";
- } else {
- pit_init();
- timename = "PIT";
- }
+ setup_irq(0, &irq0);
tsc_calibrate();
@@ -368,46 +329,4 @@ void __init time_init(void)
printk(KERN_INFO "time.c: Detected %d.%03d MHz processor.\n",
cpu_khz / 1000, cpu_khz % 1000);
init_tsc_clocksource();
-
- setup_irq(0, &irq0);
-}
-
-/*
- * sysfs support for the timer.
- */
-
-static int timer_suspend(struct sys_device *dev, pm_message_t state)
-{
- return 0;
}
-
-static int timer_resume(struct sys_device *dev)
-{
- if (hpet_address)
- hpet_reenable();
- else
- i8254_timer_resume();
- return 0;
-}
-
-static struct sysdev_class timer_sysclass = {
- .resume = timer_resume,
- .suspend = timer_suspend,
- set_kset_name("timer"),
-};
-
-/* XXX this sysfs stuff should probably go elsewhere later -john */
-static struct sys_device device_timer = {
- .id = 0,
- .cls = &timer_sysclass,
-};
-
-static int time_init_device(void)
-{
- int error = sysdev_class_register(&timer_sysclass);
- if (!error)
- error = sysdev_register(&device_timer);
- return error;
-}
-
-device_initcall(time_init_device);
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/hpet.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/hpet.h 2007-07-15 17:33:23.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/hpet.h 2007-07-15 17:43:10.000000000 +0200
@@ -1,18 +1,2 @@
-#ifndef _ASM_X8664_HPET_H
-#define _ASM_X8664_HPET_H 1
#include <asm-i386/hpet.h>
-
-#define HPET_TICK_RATE (HZ * 100000UL)
-
-extern int hpet_rtc_timer_init(void);
-extern int hpet_arch_init(void);
-extern int hpet_timer_stop_set_go(unsigned long tick);
-extern int hpet_reenable(void);
-extern unsigned int hpet_calibrate_tsc(void);
-
-extern int hpet_use_timer;
-extern unsigned long hpet_period;
-extern unsigned long hpet_tick;
-
-#endif
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 28/33] x86_64: remove now unused code
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (26 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 27/33] x86_64: convert to clock events Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 29/33] x86_64: cleanup apic.c after clock events switch Thomas Gleixner
` (4 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-remove-unused-code.patch --]
[-- Type: text/plain, Size: 19247 bytes --]
Remove the unused code after the switch to clock events.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 108 ----------
arch/x86_64/kernel/hpet.c | 444 ---------------------------------------------
arch/x86_64/kernel/time.c | 42 ----
include/asm-x86_64/apic.h | 6
include/asm-x86_64/proto.h | 7
5 files changed, 1 insertion(+), 606 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:43:10.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:52.000000000 +0200
@@ -42,9 +42,7 @@
int apic_mapped;
int apic_verbosity;
-int apic_runs_main_timer;
int apic_calibrate_pmtmr __initdata;
-
int disable_apic_timer __initdata;
/* Local APIC timer works in C2? */
@@ -130,15 +128,6 @@ static void lapic_timer_broadcast(cpumas
#endif
}
-/*
- * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
- * IPIs in place of local APIC timers
- */
-static cpumask_t timer_interrupt_broadcast_ipi_mask;
-
-/* Using APIC to generate smp_local_timer_interrupt? */
-int using_apic_timer __read_mostly = 0;
-
static void apic_pm_activate(void);
void apic_wait_icr_idle(void)
@@ -974,84 +963,6 @@ void __cpuinit setup_secondary_APIC_cloc
setup_APIC_timer();
}
-void disable_APIC_timer(void)
-{
- if (using_apic_timer) {
- unsigned long v;
-
- v = apic_read(APIC_LVTT);
- /*
- * When an illegal vector value (0-15) is written to an LVT
- * entry and delivery mode is Fixed, the APIC may signal an
- * illegal vector error, with out regard to whether the mask
- * bit is set or whether an interrupt is actually seen on input.
- *
- * Boot sequence might call this function when the LVTT has
- * '0' vector value. So make sure vector field is set to
- * valid value.
- */
- v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
- apic_write(APIC_LVTT, v);
- }
-}
-
-void enable_APIC_timer(void)
-{
- int cpu = smp_processor_id();
-
- if (using_apic_timer &&
- !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
- unsigned long v;
-
- v = apic_read(APIC_LVTT);
- apic_write(APIC_LVTT, v & ~APIC_LVT_MASKED);
- }
-}
-
-void switch_APIC_timer_to_ipi(void *cpumask)
-{
- cpumask_t mask = *(cpumask_t *)cpumask;
- int cpu = smp_processor_id();
-
- if (cpu_isset(cpu, mask) &&
- !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
- disable_APIC_timer();
- cpu_set(cpu, timer_interrupt_broadcast_ipi_mask);
- }
-}
-EXPORT_SYMBOL(switch_APIC_timer_to_ipi);
-
-void smp_send_timer_broadcast_ipi(void)
-{
- int cpu = smp_processor_id();
- cpumask_t mask;
-
- cpus_and(mask, cpu_online_map, timer_interrupt_broadcast_ipi_mask);
-
- if (cpu_isset(cpu, mask)) {
- cpu_clear(cpu, mask);
- add_pda(apic_timer_irqs, 1);
- smp_local_timer_interrupt();
- }
-
- if (!cpus_empty(mask)) {
- send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
- }
-}
-
-void switch_ipi_to_APIC_timer(void *cpumask)
-{
- cpumask_t mask = *(cpumask_t *)cpumask;
- int cpu = smp_processor_id();
-
- if (cpu_isset(cpu, mask) &&
- cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
- cpu_clear(cpu, timer_interrupt_broadcast_ipi_mask);
- enable_APIC_timer();
- }
-}
-EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
-
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
@@ -1199,7 +1110,6 @@ asmlinkage void smp_spurious_interrupt(v
v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1));
if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
ack_APIC_irq();
-
irq_exit();
}
@@ -1298,21 +1208,7 @@ static __init int setup_noapictimer(char
disable_apic_timer = 1;
return 1;
}
-
-static __init int setup_apicmaintimer(char *str)
-{
- apic_runs_main_timer = 1;
-
- return 1;
-}
-__setup("apicmaintimer", setup_apicmaintimer);
-
-static __init int setup_noapicmaintimer(char *str)
-{
- apic_runs_main_timer = -1;
- return 1;
-}
-__setup("noapicmaintimer", setup_noapicmaintimer);
+__setup("noapictimer", setup_noapictimer);
static __init int setup_apicpmtimer(char *s)
{
@@ -1322,5 +1218,3 @@ static __init int setup_apicpmtimer(char
}
__setup("apicpmtimer", setup_apicpmtimer);
-__setup("noapictimer", setup_noapictimer);
-
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/hpet.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/hpet.c 2007-07-15 17:34:42.000000000 +0200
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,444 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/mc146818rtc.h>
-#include <linux/time.h>
-#include <linux/clocksource.h>
-#include <linux/ioport.h>
-#include <linux/acpi.h>
-#include <linux/hpet.h>
-#include <asm/pgtable.h>
-#include <asm/vsyscall.h>
-#include <asm/timex.h>
-#include <asm/hpet.h>
-
-#define HPET_MASK 0xFFFFFFFF
-#define HPET_SHIFT 22
-
-/* FSEC = 10^-15 NSEC = 10^-9 */
-#define FSEC_PER_NSEC 1000000
-
-int nohpet __initdata;
-
-unsigned long hpet_address;
-unsigned long hpet_period; /* fsecs / HPET clock */
-unsigned long hpet_tick; /* HPET clocks / interrupt */
-
-int hpet_use_timer; /* Use counter of hpet for time keeping,
- * otherwise PIT
- */
-
-#ifdef CONFIG_HPET
-static __init int late_hpet_init(void)
-{
- struct hpet_data hd;
- unsigned int ntimer;
-
- if (!hpet_address)
- return 0;
-
- memset(&hd, 0, sizeof(hd));
-
- ntimer = hpet_readl(HPET_ID);
- ntimer = (ntimer & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT;
- ntimer++;
-
- /*
- * Register with driver.
- * Timer0 and Timer1 is used by platform.
- */
- hd.hd_phys_address = hpet_address;
- hd.hd_address = (void __iomem *)fix_to_virt(FIX_HPET_BASE);
- hd.hd_nirqs = ntimer;
- hd.hd_flags = HPET_DATA_PLATFORM;
- hpet_reserve_timer(&hd, 0);
-#ifdef CONFIG_HPET_EMULATE_RTC
- hpet_reserve_timer(&hd, 1);
-#endif
- hd.hd_irq[0] = HPET_LEGACY_8254;
- hd.hd_irq[1] = HPET_LEGACY_RTC;
- if (ntimer > 2) {
- struct hpet *hpet;
- struct hpet_timer *timer;
- int i;
-
- hpet = (struct hpet *) fix_to_virt(FIX_HPET_BASE);
- timer = &hpet->hpet_timers[2];
- for (i = 2; i < ntimer; timer++, i++)
- hd.hd_irq[i] = (timer->hpet_config &
- Tn_INT_ROUTE_CNF_MASK) >>
- Tn_INT_ROUTE_CNF_SHIFT;
-
- }
-
- hpet_alloc(&hd);
- return 0;
-}
-fs_initcall(late_hpet_init);
-#endif
-
-int hpet_timer_stop_set_go(unsigned long tick)
-{
- unsigned int cfg;
-
-/*
- * Stop the timers and reset the main counter.
- */
-
- cfg = hpet_readl(HPET_CFG);
- cfg &= ~(HPET_CFG_ENABLE | HPET_CFG_LEGACY);
- hpet_writel(cfg, HPET_CFG);
- hpet_writel(0, HPET_COUNTER);
- hpet_writel(0, HPET_COUNTER + 4);
-
-/*
- * Set up timer 0, as periodic with first interrupt to happen at hpet_tick,
- * and period also hpet_tick.
- */
- if (hpet_use_timer) {
- hpet_writel(HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL |
- HPET_TN_32BIT, HPET_T0_CFG);
- hpet_writel(hpet_tick, HPET_T0_CMP); /* next interrupt */
- hpet_writel(hpet_tick, HPET_T0_CMP); /* period */
- cfg |= HPET_CFG_LEGACY;
- }
-/*
- * Go!
- */
-
- cfg |= HPET_CFG_ENABLE;
- hpet_writel(cfg, HPET_CFG);
-
- return 0;
-}
-
-static cycle_t read_hpet(void)
-{
- return (cycle_t)hpet_readl(HPET_COUNTER);
-}
-
-static cycle_t __vsyscall_fn vread_hpet(void)
-{
- return readl((void __iomem *)fix_to_virt(VSYSCALL_HPET) + 0xf0);
-}
-
-struct clocksource clocksource_hpet = {
- .name = "hpet",
- .rating = 250,
- .read = read_hpet,
- .mask = (cycle_t)HPET_MASK,
- .mult = 0, /* set below */
- .shift = HPET_SHIFT,
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
- .vread = vread_hpet,
-};
-
-int hpet_arch_init(void)
-{
- unsigned int id;
- u64 tmp;
-
- if (!hpet_address)
- return -1;
- set_fixmap_nocache(FIX_HPET_BASE, hpet_address);
- __set_fixmap(VSYSCALL_HPET, hpet_address, PAGE_KERNEL_VSYSCALL_NOCACHE);
-
-/*
- * Read the period, compute tick and quotient.
- */
-
- id = hpet_readl(HPET_ID);
-
- if (!(id & HPET_ID_VENDOR) || !(id & HPET_ID_NUMBER))
- return -1;
-
- hpet_period = hpet_readl(HPET_PERIOD);
- if (hpet_period < 100000 || hpet_period > 100000000)
- return -1;
-
- hpet_tick = (FSEC_PER_TICK + hpet_period / 2) / hpet_period;
-
- hpet_use_timer = (id & HPET_ID_LEGSUP);
-
- /*
- * hpet period is in femto seconds per cycle
- * so we need to convert this to ns/cyc units
- * aproximated by mult/2^shift
- *
- * fsec/cyc * 1nsec/1000000fsec = nsec/cyc = mult/2^shift
- * fsec/cyc * 1ns/1000000fsec * 2^shift = mult
- * fsec/cyc * 2^shift * 1nsec/1000000fsec = mult
- * (fsec/cyc << shift)/1000000 = mult
- * (hpet_period << shift)/FSEC_PER_NSEC = mult
- */
- tmp = (u64)hpet_period << HPET_SHIFT;
- do_div(tmp, FSEC_PER_NSEC);
- clocksource_hpet.mult = (u32)tmp;
- clocksource_register(&clocksource_hpet);
-
- return hpet_timer_stop_set_go(hpet_tick);
-}
-
-int hpet_reenable(void)
-{
- return hpet_timer_stop_set_go(hpet_tick);
-}
-
-#ifdef CONFIG_HPET_EMULATE_RTC
-/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
- * is enabled, we support RTC interrupt functionality in software.
- * RTC has 3 kinds of interrupts:
- * 1) Update Interrupt - generate an interrupt, every sec, when RTC clock
- * is updated
- * 2) Alarm Interrupt - generate an interrupt at a specific time of day
- * 3) Periodic Interrupt - generate periodic interrupt, with frequencies
- * 2Hz-8192Hz (2Hz-64Hz for non-root user) (all freqs in powers of 2)
- * (1) and (2) above are implemented using polling at a frequency of
- * 64 Hz. The exact frequency is a tradeoff between accuracy and interrupt
- * overhead. (DEFAULT_RTC_INT_FREQ)
- * For (3), we use interrupts at 64Hz or user specified periodic
- * frequency, whichever is higher.
- */
-#include <linux/rtc.h>
-
-#define DEFAULT_RTC_INT_FREQ 64
-#define RTC_NUM_INTS 1
-
-static unsigned long UIE_on;
-static unsigned long prev_update_sec;
-
-static unsigned long AIE_on;
-static struct rtc_time alarm_time;
-
-static unsigned long PIE_on;
-static unsigned long PIE_freq = DEFAULT_RTC_INT_FREQ;
-static unsigned long PIE_count;
-
-static unsigned long hpet_rtc_int_freq; /* RTC interrupt frequency */
-static unsigned int hpet_t1_cmp; /* cached comparator register */
-
-int is_hpet_enabled(void)
-{
- return hpet_address != 0;
-}
-
-/*
- * Timer 1 for RTC, we do not use periodic interrupt feature,
- * even if HPET supports periodic interrupts on Timer 1.
- * The reason being, to set up a periodic interrupt in HPET, we need to
- * stop the main counter. And if we do that everytime someone diables/enables
- * RTC, we will have adverse effect on main kernel timer running on Timer 0.
- * So, for the time being, simulate the periodic interrupt in software.
- *
- * hpet_rtc_timer_init() is called for the first time and during subsequent
- * interuppts reinit happens through hpet_rtc_timer_reinit().
- */
-int hpet_rtc_timer_init(void)
-{
- unsigned int cfg, cnt;
- unsigned long flags;
-
- if (!is_hpet_enabled())
- return 0;
- /*
- * Set the counter 1 and enable the interrupts.
- */
- if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
- hpet_rtc_int_freq = PIE_freq;
- else
- hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
-
- local_irq_save(flags);
-
- cnt = hpet_readl(HPET_COUNTER);
- cnt += ((hpet_tick*HZ)/hpet_rtc_int_freq);
- hpet_writel(cnt, HPET_T1_CMP);
- hpet_t1_cmp = cnt;
-
- cfg = hpet_readl(HPET_T1_CFG);
- cfg &= ~HPET_TN_PERIODIC;
- cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
- hpet_writel(cfg, HPET_T1_CFG);
-
- local_irq_restore(flags);
-
- return 1;
-}
-
-static void hpet_rtc_timer_reinit(void)
-{
- unsigned int cfg, cnt, ticks_per_int, lost_ints;
-
- if (unlikely(!(PIE_on | AIE_on | UIE_on))) {
- cfg = hpet_readl(HPET_T1_CFG);
- cfg &= ~HPET_TN_ENABLE;
- hpet_writel(cfg, HPET_T1_CFG);
- return;
- }
-
- if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
- hpet_rtc_int_freq = PIE_freq;
- else
- hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
-
- /* It is more accurate to use the comparator value than current count.*/
- ticks_per_int = hpet_tick * HZ / hpet_rtc_int_freq;
- hpet_t1_cmp += ticks_per_int;
- hpet_writel(hpet_t1_cmp, HPET_T1_CMP);
-
- /*
- * If the interrupt handler was delayed too long, the write above tries
- * to schedule the next interrupt in the past and the hardware would
- * not interrupt until the counter had wrapped around.
- * So we have to check that the comparator wasn't set to a past time.
- */
- cnt = hpet_readl(HPET_COUNTER);
- if (unlikely((int)(cnt - hpet_t1_cmp) > 0)) {
- lost_ints = (cnt - hpet_t1_cmp) / ticks_per_int + 1;
- /* Make sure that, even with the time needed to execute
- * this code, the next scheduled interrupt has been moved
- * back to the future: */
- lost_ints++;
-
- hpet_t1_cmp += lost_ints * ticks_per_int;
- hpet_writel(hpet_t1_cmp, HPET_T1_CMP);
-
- if (PIE_on)
- PIE_count += lost_ints;
-
- if (printk_ratelimit())
- printk(KERN_WARNING "rtc: lost some interrupts at %ldHz.\n",
- hpet_rtc_int_freq);
- }
-}
-
-/*
- * The functions below are called from rtc driver.
- * Return 0 if HPET is not being used.
- * Otherwise do the necessary changes and return 1.
- */
-int hpet_mask_rtc_irq_bit(unsigned long bit_mask)
-{
- if (!is_hpet_enabled())
- return 0;
-
- if (bit_mask & RTC_UIE)
- UIE_on = 0;
- if (bit_mask & RTC_PIE)
- PIE_on = 0;
- if (bit_mask & RTC_AIE)
- AIE_on = 0;
-
- return 1;
-}
-
-int hpet_set_rtc_irq_bit(unsigned long bit_mask)
-{
- int timer_init_reqd = 0;
-
- if (!is_hpet_enabled())
- return 0;
-
- if (!(PIE_on | AIE_on | UIE_on))
- timer_init_reqd = 1;
-
- if (bit_mask & RTC_UIE) {
- UIE_on = 1;
- }
- if (bit_mask & RTC_PIE) {
- PIE_on = 1;
- PIE_count = 0;
- }
- if (bit_mask & RTC_AIE) {
- AIE_on = 1;
- }
-
- if (timer_init_reqd)
- hpet_rtc_timer_init();
-
- return 1;
-}
-
-int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec)
-{
- if (!is_hpet_enabled())
- return 0;
-
- alarm_time.tm_hour = hrs;
- alarm_time.tm_min = min;
- alarm_time.tm_sec = sec;
-
- return 1;
-}
-
-int hpet_set_periodic_freq(unsigned long freq)
-{
- if (!is_hpet_enabled())
- return 0;
-
- PIE_freq = freq;
- PIE_count = 0;
-
- return 1;
-}
-
-int hpet_rtc_dropped_irq(void)
-{
- if (!is_hpet_enabled())
- return 0;
-
- return 1;
-}
-
-irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
-{
- struct rtc_time curr_time;
- unsigned long rtc_int_flag = 0;
- int call_rtc_interrupt = 0;
-
- hpet_rtc_timer_reinit();
-
- if (UIE_on | AIE_on) {
- rtc_get_rtc_time(&curr_time);
- }
- if (UIE_on) {
- if (curr_time.tm_sec != prev_update_sec) {
- /* Set update int info, call real rtc int routine */
- call_rtc_interrupt = 1;
- rtc_int_flag = RTC_UF;
- prev_update_sec = curr_time.tm_sec;
- }
- }
- if (PIE_on) {
- PIE_count++;
- if (PIE_count >= hpet_rtc_int_freq/PIE_freq) {
- /* Set periodic int info, call real rtc int routine */
- call_rtc_interrupt = 1;
- rtc_int_flag |= RTC_PF;
- PIE_count = 0;
- }
- }
- if (AIE_on) {
- if ((curr_time.tm_sec == alarm_time.tm_sec) &&
- (curr_time.tm_min == alarm_time.tm_min) &&
- (curr_time.tm_hour == alarm_time.tm_hour)) {
- /* Set alarm int info, call real rtc int routine */
- call_rtc_interrupt = 1;
- rtc_int_flag |= RTC_AF;
- }
- }
- if (call_rtc_interrupt) {
- rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
- rtc_interrupt(rtc_int_flag, dev_id);
- }
- return IRQ_HANDLED;
-}
-#endif
-
-static int __init nohpet_setup(char *s)
-{
- nohpet = 1;
- return 1;
-}
-
-__setup("nohpet", nohpet_setup);
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/time.c 2007-07-15 17:43:10.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/time.c 2007-07-15 17:44:47.000000000 +0200
@@ -150,48 +150,6 @@ int update_persistent_clock(struct times
return set_rtc_mmss(now.tv_sec);
}
-void main_timer_handler(void)
-{
-/*
- * Here we are in the timer irq handler. We have irqs locally disabled (so we
- * don't need spin_lock_irqsave()) but we don't know if the timer_bh is running
- * on the other CPU, so we need a lock. We also need to lock the vsyscall
- * variables, because both do_timer() and us change them -arca+vojtech
- */
-
- write_seqlock(&xtime_lock);
-
-/*
- * Do the timer stuff.
- */
-
- do_timer(1);
-#ifndef CONFIG_SMP
- update_process_times(user_mode(get_irq_regs()));
-#endif
-
-/*
- * In the SMP case we use the local APIC timer interrupt to do the profiling,
- * except when we simulate SMP mode on a uniprocessor system, in that case we
- * have to call the local interrupt handler.
- */
-
- if (!using_apic_timer)
- smp_local_timer_interrupt();
-
- write_sequnlock(&xtime_lock);
-}
-
-static irqreturn_t timer_interrupt(int irq, void *dev_id)
-{
- if (apic_runs_main_timer > 1)
- return IRQ_HANDLED;
- main_timer_handler();
- if (using_apic_timer)
- smp_send_timer_broadcast_ipi();
- return IRQ_HANDLED;
-}
-
static irqreturn_t timer_event_interrupt(int irq, void *dev_id)
{
global_clock_event->event_handler(global_clock_event);
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/apic.h 2007-07-15 17:31:31.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h 2007-07-15 17:48:52.000000000 +0200
@@ -79,8 +79,6 @@ extern void smp_local_timer_interrupt (v
extern void setup_boot_APIC_clock (void);
extern void setup_secondary_APIC_clock (void);
extern int APIC_init_uniprocessor (void);
-extern void disable_APIC_timer(void);
-extern void enable_APIC_timer(void);
extern void setup_apic_routing(void);
extern void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector,
@@ -95,10 +93,6 @@ extern int apic_is_clustered_box(void);
#define K8_APIC_EXT_INT_MSG_EXT 0x7
#define K8_APIC_EXT_LVT_ENTRY_THRESHOLD 0
-void smp_send_timer_broadcast_ipi(void);
-void switch_APIC_timer_to_ipi(void *cpumask);
-void switch_ipi_to_APIC_timer(void *cpumask);
-
#define ARCH_APICTIMER_STOPS_ON_C3 1
extern unsigned boot_cpu_id;
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/proto.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/proto.h 2007-07-15 16:55:20.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/proto.h 2007-07-15 17:44:47.000000000 +0200
@@ -51,9 +51,6 @@ extern void reserve_bootmem_generic(unsi
extern void load_gs_index(unsigned gs);
-extern void stop_timer_interrupt(void);
-extern void main_timer_handler(void);
-
extern unsigned long end_pfn_map;
extern void show_trace(struct task_struct *, struct pt_regs *, unsigned long * rsp);
@@ -90,14 +87,10 @@ extern int timer_over_8254;
extern int gsi_irq_sharing(int gsi);
-extern void smp_local_timer_interrupt(void);
-
extern int force_mwait;
long do_arch_prctl(struct task_struct *task, int code, unsigned long addr);
-void i8254_timer_resume(void);
-
#define round_up(x,y) (((x) + (y) - 1) & ~((y)-1))
#define round_down(x,y) ((x) & ~((y)-1))
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 29/33] x86_64: cleanup apic.c after clock events switch
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (27 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 28/33] x86_64: remove now unused code Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 30/33] jiffies: remove unused macros Thomas Gleixner
` (3 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: x86_64-cleanup-apic-c.patch --]
[-- Type: text/plain, Size: 1461 bytes --]
Make variables static.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86_64/kernel/apic.c | 6 +++---
include/asm-x86_64/apic.h | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
Index: linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/x86_64/kernel/apic.c 2007-07-15 17:48:14.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/x86_64/kernel/apic.c 2007-07-15 17:48:22.000000000 +0200
@@ -40,10 +40,10 @@
#include <asm/hpet.h>
#include <asm/apic.h>
-int apic_mapped;
int apic_verbosity;
-int apic_calibrate_pmtmr __initdata;
-int disable_apic_timer __initdata;
+static int apic_mapped;
+static int apic_calibrate_pmtmr __initdata;
+static int disable_apic_timer __initdata;
/* Local APIC timer works in C2? */
int local_apic_timer_c2_ok;
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/apic.h 2007-07-15 17:48:14.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/apic.h 2007-07-15 17:48:22.000000000 +0200
@@ -19,7 +19,6 @@
extern int apic_verbosity;
extern int apic_runs_main_timer;
extern int ioapic_force;
-extern int apic_mapped;
/*
* Define the default level of output to be very little
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 30/33] jiffies: remove unused macros
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (28 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 29/33] x86_64: cleanup apic.c after clock events switch Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 31/33] ACPI: remove the now unused ifdef code Thomas Gleixner
` (2 subsequent siblings)
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: jiffies-remove-unused-macros.patch --]
[-- Type: text/plain, Size: 1527 bytes --]
From: Chris Wright <chrisw@sous-sol.org>
The x86 hpet cleanups allow removal of some unused macros.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/linux/jiffies.h | 6 ------
1 file changed, 6 deletions(-)
Index: linux-2.6.22-rc6-mm/include/linux/jiffies.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/linux/jiffies.h 2007-07-15 17:48:13.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/linux/jiffies.h 2007-07-15 17:48:22.000000000 +0200
@@ -36,8 +36,6 @@
/* LATCH is used in the interval timer and ftape setup. */
#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
-#define LATCH_HPET ((HPET_TICK_RATE + HZ/2) / HZ)
-
/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can
* improve accuracy by shifting LSH bits, hence calculating:
* (NOM << LSH) / DEN
@@ -53,13 +51,9 @@
/* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */
#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
-#define ACTHZ_HPET (SH_DIV (HPET_TICK_RATE, LATCH_HPET, 8))
-
/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */
#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
-#define TICK_NSEC_HPET (SH_DIV(1000000UL * 1000, ACTHZ_HPET, 8))
-
/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 31/33] ACPI: remove the now unused ifdef code
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (29 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 30/33] jiffies: remove unused macros Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 32/33] i386: Remove the useless #ifdef in i8253.h Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 33/33] i386/x8664: cleanup the shared hpet code Thomas Gleixner
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, john stultz
[-- Attachment #1: acpi-remove-the-useless-ifdef-code.patch --]
[-- Type: text/plain, Size: 1823 bytes --]
The conversion of x86-64 to clock events makes the
#ifdef CONFIG_GENERIC_CLOCKEVENTS
n the timer broadcast functions useless. Remove it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: john stultz <johnstul@us.ibm.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/acpi/processor_idle.c | 12 ------------
1 file changed, 12 deletions(-)
Index: linux-2.6.22-rc6-mm/drivers/acpi/processor_idle.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/drivers/acpi/processor_idle.c 2007-07-15 17:48:12.000000000 +0200
+++ linux-2.6.22-rc6-mm/drivers/acpi/processor_idle.c 2007-07-15 17:48:22.000000000 +0200
@@ -203,21 +203,12 @@ static void acpi_timer_check_state(int s
static void acpi_propagate_timer_broadcast(struct acpi_processor *pr)
{
-#ifdef CONFIG_GENERIC_CLOCKEVENTS
unsigned long reason;
reason = pr->power.timer_broadcast_on_state < INT_MAX ?
CLOCK_EVT_NOTIFY_BROADCAST_ON : CLOCK_EVT_NOTIFY_BROADCAST_OFF;
clockevents_notify(reason, &pr->id);
-#else
- cpumask_t mask = cpumask_of_cpu(pr->id);
-
- if (pr->power.timer_broadcast_on_state < INT_MAX)
- on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1);
- else
- on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1);
-#endif
}
/* Power(C) State timer broadcast control */
@@ -225,8 +216,6 @@ static void acpi_state_timer_broadcast(s
struct acpi_processor_cx *cx,
int broadcast)
{
-#ifdef CONFIG_GENERIC_CLOCKEVENTS
-
int state = cx - pr->power.states;
if (state >= pr->power.timer_broadcast_on_state) {
@@ -236,7 +225,6 @@ static void acpi_state_timer_broadcast(s
CLOCK_EVT_NOTIFY_BROADCAST_EXIT;
clockevents_notify(reason, &pr->id);
}
-#endif
}
#else
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 32/33] i386: Remove the useless #ifdef in i8253.h
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (30 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 31/33] ACPI: remove the now unused ifdef code Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 33/33] i386/x8664: cleanup the shared hpet code Thomas Gleixner
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: i386-pit-remove-the-useless-ifdefs.patch --]
[-- Type: text/plain, Size: 746 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/asm-i386/i8253.h | 4 ----
1 file changed, 4 deletions(-)
Index: linux-2.6.22-rc6-mm/include/asm-i386/i8253.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/i8253.h 2007-07-15 17:48:11.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/i8253.h 2007-07-15 17:48:22.000000000 +0200
@@ -8,12 +8,8 @@
extern spinlock_t i8253_lock;
-#ifdef CONFIG_GENERIC_CLOCKEVENTS
-
extern struct clock_event_device *global_clock_event;
extern void setup_pit_timer(void);
-#endif
-
#endif /* __ASM_I8253_H__ */
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* [patch-mm 33/33] i386/x8664: cleanup the shared hpet code
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
` (31 preceding siblings ...)
2007-07-15 16:11 ` [patch-mm 32/33] i386: Remove the useless #ifdef in i8253.h Thomas Gleixner
@ 2007-07-15 16:11 ` Thomas Gleixner
32 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-15 16:11 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen, Chris Wright
[-- Attachment #1: i386-hpet-sharing-optimize.patch --]
[-- Type: text/plain, Size: 2481 bytes --]
Remove hpet_readl/writel from vsyscall.h, where it does not belong
anyway. Use the hpet code itself.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/i386/kernel/hpet.c | 6 +-----
include/asm-i386/hpet.h | 2 ++
include/asm-x86_64/vsyscall.h | 3 ---
3 files changed, 3 insertions(+), 8 deletions(-)
Index: linux-2.6.22-rc6-mm/include/asm-i386/hpet.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-i386/hpet.h 2007-07-15 17:48:10.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-i386/hpet.h 2007-07-15 17:48:24.000000000 +0200
@@ -66,6 +66,7 @@
extern unsigned long hpet_address;
extern int is_hpet_enabled(void);
extern int hpet_enable(void);
+extern unsigned long hpet_readl(unsigned long a);
#ifdef CONFIG_HPET_EMULATE_RTC
@@ -85,6 +86,7 @@ extern irqreturn_t hpet_rtc_interrupt(in
#else
static inline int hpet_enable(void) { return 0; }
+static inline unsigned long hpet_readl(unsigned long a) { return 0; }
#endif /* CONFIG_HPET_TIMER */
#endif /* _I386_HPET_H */
Index: linux-2.6.22-rc6-mm/include/asm-x86_64/vsyscall.h
===================================================================
--- linux-2.6.22-rc6-mm.orig/include/asm-x86_64/vsyscall.h 2007-07-15 17:48:10.000000000 +0200
+++ linux-2.6.22-rc6-mm/include/asm-x86_64/vsyscall.h 2007-07-15 17:48:24.000000000 +0200
@@ -29,9 +29,6 @@ enum vsyscall_num {
#define VGETCPU_RDTSCP 1
#define VGETCPU_LSL 2
-#define hpet_readl(a) readl((const void __iomem *)fix_to_virt(FIX_HPET_BASE) + a)
-#define hpet_writel(d,a) writel(d, (void __iomem *)fix_to_virt(FIX_HPET_BASE) + a)
-
extern int __vgetcpu_mode;
extern volatile unsigned long __jiffies;
Index: linux-2.6.22-rc6-mm/arch/i386/kernel/hpet.c
===================================================================
--- linux-2.6.22-rc6-mm.orig/arch/i386/kernel/hpet.c 2007-07-15 17:48:10.000000000 +0200
+++ linux-2.6.22-rc6-mm/arch/i386/kernel/hpet.c 2007-07-15 17:48:24.000000000 +0200
@@ -24,11 +24,7 @@
unsigned long hpet_address;
static void __iomem *hpet_virt_address;
-/* Temporary hack. Cleanup after x86_64 clock events conversion */
-#undef hpet_readl
-#undef hpet_writel
-
-static inline unsigned long hpet_readl(unsigned long a)
+unsigned long hpet_readl(unsigned long a)
{
return readl(hpet_virt_address + a);
}
--
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [patch-mm 01/33] clockevents: Remove unused inline function
2007-07-15 16:10 ` [patch-mm 01/33] clockevents: Remove unused inline function Thomas Gleixner
@ 2007-07-17 12:33 ` Andi Kleen
2007-07-17 14:58 ` Thomas Gleixner
0 siblings, 1 reply; 38+ messages in thread
From: Andi Kleen @ 2007-07-17 12:33 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Andrew Morton
On Sunday 15 July 2007 18:10:42 Thomas Gleixner wrote:
> Index: linux-2.6.22-rc6-mm/include/linux/clockchips.h
> ===================================================================
> --- linux-2.6.22-rc6-mm.orig/include/linux/clockchips.h 2007-07-15 09:44:00.000000000 +0200
> +++ linux-2.6.22-rc6-mm/include/linux/clockchips.h 2007-07-15 17:49:11.000000000 +0200
> @@ -131,7 +131,6 @@ extern void clockevents_notify(unsigned
>
> #else
>
> -static inline void clockevents_resume_events(void) { }
> #define clockevents_notify(reason, arg) do { } while (0)
Unrelated. Surely you can just send?
-Andi
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [patch-mm 14/33] x86_64: Consolidate tsc calibration
2007-07-15 16:10 ` [patch-mm 14/33] x86_64: Consolidate tsc calibration Thomas Gleixner
@ 2007-07-17 12:51 ` Andi Kleen
2007-07-17 15:00 ` Thomas Gleixner
0 siblings, 1 reply; 38+ messages in thread
From: Andi Kleen @ 2007-07-17 12:51 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Andrew Morton, Chris Wright
On Sunday 15 July 2007 18:10:55 Thomas Gleixner wrote:
> Move the TSC calibration code to tsc.c. Reimplement it so the
> pm timer can be used as a reference as well.
Why is the pm timer better than the PIT for this?
I've had mixed success with the pmtimer too.
>
> Index: linux-2.6.22-rc6-mm/include/asm-i386/tsc.h
> ===================================================================
> --- linux-2.6.22-rc6-mm.orig/include/asm-i386/tsc.h 2007-07-15 17:26:45.000000000 +0200
> +++ linux-2.6.22-rc6-mm/include/asm-i386/tsc.h 2007-07-15 17:34:42.000000000 +0200
> @@ -71,4 +71,8 @@ extern void init_tsc_clocksource(void);
> extern void check_tsc_sync_source(int cpu);
> extern void check_tsc_sync_target(void);
>
> +#ifdef CONFIG_X86_64
> +extern void tsc_calibrate(void);
> +#endif
The ifdef shouldn't be needed?
-Andi
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [patch-mm 01/33] clockevents: Remove unused inline function
2007-07-17 12:33 ` Andi Kleen
@ 2007-07-17 14:58 ` Thomas Gleixner
0 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-17 14:58 UTC (permalink / raw)
To: Andi Kleen; +Cc: LKML, Ingo Molnar, Andrew Morton
On Tue, 2007-07-17 at 14:33 +0200, Andi Kleen wrote:
> > -static inline void clockevents_resume_events(void) { }
> > #define clockevents_notify(reason, arg) do { } while (0)
>
>
> Unrelated. Surely you can just send?
Sure.
tglx
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [patch-mm 14/33] x86_64: Consolidate tsc calibration
2007-07-17 12:51 ` Andi Kleen
@ 2007-07-17 15:00 ` Thomas Gleixner
0 siblings, 0 replies; 38+ messages in thread
From: Thomas Gleixner @ 2007-07-17 15:00 UTC (permalink / raw)
To: Andi Kleen; +Cc: LKML, Ingo Molnar, Andrew Morton, Chris Wright
On Tue, 2007-07-17 at 14:51 +0200, Andi Kleen wrote:
> On Sunday 15 July 2007 18:10:55 Thomas Gleixner wrote:
> > Move the TSC calibration code to tsc.c. Reimplement it so the
> > pm timer can be used as a reference as well.
>
> Why is the pm timer better than the PIT for this?
>
> I've had mixed success with the pmtimer too.
I had more consistent results on i386 with pmtimer than with the PIT
> >
> > Index: linux-2.6.22-rc6-mm/include/asm-i386/tsc.h
> > ===================================================================
> > --- linux-2.6.22-rc6-mm.orig/include/asm-i386/tsc.h 2007-07-15 17:26:45.000000000 +0200
> > +++ linux-2.6.22-rc6-mm/include/asm-i386/tsc.h 2007-07-15 17:34:42.000000000 +0200
> > @@ -71,4 +71,8 @@ extern void init_tsc_clocksource(void);
> > extern void check_tsc_sync_source(int cpu);
> > extern void check_tsc_sync_target(void);
> >
> > +#ifdef CONFIG_X86_64
> > +extern void tsc_calibrate(void);
> > +#endif
>
> The ifdef shouldn't be needed?
Yep. It can go.
tglx
^ permalink raw reply [flat|nested] 38+ messages in thread
end of thread, other threads:[~2007-07-17 15:00 UTC | newest]
Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-15 16:10 [patch-mm 00/33] x86_64 clock events conversion - V5 Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 01/33] clockevents: Remove unused inline function Thomas Gleixner
2007-07-17 12:33 ` Andi Kleen
2007-07-17 14:58 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 02/33] clockevents: Allow build w/o run-tine usage for migration purposes Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 03/33] i386: remove pit_interrupt_hook Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 04/33] X86_64: hpet tsc calibration fix broken smi detection logic Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 05/33] x86_64: Untangle asm/hpet.h from asm/timex.h Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 06/33] x86_64: use generic cmos update Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 07/33] x86_64: Use generic xtime init Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 08/33] x86_64: Remove dead code and other janitor work in tsc.c Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 09/33] x86_64: Fix APIC typo Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 10/33] x86_64: fiuxp pt_reqs leftovers Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 11/33] x86_64: share hpet.h with i386 Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 12/33] x86_64: apic.c coding style janitor work Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 13/33] x86_64: time.c white space wreckage cleanup Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 14/33] x86_64: Consolidate tsc calibration Thomas Gleixner
2007-07-17 12:51 ` Andi Kleen
2007-07-17 15:00 ` Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 15/33] i386: prepare sharing the hpet code with x86_64 Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 16/33] i386: hpet add x8664 bits Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 17/33] i386: prepare sharing the PIT code Thomas Gleixner
2007-07-15 16:10 ` [patch-mm 18/33] x86_64: use shared i8253.h Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 19/33] x86_64: prepare apic code for clock events Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 20/33] x86_64: remove pit synchronization Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 21/33] x86_64: Move apic calibration code around Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 22/33] x86_64: Remove APIC_DIVISOR Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 23/33] x86_64: apic change setup_APIC_timer calling convention Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 24/33] x86_64: remove nested irq disables Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 25/33] x86_64: prepare idle loop for dynamic ticks Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 26/33] x86_64: apic add clock event functions Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 27/33] x86_64: convert to clock events Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 28/33] x86_64: remove now unused code Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 29/33] x86_64: cleanup apic.c after clock events switch Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 30/33] jiffies: remove unused macros Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 31/33] ACPI: remove the now unused ifdef code Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 32/33] i386: Remove the useless #ifdef in i8253.h Thomas Gleixner
2007-07-15 16:11 ` [patch-mm 33/33] i386/x8664: cleanup the shared hpet code Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox