x86: Merge tsc_init and clocksource code
PATCH 4/5 x86: Merge tsc_init and clocksource code
[VMware, Inc. is providing the following patch to you under the terms of the GPL version 2 and no later version. This patch is provided as is, with no warranties or support. VMware disclaims all liability in connection with the use/inability to use this patch. Any use of the attached is considered acceptance of the above.]
From: Alok N Kataria <[email protected]>
Unify the clocksource code.
Unify the tsc_init code.
Signed-off-by Alok N Kataria <[email protected]>
Signed-off-by Dan Hecht <[email protected]>
---
arch/x86/kernel/Makefile | 2 arch/x86/kernel/time_64.c | 32 ------- arch/x86/kernel/tsc.c | 212 ++++++++++++++++++++++++++++++++++++++++++++- arch/x86/kernel/tsc_32.c | 188 ---------------------------------------- arch/x86/kernel/tsc_64.c | 106 ----------------------- include/asm-x86/apic.h | 7 + include/asm-x86/delay.h | 4 + include/asm-x86/time.h | 2 include/asm-x86/tsc.h | 1 9 files changed, 224 insertions(+), 330 deletions(-) delete mode 100644 arch/x86/kernel/tsc_32.c delete mode 100644 arch/x86/kernel/tsc_64.c
arch/x86/kernel/Makefile +1 -1
@@ -34,7 +34,7 @@ obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o obj-y += bootflag.o e820.o obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o obj-y += alternative.o i8253.o pci-nommu.o -obj-y += tsc_$(BITS).o io_delay.o rtc.o tsc.o +obj-y += tsc.o io_delay.o rtc.o obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o obj-y += process.o
arch/x86/kernel/time_64.c +2 -30
@@ -56,7 +56,7 @@ static irqreturn_t timer_event_interrupt(int irq, void *dev_id)/* calibrate_cpu is used on systems with fixed rate TSCs to determine * processor frequency */ #define TICK_COUNT 100000000 -static unsigned long __init calibrate_cpu (void ) +unsigned long __init calibrate_cpu (void ) {int tsc_start, tsc_now;int i, no_ctr_free;
@@ -114,41 +114,13 @@ void __init hpet_time_init(void)setup_irq (0 , &irq0); } -extern void set_cyc2ns_scale (unsigned long cpu_khz,int cpu); -void __init time_init (void ) { -int cpu; - - cpu_khz =calculate_cpu_khz (); - tsc_khz = cpu_khz; - -if (cpu_has (&boot_cpu_data,X86_FEATURE_CONSTANT_TSC ) && - (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD )) - cpu_khz =calibrate_cpu (); - - lpj_fine = ((unsigned long )tsc_khz *1000 )/HZ ; - -if (unsynchronized_tsc ()) -mark_tsc_unstable ("TSCs unsynchronized" ); - +tsc_init ();if (cpu_has (&boot_cpu_data,X86_FEATURE_RDTSCP )) vgetcpu_mode =VGETCPU_RDTSCP ;else vgetcpu_mode =VGETCPU_LSL ; -printk (KERN_INFO "time.c: Detected %d.%03d MHz processor.\n" , - cpu_khz /1000 , cpu_khz %1000 ); - -/* -* Secondary CPUs do not run through tsc_init(), so set up -* all the scale factors for all CPUs, assuming the same -* speed as the bootup CPU. (cpufreq notifiers will fix this -* up if their speed diverges) -*/ -for_each_possible_cpu (cpu) -set_cyc2ns_scale (cpu_khz, cpu); - -init_tsc_clocksource (); late_time_init =choose_time_init (); }
arch/x86/kernel/tsc.c +209 -3
239 lines not on this page · raw message
arch/x86/kernel/tsc_32.c deleted +0 -188
188 lines not on this page · raw message
arch/x86/kernel/tsc_64.c deleted +0 -106
106 lines not on this page · raw message
include/asm-x86/apic.h +6 -1
@@ -125,12 +125,17 @@ extern void enable_NMI_through_LVT0(void);*/ #ifdef CONFIG_X86_64 extern void early_init_lapic_mapping (void ); +extern int apic_is_clustered_box (void ); +#else +static inline int apic_is_clustered_box (void ) +{ +return 0 ; +}#endif extern u8 setup_APIC_eilvt_mce (u8 vector,u8 msg_type,u8 mask);extern u8 setup_APIC_eilvt_ibs (u8 vector,u8 msg_type,u8 mask); -extern int apic_is_clustered_box (void );#else /* !CONFIG_X86_LOCAL_APIC */ static inline void lapic_shutdown (void ) { }
include/asm-x86/delay.h +4 -0
@@ -26,6 +26,10 @@ extern void __delay(unsigned long loops); ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ __ndelay(n)) +#ifdef CONFIG_X86_32 void use_tsc_delay (void ); +#else +#define use_tsc_delay () {} +#endif #endif /* _ASM_X86_DELAY_H */
include/asm-x86/time.h +2 -0
@@ -56,4 +56,6 @@ static inline int native_set_wallclock(unsigned long nowtime)#endif /* CONFIG_PARAVIRT */ +extern unsigned long __init calibrate_cpu (void ); +#endif
include/asm-x86/tsc.h +0 -1
@@ -48,7 +48,6 @@ static __always_inline cycles_t vget_cycles(void)extern void tsc_init (void );extern void mark_tsc_unstable (char *reason);extern int unsynchronized_tsc (void ); -extern void init_tsc_clocksource (void );int check_tsc_unstable (void );/*