diff options
-rw-r--r-- | arch/x86/kernel/time_64.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/tsc_32.c | 5 | ||||
-rw-r--r-- | include/linux/delay.h | 1 | ||||
-rw-r--r-- | init/calibrate.c | 36 |
4 files changed, 27 insertions, 17 deletions
diff --git a/arch/x86/kernel/time_64.c b/arch/x86/kernel/time_64.c index c737849e2ef7..12b4a71bd074 100644 --- a/arch/x86/kernel/time_64.c +++ b/arch/x86/kernel/time_64.c | |||
@@ -123,6 +123,8 @@ void __init time_init(void) | |||
123 | (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)) | 123 | (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)) |
124 | cpu_khz = calculate_cpu_khz(); | 124 | cpu_khz = calculate_cpu_khz(); |
125 | 125 | ||
126 | lpj_tsc = ((unsigned long)tsc_khz * 1000)/HZ; | ||
127 | |||
126 | if (unsynchronized_tsc()) | 128 | if (unsynchronized_tsc()) |
127 | mark_tsc_unstable("TSCs unsynchronized"); | 129 | mark_tsc_unstable("TSCs unsynchronized"); |
128 | 130 | ||
diff --git a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c index 068759db63dd..be729035b30b 100644 --- a/arch/x86/kernel/tsc_32.c +++ b/arch/x86/kernel/tsc_32.c | |||
@@ -401,6 +401,7 @@ static inline void check_geode_tsc_reliable(void) { } | |||
401 | void __init tsc_init(void) | 401 | void __init tsc_init(void) |
402 | { | 402 | { |
403 | int cpu; | 403 | int cpu; |
404 | u64 lpj; | ||
404 | 405 | ||
405 | if (!cpu_has_tsc || tsc_disabled) { | 406 | if (!cpu_has_tsc || tsc_disabled) { |
406 | /* Disable the TSC in case of !cpu_has_tsc */ | 407 | /* Disable the TSC in case of !cpu_has_tsc */ |
@@ -421,6 +422,10 @@ void __init tsc_init(void) | |||
421 | return; | 422 | return; |
422 | } | 423 | } |
423 | 424 | ||
425 | lpj = ((u64)tsc_khz * 1000); | ||
426 | do_div(lpj, HZ); | ||
427 | lpj_tsc = lpj; | ||
428 | |||
424 | printk("Detected %lu.%03lu MHz processor.\n", | 429 | printk("Detected %lu.%03lu MHz processor.\n", |
425 | (unsigned long)cpu_khz / 1000, | 430 | (unsigned long)cpu_khz / 1000, |
426 | (unsigned long)cpu_khz % 1000); | 431 | (unsigned long)cpu_khz % 1000); |
diff --git a/include/linux/delay.h b/include/linux/delay.h index 54552d21296e..01aec60590ab 100644 --- a/include/linux/delay.h +++ b/include/linux/delay.h | |||
@@ -41,6 +41,7 @@ static inline void ndelay(unsigned long x) | |||
41 | #define ndelay(x) ndelay(x) | 41 | #define ndelay(x) ndelay(x) |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | extern unsigned long lpj_tsc; | ||
44 | void calibrate_delay(void); | 45 | void calibrate_delay(void); |
45 | void msleep(unsigned int msecs); | 46 | void msleep(unsigned int msecs); |
46 | unsigned long msleep_interruptible(unsigned int msecs); | 47 | unsigned long msleep_interruptible(unsigned int msecs); |
diff --git a/init/calibrate.c b/init/calibrate.c index ecb3822d4f70..86286974dada 100644 --- a/init/calibrate.c +++ b/init/calibrate.c | |||
@@ -8,7 +8,9 @@ | |||
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/timex.h> | 10 | #include <linux/timex.h> |
11 | #include <linux/smp.h> | ||
11 | 12 | ||
13 | unsigned long lpj_tsc; | ||
12 | unsigned long preset_lpj; | 14 | unsigned long preset_lpj; |
13 | static int __init lpj_setup(char *str) | 15 | static int __init lpj_setup(char *str) |
14 | { | 16 | { |
@@ -108,6 +110,10 @@ static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;} | |||
108 | * This is the number of bits of precision for the loops_per_jiffy. Each | 110 | * This is the number of bits of precision for the loops_per_jiffy. Each |
109 | * bit takes on average 1.5/HZ seconds. This (like the original) is a little | 111 | * bit takes on average 1.5/HZ seconds. This (like the original) is a little |
110 | * better than 1% | 112 | * better than 1% |
113 | * For the boot cpu we can skip the delay calibration and assign it a value | ||
114 | * calculated based on the tsc frequency. | ||
115 | * For the rest of the CPUs we cannot assume that the tsc frequency is same as | ||
116 | * the cpu frequency, hence do the calibration for those. | ||
111 | */ | 117 | */ |
112 | #define LPS_PREC 8 | 118 | #define LPS_PREC 8 |
113 | 119 | ||
@@ -118,20 +124,20 @@ void __cpuinit calibrate_delay(void) | |||
118 | 124 | ||
119 | if (preset_lpj) { | 125 | if (preset_lpj) { |
120 | loops_per_jiffy = preset_lpj; | 126 | loops_per_jiffy = preset_lpj; |
121 | printk("Calibrating delay loop (skipped)... " | 127 | printk(KERN_INFO |
122 | "%lu.%02lu BogoMIPS preset\n", | 128 | "Calibrating delay loop (skipped) preset value.. "); |
123 | loops_per_jiffy/(500000/HZ), | 129 | } else if ((smp_processor_id() == 0) && lpj_tsc) { |
124 | (loops_per_jiffy/(5000/HZ)) % 100); | 130 | loops_per_jiffy = lpj_tsc; |
131 | printk(KERN_INFO | ||
132 | "Calibrating delay loop (skipped), " | ||
133 | "using tsc calculated value.. "); | ||
125 | } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) { | 134 | } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) { |
126 | printk("Calibrating delay using timer specific routine.. "); | 135 | printk(KERN_INFO |
127 | printk("%lu.%02lu BogoMIPS (lpj=%lu)\n", | 136 | "Calibrating delay using timer specific routine.. "); |
128 | loops_per_jiffy/(500000/HZ), | ||
129 | (loops_per_jiffy/(5000/HZ)) % 100, | ||
130 | loops_per_jiffy); | ||
131 | } else { | 137 | } else { |
132 | loops_per_jiffy = (1<<12); | 138 | loops_per_jiffy = (1<<12); |
133 | 139 | ||
134 | printk(KERN_DEBUG "Calibrating delay loop... "); | 140 | printk(KERN_INFO "Calibrating delay loop... "); |
135 | while ((loops_per_jiffy <<= 1) != 0) { | 141 | while ((loops_per_jiffy <<= 1) != 0) { |
136 | /* wait for "start of" clock tick */ | 142 | /* wait for "start of" clock tick */ |
137 | ticks = jiffies; | 143 | ticks = jiffies; |
@@ -161,12 +167,8 @@ void __cpuinit calibrate_delay(void) | |||
161 | if (jiffies != ticks) /* longer than 1 tick */ | 167 | if (jiffies != ticks) /* longer than 1 tick */ |
162 | loops_per_jiffy &= ~loopbit; | 168 | loops_per_jiffy &= ~loopbit; |
163 | } | 169 | } |
164 | |||
165 | /* Round the value and print it */ | ||
166 | printk("%lu.%02lu BogoMIPS (lpj=%lu)\n", | ||
167 | loops_per_jiffy/(500000/HZ), | ||
168 | (loops_per_jiffy/(5000/HZ)) % 100, | ||
169 | loops_per_jiffy); | ||
170 | } | 170 | } |
171 | 171 | printk(KERN_INFO "%lu.%02lu BogoMIPS (lpj=%lu)\n", | |
172 | loops_per_jiffy/(500000/HZ), | ||
173 | (loops_per_jiffy/(5000/HZ)) % 100, loops_per_jiffy); | ||
172 | } | 174 | } |