diff options
Diffstat (limited to 'arch/x86/kernel/tsc_32.c')
-rw-r--r-- | arch/x86/kernel/tsc_32.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c index 068759db63dd..774a5a83c296 100644 --- a/arch/x86/kernel/tsc_32.c +++ b/arch/x86/kernel/tsc_32.c | |||
@@ -14,7 +14,10 @@ | |||
14 | 14 | ||
15 | #include "mach_timer.h" | 15 | #include "mach_timer.h" |
16 | 16 | ||
17 | static int tsc_disabled; | 17 | /* native_sched_clock() is called before tsc_init(), so |
18 | we must start with the TSC soft disabled to prevent | ||
19 | erroneous rdtsc usage on !cpu_has_tsc processors */ | ||
20 | static int tsc_disabled = -1; | ||
18 | 21 | ||
19 | /* | 22 | /* |
20 | * On some systems the TSC frequency does not | 23 | * On some systems the TSC frequency does not |
@@ -283,7 +286,6 @@ core_initcall(cpufreq_tsc); | |||
283 | 286 | ||
284 | /* clock source code */ | 287 | /* clock source code */ |
285 | 288 | ||
286 | static unsigned long current_tsc_khz; | ||
287 | static struct clocksource clocksource_tsc; | 289 | static struct clocksource clocksource_tsc; |
288 | 290 | ||
289 | /* | 291 | /* |
@@ -402,25 +404,20 @@ void __init tsc_init(void) | |||
402 | { | 404 | { |
403 | int cpu; | 405 | int cpu; |
404 | 406 | ||
405 | if (!cpu_has_tsc || tsc_disabled) { | 407 | if (!cpu_has_tsc || tsc_disabled > 0) |
406 | /* Disable the TSC in case of !cpu_has_tsc */ | ||
407 | tsc_disabled = 1; | ||
408 | return; | 408 | return; |
409 | } | ||
410 | 409 | ||
411 | cpu_khz = calculate_cpu_khz(); | 410 | cpu_khz = calculate_cpu_khz(); |
412 | tsc_khz = cpu_khz; | 411 | tsc_khz = cpu_khz; |
413 | 412 | ||
414 | if (!cpu_khz) { | 413 | if (!cpu_khz) { |
415 | mark_tsc_unstable("could not calculate TSC khz"); | 414 | mark_tsc_unstable("could not calculate TSC khz"); |
416 | /* | ||
417 | * We need to disable the TSC completely in this case | ||
418 | * to prevent sched_clock() from using it. | ||
419 | */ | ||
420 | tsc_disabled = 1; | ||
421 | return; | 415 | return; |
422 | } | 416 | } |
423 | 417 | ||
418 | /* now allow native_sched_clock() to use rdtsc */ | ||
419 | tsc_disabled = 0; | ||
420 | |||
424 | printk("Detected %lu.%03lu MHz processor.\n", | 421 | printk("Detected %lu.%03lu MHz processor.\n", |
425 | (unsigned long)cpu_khz / 1000, | 422 | (unsigned long)cpu_khz / 1000, |
426 | (unsigned long)cpu_khz % 1000); | 423 | (unsigned long)cpu_khz % 1000); |
@@ -441,9 +438,8 @@ void __init tsc_init(void) | |||
441 | 438 | ||
442 | unsynchronized_tsc(); | 439 | unsynchronized_tsc(); |
443 | check_geode_tsc_reliable(); | 440 | check_geode_tsc_reliable(); |
444 | current_tsc_khz = tsc_khz; | 441 | clocksource_tsc.mult = clocksource_khz2mult(tsc_khz, |
445 | clocksource_tsc.mult = clocksource_khz2mult(current_tsc_khz, | 442 | clocksource_tsc.shift); |
446 | clocksource_tsc.shift); | ||
447 | /* lower the rating if we already know its unstable: */ | 443 | /* lower the rating if we already know its unstable: */ |
448 | if (check_tsc_unstable()) { | 444 | if (check_tsc_unstable()) { |
449 | clocksource_tsc.rating = 0; | 445 | clocksource_tsc.rating = 0; |