aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/tsc_32.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/tsc_32.c')
-rw-r--r--arch/x86/kernel/tsc_32.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c
index d53b1040cbb7..ac8b85e18939 100644
--- a/arch/x86/kernel/tsc_32.c
+++ b/arch/x86/kernel/tsc_32.c
@@ -14,7 +14,7 @@
14 14
15#include "mach_timer.h" 15#include "mach_timer.h"
16 16
17static int tsc_enabled; 17static int tsc_disabled;
18 18
19/* 19/*
20 * On some systems the TSC frequency does not 20 * On some systems the TSC frequency does not
@@ -28,8 +28,8 @@ EXPORT_SYMBOL_GPL(tsc_khz);
28static int __init tsc_setup(char *str) 28static int __init tsc_setup(char *str)
29{ 29{
30 printk(KERN_WARNING "notsc: Kernel compiled with CONFIG_X86_TSC, " 30 printk(KERN_WARNING "notsc: Kernel compiled with CONFIG_X86_TSC, "
31 "cannot disable TSC completely.\n"); 31 "cannot disable TSC completely.\n");
32 mark_tsc_unstable("user disabled TSC"); 32 tsc_disabled = 1;
33 return 1; 33 return 1;
34} 34}
35#else 35#else
@@ -120,7 +120,7 @@ unsigned long long native_sched_clock(void)
120 * very important for it to be as fast as the platform 120 * very important for it to be as fast as the platform
121 * can achive it. ) 121 * can achive it. )
122 */ 122 */
123 if (unlikely(!tsc_enabled && !tsc_unstable)) 123 if (unlikely(tsc_disabled))
124 /* No locking but a rare wrong value is not a big deal: */ 124 /* No locking but a rare wrong value is not a big deal: */
125 return (jiffies_64 - INITIAL_JIFFIES) * (1000000000 / HZ); 125 return (jiffies_64 - INITIAL_JIFFIES) * (1000000000 / HZ);
126 126
@@ -321,7 +321,6 @@ void mark_tsc_unstable(char *reason)
321{ 321{
322 if (!tsc_unstable) { 322 if (!tsc_unstable) {
323 tsc_unstable = 1; 323 tsc_unstable = 1;
324 tsc_enabled = 0;
325 printk("Marking TSC unstable due to: %s.\n", reason); 324 printk("Marking TSC unstable due to: %s.\n", reason);
326 /* Can be called before registration */ 325 /* Can be called before registration */
327 if (clocksource_tsc.mult) 326 if (clocksource_tsc.mult)
@@ -335,7 +334,7 @@ EXPORT_SYMBOL_GPL(mark_tsc_unstable);
335static int __init dmi_mark_tsc_unstable(const struct dmi_system_id *d) 334static int __init dmi_mark_tsc_unstable(const struct dmi_system_id *d)
336{ 335{
337 printk(KERN_NOTICE "%s detected: marking TSC unstable.\n", 336 printk(KERN_NOTICE "%s detected: marking TSC unstable.\n",
338 d->ident); 337 d->ident);
339 tsc_unstable = 1; 338 tsc_unstable = 1;
340 return 0; 339 return 0;
341} 340}
@@ -402,14 +401,22 @@ void __init tsc_init(void)
402{ 401{
403 int cpu; 402 int cpu;
404 403
405 if (!cpu_has_tsc) 404 if (!cpu_has_tsc || tsc_disabled) {
405 /* Disable the TSC in case of !cpu_has_tsc */
406 tsc_disabled = 1;
406 return; 407 return;
408 }
407 409
408 cpu_khz = calculate_cpu_khz(); 410 cpu_khz = calculate_cpu_khz();
409 tsc_khz = cpu_khz; 411 tsc_khz = cpu_khz;
410 412
411 if (!cpu_khz) { 413 if (!cpu_khz) {
412 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;
413 return; 420 return;
414 } 421 }
415 422
@@ -439,8 +446,6 @@ void __init tsc_init(void)
439 if (check_tsc_unstable()) { 446 if (check_tsc_unstable()) {
440 clocksource_tsc.rating = 0; 447 clocksource_tsc.rating = 0;
441 clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS; 448 clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS;
442 } else 449 }
443 tsc_enabled = 1;
444
445 clocksource_register(&clocksource_tsc); 450 clocksource_register(&clocksource_tsc);
446} 451}