diff options
Diffstat (limited to 'arch/i386/kernel/tsc.c')
-rw-r--r-- | arch/i386/kernel/tsc.c | 83 |
1 files changed, 37 insertions, 46 deletions
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c index 59222a04234b..875d8a6ecc02 100644 --- a/arch/i386/kernel/tsc.c +++ b/arch/i386/kernel/tsc.c | |||
@@ -184,34 +184,6 @@ int recalibrate_cpu_khz(void) | |||
184 | 184 | ||
185 | EXPORT_SYMBOL(recalibrate_cpu_khz); | 185 | EXPORT_SYMBOL(recalibrate_cpu_khz); |
186 | 186 | ||
187 | void __init tsc_init(void) | ||
188 | { | ||
189 | if (!cpu_has_tsc || tsc_disable) | ||
190 | goto out_no_tsc; | ||
191 | |||
192 | cpu_khz = calculate_cpu_khz(); | ||
193 | tsc_khz = cpu_khz; | ||
194 | |||
195 | if (!cpu_khz) | ||
196 | goto out_no_tsc; | ||
197 | |||
198 | printk("Detected %lu.%03lu MHz processor.\n", | ||
199 | (unsigned long)cpu_khz / 1000, | ||
200 | (unsigned long)cpu_khz % 1000); | ||
201 | |||
202 | set_cyc2ns_scale(cpu_khz); | ||
203 | use_tsc_delay(); | ||
204 | return; | ||
205 | |||
206 | out_no_tsc: | ||
207 | /* | ||
208 | * Set the tsc_disable flag if there's no TSC support, this | ||
209 | * makes it a fast flag for the kernel to see whether it | ||
210 | * should be using the TSC. | ||
211 | */ | ||
212 | tsc_disable = 1; | ||
213 | } | ||
214 | |||
215 | #ifdef CONFIG_CPU_FREQ | 187 | #ifdef CONFIG_CPU_FREQ |
216 | 188 | ||
217 | /* | 189 | /* |
@@ -381,28 +353,47 @@ static void __init check_geode_tsc_reliable(void) | |||
381 | static inline void check_geode_tsc_reliable(void) { } | 353 | static inline void check_geode_tsc_reliable(void) { } |
382 | #endif | 354 | #endif |
383 | 355 | ||
384 | static int __init init_tsc_clocksource(void) | 356 | |
357 | void __init tsc_init(void) | ||
385 | { | 358 | { |
359 | if (!cpu_has_tsc || tsc_disable) | ||
360 | goto out_no_tsc; | ||
386 | 361 | ||
387 | if (cpu_has_tsc && tsc_khz && !tsc_disable) { | 362 | cpu_khz = calculate_cpu_khz(); |
388 | /* check blacklist */ | 363 | tsc_khz = cpu_khz; |
389 | dmi_check_system(bad_tsc_dmi_table); | ||
390 | 364 | ||
391 | unsynchronized_tsc(); | 365 | if (!cpu_khz) |
392 | check_geode_tsc_reliable(); | 366 | goto out_no_tsc; |
393 | current_tsc_khz = tsc_khz; | ||
394 | clocksource_tsc.mult = clocksource_khz2mult(current_tsc_khz, | ||
395 | clocksource_tsc.shift); | ||
396 | /* lower the rating if we already know its unstable: */ | ||
397 | if (check_tsc_unstable()) { | ||
398 | clocksource_tsc.rating = 0; | ||
399 | clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS; | ||
400 | } | ||
401 | 367 | ||
402 | return clocksource_register(&clocksource_tsc); | 368 | printk("Detected %lu.%03lu MHz processor.\n", |
369 | (unsigned long)cpu_khz / 1000, | ||
370 | (unsigned long)cpu_khz % 1000); | ||
371 | |||
372 | set_cyc2ns_scale(cpu_khz); | ||
373 | use_tsc_delay(); | ||
374 | |||
375 | /* Check and install the TSC clocksource */ | ||
376 | dmi_check_system(bad_tsc_dmi_table); | ||
377 | |||
378 | unsynchronized_tsc(); | ||
379 | check_geode_tsc_reliable(); | ||
380 | current_tsc_khz = tsc_khz; | ||
381 | clocksource_tsc.mult = clocksource_khz2mult(current_tsc_khz, | ||
382 | clocksource_tsc.shift); | ||
383 | /* lower the rating if we already know its unstable: */ | ||
384 | if (check_tsc_unstable()) { | ||
385 | clocksource_tsc.rating = 0; | ||
386 | clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS; | ||
403 | } | 387 | } |
388 | clocksource_register(&clocksource_tsc); | ||
404 | 389 | ||
405 | return 0; | 390 | return; |
406 | } | ||
407 | 391 | ||
408 | module_init(init_tsc_clocksource); | 392 | out_no_tsc: |
393 | /* | ||
394 | * Set the tsc_disable flag if there's no TSC support, this | ||
395 | * makes it a fast flag for the kernel to see whether it | ||
396 | * should be using the TSC. | ||
397 | */ | ||
398 | tsc_disable = 1; | ||
399 | } | ||