disable tscticks in pc kernel (for now)

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.
This commit is contained in:
cinap_lenrek 2013-06-20 02:30:17 +02:00
parent 8da4c8dcde
commit 17da3e3ff4
3 changed files with 19 additions and 14 deletions

View file

@ -519,7 +519,5 @@ identify(void)
return 1; return 1;
if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0) if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0)
return 1; return 1;
if(m->havetsc)
archacpi.fastclock = tscticks;
return 0; return 0;
} }

View file

@ -395,8 +395,5 @@ identify(void)
return 1; return 1;
} }
if(m->havetsc)
archmp.fastclock = tscticks;
return 0; return 0;
} }

View file

@ -145,12 +145,10 @@ guesscpuhz(int aalcycles)
* *
*/ */
outb(Tmode, Latch2); outb(Tmode, Latch2);
cycles(&a);
x = inb(T2cntr); x = inb(T2cntr);
x |= inb(T2cntr)<<8; x |= inb(T2cntr)<<8;
aamloop(loops); aamloop(loops);
outb(Tmode, Latch2); outb(Tmode, Latch2);
cycles(&b);
y = inb(T2cntr); y = inb(T2cntr);
y |= inb(T2cntr)<<8; y |= inb(T2cntr)<<8;
@ -174,13 +172,25 @@ guesscpuhz(int aalcycles)
cpufreq = (vlong)loops*((aalcycles*2*Freq)/x); cpufreq = (vlong)loops*((aalcycles*2*Freq)/x);
m->loopconst = (cpufreq/1000)/aalcycles; /* AAM+LOOP's for 1 ms */ m->loopconst = (cpufreq/1000)/aalcycles; /* AAM+LOOP's for 1 ms */
/* a == b means virtualbox has confused us */ if(m->havetsc){
if(m->havetsc && b > a){ aamloop(loops); /* warm up */
b -= a; cycles(&a);
b *= 2*Freq; aamloop(loops);
b /= x; cycles(&b);
m->cyclefreq = b;
cpufreq = 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; m->cpuhz = cpufreq;