diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-06-25 06:36:55 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-25 06:36:55 -0400 |
commit | f6477cc76c73833a56e97f1fafc36a7ca92927e5 (patch) | |
tree | 9b4ca3d9fa63ea001d516834c8b2707094f3f711 /arch/x86/kernel/tsc_32.c | |
parent | fd2c17e1777d46cff14c25ea774a4d17459d188a (diff) | |
parent | 543cf4cb3fe6f6cae3651ba918b9c56200b257d0 (diff) |
Merge branch 'linus' into x86/timers
Diffstat (limited to 'arch/x86/kernel/tsc_32.c')
-rw-r--r-- | arch/x86/kernel/tsc_32.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c index ac8b85e18939..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 |
@@ -401,25 +404,20 @@ void __init tsc_init(void) | |||
401 | { | 404 | { |
402 | int cpu; | 405 | int cpu; |
403 | 406 | ||
404 | if (!cpu_has_tsc || tsc_disabled) { | 407 | if (!cpu_has_tsc || tsc_disabled > 0) |
405 | /* Disable the TSC in case of !cpu_has_tsc */ | ||
406 | tsc_disabled = 1; | ||
407 | return; | 408 | return; |
408 | } | ||
409 | 409 | ||
410 | cpu_khz = calculate_cpu_khz(); | 410 | cpu_khz = calculate_cpu_khz(); |
411 | tsc_khz = cpu_khz; | 411 | tsc_khz = cpu_khz; |
412 | 412 | ||
413 | if (!cpu_khz) { | 413 | if (!cpu_khz) { |
414 | mark_tsc_unstable("could not calculate TSC khz"); | 414 | mark_tsc_unstable("could not calculate TSC khz"); |
415 | /* | ||
416 | * We need to disable the TSC completely in this case | ||
417 | * to prevent sched_clock() from using it. | ||
418 | */ | ||
419 | tsc_disabled = 1; | ||
420 | return; | 415 | return; |
421 | } | 416 | } |
422 | 417 | ||
418 | /* now allow native_sched_clock() to use rdtsc */ | ||
419 | tsc_disabled = 0; | ||
420 | |||
423 | printk("Detected %lu.%03lu MHz processor.\n", | 421 | printk("Detected %lu.%03lu MHz processor.\n", |
424 | (unsigned long)cpu_khz / 1000, | 422 | (unsigned long)cpu_khz / 1000, |
425 | (unsigned long)cpu_khz % 1000); | 423 | (unsigned long)cpu_khz % 1000); |