]> git.lizzy.rs Git - plan9front.git/commitdiff
disable tscticks in pc kernel (for now)
authorcinap_lenrek <cinap_lenrek@gmx.de>
Thu, 20 Jun 2013 00:30:17 +0000 (02:30 +0200)
committercinap_lenrek <cinap_lenrek@gmx.de>
Thu, 20 Jun 2013 00:30:17 +0000 (02:30 +0200)
doesnt seem to be reliable. also, separate tsc frequency measurement
and cpu loopconst measurement. turned out with *notsc=, the simplcycles()
calls would mess up loopconst.

sys/src/9/pc/archacpi.c
sys/src/9/pc/archmp.c
sys/src/9/pc/i8253.c

index 24b3245bca1dad780fc8499cbec935cadc90a572..298709847c487156be5a824506cf0790f939e1ea 100644 (file)
@@ -519,7 +519,5 @@ identify(void)
                return 1;
        if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0)
                return 1;
-       if(m->havetsc)
-               archacpi.fastclock = tscticks;
        return 0;
 }
index 23cf4fa6695ffeea3744c3177f4f50b8f47c6d75..354249f386c3f11cd0e2d13d60e9b24d8e7c1b9d 100644 (file)
@@ -395,8 +395,5 @@ identify(void)
                return 1;
        }
 
-       if(m->havetsc)
-               archmp.fastclock = tscticks;
-
        return 0;
 }
index 1ae22615fde2a3e1e2572e8719cd74bcde7def9f..46e59f5c476ab5a8fb05a938fbfd23e86147f6c7 100644 (file)
@@ -145,12 +145,10 @@ guesscpuhz(int aalcycles)
                 *
                 */
                outb(Tmode, Latch2);
-               cycles(&a);
                x = inb(T2cntr);
                x |= inb(T2cntr)<<8;
                aamloop(loops);
                outb(Tmode, Latch2);
-               cycles(&b);
                y = inb(T2cntr);
                y |= inb(T2cntr)<<8;
 
@@ -174,13 +172,25 @@ guesscpuhz(int aalcycles)
        cpufreq = (vlong)loops*((aalcycles*2*Freq)/x);
        m->loopconst = (cpufreq/1000)/aalcycles;        /* AAM+LOOP's for 1 ms */
 
-       /* a == b means virtualbox has confused us */
-       if(m->havetsc && b > a){
-               b -= a;
-               b *= 2*Freq;
-               b /= x;
-               m->cyclefreq = b;
-               cpufreq = b;
+       if(m->havetsc){
+               aamloop(loops);         /* warm up */
+               cycles(&a);
+               aamloop(loops);
+               cycles(&b);
+       
+               aamloop(loops);
+               cycles(&a);
+               aamloop(loops);
+               cycles(&b);
+
+               /* a == b means virtualbox has confused us */
+               if(b > a){
+                       b -= a;
+                       b *= 2*Freq;
+                       b /= x;
+                       m->cyclefreq = b;
+                       cpufreq = b;
+               }
        }
        m->cpuhz = cpufreq;