diff -u -r linux-2.6.22.7-old/arch/i386/Kconfig linux-2.6.22.7/arch/i386/Kconfig --- linux-2.6.22.7-old/arch/i386/Kconfig 2007-09-23 20:44:10.000000000 +0000 +++ linux-2.6.22.7/arch/i386/Kconfig 2007-09-23 22:15:57.000000000 +0000 @@ -362,6 +362,18 @@ to disable it. MCE support simply ignores non-MCE processors like the 386 and 486, so nearly everyone can say Y here. +config X86_TSC + bool "Use TSC as time source" if EMBEDDED + depends on X86 + default y + help + Uses the TSC (time stamp counter) in Pentium and newer systems as a + high resolution timer. If you are compiling a kernel for older 386 + and 486 systems that do not have this counter, you can say N here + to help reduce the size of your kernel. + + If unsure, say Y. + config X86_MCE_NONFATAL tristate "Check for non-fatal errors on AMD Athlon/Duron / Intel Pentium 4" depends on X86_MCE diff -u -r linux-2.6.22.7-old/arch/i386/kernel/Makefile linux-2.6.22.7/arch/i386/kernel/Makefile --- linux-2.6.22.7-old/arch/i386/kernel/Makefile 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/arch/i386/kernel/Makefile 2007-09-23 22:17:36.000000000 +0000 @@ -7,8 +7,9 @@ obj-y := process.o signal.o entry.o traps.o irq.o \ ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ pci-dma.o i386_ksyms.o i387.o bootflag.o e820.o\ - quirks.o i8237.o topology.o alternative.o i8253.o tsc.o + quirks.o i8237.o topology.o alternative.o i8253.o +obj-$(CONFIG_X86_TSC) += tsc.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += cpu/ obj-y += acpi/ diff -u -r linux-2.6.22.7-old/arch/i386/kernel/cpu/amd.c linux-2.6.22.7/arch/i386/kernel/cpu/amd.c --- linux-2.6.22.7-old/arch/i386/kernel/cpu/amd.c 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/arch/i386/kernel/cpu/amd.c 2007-09-23 23:39:11.000000000 +0000 @@ -117,6 +117,7 @@ break; } +#ifdef CONFIG_X86_TSC /* this test requires the presence of the TSC */ if ( c->x86_model == 6 && c->x86_mask == 1 ) { const int K6_BUG_LOOP = 1000000; int n; @@ -144,6 +145,7 @@ printk("probably OK (after B9730xxxx).\n"); printk(KERN_INFO "Please see http://membres.lycos.fr/poulot/k6bug.html\n"); } +#endif /* K6 with old style WHCR */ if (c->x86_model < 8 || diff -u -r linux-2.6.22.7-old/arch/i386/lib/delay.c linux-2.6.22.7/arch/i386/lib/delay.c --- linux-2.6.22.7-old/arch/i386/lib/delay.c 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/arch/i386/lib/delay.c 2007-09-23 23:15:42.000000000 +0000 @@ -37,6 +37,7 @@ :"0" (loops)); } +#ifdef CONFIG_X86_TSC /* TSC based delay: */ static void delay_tsc(unsigned long loops) { @@ -48,6 +49,7 @@ rdtscl(now); } while ((now-bclock) < loops); } +#endif /* * Since we calibrate only once at boot, this @@ -55,6 +57,7 @@ */ static void (*delay_fn)(unsigned long) = delay_loop; +#ifdef CONFIG_X86_TSC void use_tsc_delay(void) { delay_fn = delay_tsc; @@ -68,6 +71,7 @@ } return -1; } +#endif void __delay(unsigned long loops) { diff -u -r linux-2.6.22.7-old/include/asm-i386/cpufeature.h linux-2.6.22.7/include/asm-i386/cpufeature.h --- linux-2.6.22.7-old/include/asm-i386/cpufeature.h 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/include/asm-i386/cpufeature.h 2007-09-23 23:32:13.000000000 +0000 @@ -119,7 +119,11 @@ #define cpu_has_vme boot_cpu_has(X86_FEATURE_VME) #define cpu_has_de boot_cpu_has(X86_FEATURE_DE) #define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE) +#ifdef CONFIG_X86_TSC #define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC) +#else +#define cpu_has_tsc 0 +#endif #define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE) #define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE) #define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC) diff -u -r linux-2.6.22.7-old/include/asm-i386/delay.h linux-2.6.22.7/include/asm-i386/delay.h --- linux-2.6.22.7-old/include/asm-i386/delay.h 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/include/asm-i386/delay.h 2007-09-23 23:16:25.000000000 +0000 @@ -26,6 +26,10 @@ ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ __ndelay(n)) +#ifdef CONFIG_X86_TSC void use_tsc_delay(void); +#else +static inline void use_tsc_delay(void) { } +#endif #endif /* defined(_I386_DELAY_H) */ diff -u -r linux-2.6.22.7-old/include/asm-i386/msr.h linux-2.6.22.7/include/asm-i386/msr.h --- linux-2.6.22.7-old/include/asm-i386/msr.h 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/include/asm-i386/msr.h 2007-09-23 23:41:08.000000000 +0000 @@ -60,12 +60,14 @@ return err; } +#ifdef CONFIG_X86_TSC static inline unsigned long long native_read_tsc(void) { unsigned long long val; asm volatile("rdtsc" : "=A" (val)); return val; } +#endif static inline unsigned long long native_read_pmc(void) { @@ -117,6 +119,8 @@ __err; \ }) +#ifdef CONFIG_X86_TSC + #define rdtscl(low) \ ((low) = (u32)native_read_tsc()) @@ -125,6 +129,16 @@ #define write_tsc(val1,val2) wrmsr(0x10, val1, val2) +#else /* CONFIG_X86_TSC */ + +#define rdtscl(low) ((low) = 0) + +#define rdtscll(val) ((val) = 0) + +#define write_tsc(val1,val2) + +#endif /* CONFIG_X86_TSC */ + #define rdpmc(counter,low,high) \ do { \ u64 _l = native_read_pmc(); \ diff -u -r linux-2.6.22.7-old/include/asm-i386/processor.h linux-2.6.22.7/include/asm-i386/processor.h --- linux-2.6.22.7-old/include/asm-i386/processor.h 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/include/asm-i386/processor.h 2007-09-23 22:58:59.000000000 +0000 @@ -24,7 +24,11 @@ #include /* flag for disabling the tsc */ +#ifdef CONFIG_X86_TSC extern int tsc_disable; +#else +# define tsc_disable 1 +#endif struct desc_struct { unsigned long a,b; diff -u -r linux-2.6.22.7-old/include/asm-i386/timer.h linux-2.6.22.7/include/asm-i386/timer.h --- linux-2.6.22.7-old/include/asm-i386/timer.h 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/include/asm-i386/timer.h 2007-09-23 23:12:35.000000000 +0000 @@ -12,7 +12,12 @@ extern int timer_ack; extern int no_timer_check; extern int no_sync_cmos_clock; + +#ifdef CONFIG_X86_TSC extern int recalibrate_cpu_khz(void); +#else +static inline int recalibrate_cpu_khz(void) { return -ENODEV; } +#endif #ifndef CONFIG_PARAVIRT #define get_scheduled_cycles(val) rdtscll(val) diff -u -r linux-2.6.22.7-old/include/asm-i386/timex.h linux-2.6.22.7/include/asm-i386/timex.h --- linux-2.6.22.7-old/include/asm-i386/timex.h 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/include/asm-i386/timex.h 2007-09-23 23:20:42.000000000 +0000 @@ -15,8 +15,12 @@ # define CLOCK_TICK_RATE 1193182 /* Underlying HZ */ #endif - +#ifdef CONFIG_X86_TSC extern int read_current_timer(unsigned long *timer_value); +#else +static inline int read_current_timer(unsigned long *timer_value) { return -1; } +#endif + #define ARCH_HAS_READ_CURRENT_TIMER 1 #endif diff -u -r linux-2.6.22.7-old/include/asm-i386/tsc.h linux-2.6.22.7/include/asm-i386/tsc.h --- linux-2.6.22.7-old/include/asm-i386/tsc.h 2007-09-21 22:38:23.000000000 +0000 +++ linux-2.6.22.7/include/asm-i386/tsc.h 2007-09-23 23:36:29.000000000 +0000 @@ -25,7 +25,7 @@ return 0; #endif -#if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC) +#if defined(CONFIG_X86_GENERIC) && defined(CONFIG_X86_TSC) rdtscll(ret); #endif return ret; @@ -34,6 +34,7 @@ /* Like get_cycles, but make sure the CPU is synchronized. */ static __always_inline cycles_t get_cycles_sync(void) { +#ifdef CONFIG_X86_TSC unsigned long long ret; unsigned eax, edx; @@ -57,8 +58,12 @@ rdtscll(ret); return ret; +#else + return 0; +#endif } +#ifdef CONFIG_X86_TSC extern void tsc_init(void); extern void mark_tsc_unstable(char *reason); extern int unsynchronized_tsc(void); @@ -70,5 +75,15 @@ */ extern void check_tsc_sync_source(int cpu); extern void check_tsc_sync_target(void); +#else /* CONFIG_X86_TSC */ +/* effectively disable all calls to TSC functions. + * GCC should optimize these inline functions down to nothing. */ +static inline void tsc_init(void) { } +static inline void mark_tsc_unstable(char *reason) { } +static inline int unsynchronized_tsc(void) { return 1; } +static inline void init_tsc_clocksource(void) { } +static inline void check_tsc_sync_source(int cpu) { } +static inline void check_tsc_sync_target(void) { } +#endif /* CONFIG_X86_TSC */ #endif