git: 9front

Download patch

ref: f5b788310390df777cb0ed7d0d84a37b8e545e6f
parent: 30ecdef8da6f72b646657dda957112f59a5ad974
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Wed Jun 19 16:56:01 EDT 2013

plan9.ini: add *notsc= option to disable use of TSC as righ resolution clock

we previously used tsc only on cpu kernel. now that
we use it on terminal kernel too, there might be some
surprises ahead.

so make it possible to disable tsc for machines where
the tsc rate is not kept constant across cores or is
dynamically adjusted by power management.

--- a/sys/man/8/plan9.ini
+++ b/sys/man/8/plan9.ini
@@ -720,6 +720,11 @@
 Prints a summary of the multiprocessor APIC interrupt configuration.
 .SS \fL*nomsi=\fP
 Disables message signaled interrupts.
+.SS \fL*notsc=\fP
+Disables the use of the per processor timestamp counter registers
+as high resolution clock. This option is intended for machines where
+the timestamp counter rate is not constant across cores or is adjusted
+dynamically by power management.
 .SS \fL*pcimaxbno=value\fP
 This puts a limit on the maximum bus number probed
 on a PCI bus (default 7).
--- a/sys/src/9/pc/devarch.c
+++ b/sys/src/9/pc/devarch.c
@@ -797,7 +797,7 @@
 	/*
 	 *  if there is one, set tsc to a known value
 	 */
-	if(m->cpuiddx & Tsc){
+	if((m->cpuiddx & Tsc) != 0 && getconf("*notsc") == nil){
 		m->havetsc = 1;
 		cycles = _cycles;
 		if(m->cpuiddx & Cpumsr)
--