diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-06-25 06:30:10 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-25 06:30:10 -0400 |
commit | 28f73e51d0f64a5b896ad816ab8df6f3bcec5810 (patch) | |
tree | 8c51ad5ff74d6ef5d1d68121c9f9aadce836736e /arch/x86/kernel/tsc_32.c | |
parent | f3f3149f35b9195ef4b761b1353fc0766b5f53be (diff) | |
parent | 543cf4cb3fe6f6cae3651ba918b9c56200b257d0 (diff) |
Merge branch 'linus' into x86/delay
Conflicts:
arch/x86/kernel/tsc_32.c
Signed-off-by: Ingo Molnar <mingo@elte.hu>
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 048baab77268..0065426f1511 100644 --- a/arch/x86/kernel/tsc_32.c +++ b/arch/x86/kernel/tsc_32.c | |||
@@ -15,7 +15,10 @@ | |||
15 | 15 | ||
16 | #include "mach_timer.h" | 16 | #include "mach_timer.h" |
17 | 17 | ||
18 | static int tsc_disabled; | 18 | /* native_sched_clock() is called before tsc_init(), so |
19 | we must start with the TSC soft disabled to prevent | ||
20 | erroneous rdtsc usage on !cpu_has_tsc processors */ | ||
21 | static int tsc_disabled = -1; | ||
19 | 22 | ||
20 | /* | 23 | /* |
21 | * On some systems the TSC frequency does not | 24 | * On some systems the TSC frequency does not |
@@ -404,22 +407,14 @@ void __init tsc_init(void) | |||
404 | int cpu; | 407 | int cpu; |
405 | u64 lpj; | 408 | u64 lpj; |
406 | 409 | ||
407 | if (!cpu_has_tsc || tsc_disabled) { | 410 | if (!cpu_has_tsc || tsc_disabled > 0) |
408 | /* Disable the TSC in case of !cpu_has_tsc */ | ||
409 | tsc_disabled = 1; | ||
410 | return; | 411 | return; |
411 | } | ||
412 | 412 | ||
413 | cpu_khz = calculate_cpu_khz(); | 413 | cpu_khz = calculate_cpu_khz(); |
414 | tsc_khz = cpu_khz; | 414 | tsc_khz = cpu_khz; |
415 | 415 | ||
416 | if (!cpu_khz) { | 416 | if (!cpu_khz) { |
417 | mark_tsc_unstable("could not calculate TSC khz"); | 417 | mark_tsc_unstable("could not calculate TSC khz"); |
418 | /* | ||
419 | * We need to disable the TSC completely in this case | ||
420 | * to prevent sched_clock() from using it. | ||
421 | */ | ||
422 | tsc_disabled = 1; | ||
423 | return; | 418 | return; |
424 | } | 419 | } |
425 | 420 | ||
@@ -427,6 +422,9 @@ void __init tsc_init(void) | |||
427 | do_div(lpj, HZ); | 422 | do_div(lpj, HZ); |
428 | lpj_fine = lpj; | 423 | lpj_fine = lpj; |
429 | 424 | ||
425 | /* now allow native_sched_clock() to use rdtsc */ | ||
426 | tsc_disabled = 0; | ||
427 | |||
430 | printk("Detected %lu.%03lu MHz processor.\n", | 428 | printk("Detected %lu.%03lu MHz processor.\n", |
431 | (unsigned long)cpu_khz / 1000, | 429 | (unsigned long)cpu_khz / 1000, |
432 | (unsigned long)cpu_khz % 1000); | 430 | (unsigned long)cpu_khz % 1000); |