]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'linus' into x86/timers
authorIngo Molnar <mingo@elte.hu>
Mon, 16 Jun 2008 09:20:57 +0000 (11:20 +0200)
committerIngo Molnar <mingo@elte.hu>
Mon, 16 Jun 2008 09:20:57 +0000 (11:20 +0200)
1  2 
arch/x86/kernel/tsc_32.c
arch/x86/kernel/tsc_64.c

diff --combined arch/x86/kernel/tsc_32.c
index d53b1040cbb77a46e6e27371e4411da6e8c1ae5c,068759db63ddebca0ed5561a1306a302dc38f474..ac8b85e18939ae4c5ad88159112a67d06af7b644
@@@ -14,7 -14,7 +14,7 @@@
  
  #include "mach_timer.h"
  
- static int tsc_enabled;
+ static int tsc_disabled;
  
  /*
   * On some systems the TSC frequency does not
@@@ -28,8 -28,8 +28,8 @@@ EXPORT_SYMBOL_GPL(tsc_khz)
  static int __init tsc_setup(char *str)
  {
        printk(KERN_WARNING "notsc: Kernel compiled with CONFIG_X86_TSC, "
-                               "cannot disable TSC completely.\n");
-       mark_tsc_unstable("user disabled TSC");
+              "cannot disable TSC completely.\n");
+       tsc_disabled = 1;
        return 1;
  }
  #else
@@@ -120,7 -120,7 +120,7 @@@ unsigned long long native_sched_clock(v
         *   very important for it to be as fast as the platform
         *   can achive it. )
         */
-       if (unlikely(!tsc_enabled && !tsc_unstable))
+       if (unlikely(tsc_disabled))
                /* No locking but a rare wrong value is not a big deal: */
                return (jiffies_64 - INITIAL_JIFFIES) * (1000000000 / HZ);
  
@@@ -283,6 -283,7 +283,6 @@@ core_initcall(cpufreq_tsc)
  
  /* clock source code */
  
 -static unsigned long current_tsc_khz;
  static struct clocksource clocksource_tsc;
  
  /*
@@@ -321,7 -322,6 +321,6 @@@ void mark_tsc_unstable(char *reason
  {
        if (!tsc_unstable) {
                tsc_unstable = 1;
-               tsc_enabled = 0;
                printk("Marking TSC unstable due to: %s.\n", reason);
                /* Can be called before registration */
                if (clocksource_tsc.mult)
@@@ -335,7 -335,7 +334,7 @@@ EXPORT_SYMBOL_GPL(mark_tsc_unstable)
  static int __init dmi_mark_tsc_unstable(const struct dmi_system_id *d)
  {
        printk(KERN_NOTICE "%s detected: marking TSC unstable.\n",
-                      d->ident);
+              d->ident);
        tsc_unstable = 1;
        return 0;
  }
@@@ -402,14 -402,22 +401,22 @@@ void __init tsc_init(void
  {
        int cpu;
  
-       if (!cpu_has_tsc)
+       if (!cpu_has_tsc || tsc_disabled) {
+               /* Disable the TSC in case of !cpu_has_tsc */
+               tsc_disabled = 1;
                return;
+       }
  
        cpu_khz = calculate_cpu_khz();
        tsc_khz = cpu_khz;
  
        if (!cpu_khz) {
                mark_tsc_unstable("could not calculate TSC khz");
+               /*
+                * We need to disable the TSC completely in this case
+                * to prevent sched_clock() from using it.
+                */
+               tsc_disabled = 1;
                return;
        }
  
  
        unsynchronized_tsc();
        check_geode_tsc_reliable();
 -      current_tsc_khz = tsc_khz;
 -      clocksource_tsc.mult = clocksource_khz2mult(current_tsc_khz,
 -                                                      clocksource_tsc.shift);
 +      clocksource_tsc.mult = clocksource_khz2mult(tsc_khz,
 +                                                  clocksource_tsc.shift);
        /* lower the rating if we already know its unstable: */
        if (check_tsc_unstable()) {
                clocksource_tsc.rating = 0;
                clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS;
-       } else
-               tsc_enabled = 1;
+       }
        clocksource_register(&clocksource_tsc);
  }
diff --combined arch/x86/kernel/tsc_64.c
index c19b0e273ef17070dd699cc36a7c40345fe26928,1784b8077a125e20bdc4bc38c85feca0ce01260f..9898fb01edfdba8be913462657fe08e473a8da25
@@@ -227,14 -227,14 +227,14 @@@ void __init tsc_calibrate(void
        /* hpet or pmtimer available ? */
        if (!hpet && !pm1 && !pm2) {
                printk(KERN_INFO "TSC calibrated against PIT\n");
-               return;
+               goto out;
        }
  
        /* Check, whether the sampling was disturbed by an SMI */
        if (tsc1 == ULONG_MAX || tsc2 == ULONG_MAX) {
                printk(KERN_WARNING "TSC calibration disturbed by SMI, "
                       "using PIT calibration result\n");
-               return;
+               goto out;
        }
  
        tsc2 = (tsc2 - tsc1) * 1000000L;
        if (hpet) {
                printk(KERN_INFO "TSC calibrated against HPET\n");
                if (hpet2 < hpet1)
 -                      hpet2 += 0x100000000;
 +                      hpet2 += 0x100000000UL;
                hpet2 -= hpet1;
                tsc1 = (hpet2 * hpet_readl(HPET_PERIOD)) / 1000000;
        } else {
  
        tsc_khz = tsc2 / tsc1;
  
+ out:
        for_each_possible_cpu(cpu)
                set_cyc2ns_scale(tsc_khz, cpu);
  }