Author: jkim
Date: Thu Mar 10 20:02:58 2011
New Revision: 219461
URL: http://svn.freebsd.org/changeset/base/219461

Log:
  Deprecate rarely used tsc_is_broken.  Instead, we zero out tsc_freq because
  it is almost always used with tsc_freq any way.

Modified:
  head/sys/amd64/amd64/identcpu.c
  head/sys/amd64/amd64/prof_machdep.c
  head/sys/amd64/include/clock.h
  head/sys/contrib/altq/altq/altq_subr.c
  head/sys/i386/i386/identcpu.c
  head/sys/i386/i386/machdep.c
  head/sys/i386/include/clock.h
  head/sys/i386/isa/prof_machdep.c
  head/sys/pc98/pc98/machdep.c
  head/sys/x86/isa/clock.c
  head/sys/x86/x86/tsc.c

Modified: head/sys/amd64/amd64/identcpu.c
==============================================================================
--- head/sys/amd64/amd64/identcpu.c     Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/amd64/amd64/identcpu.c     Thu Mar 10 20:02:58 2011        
(r219461)
@@ -193,10 +193,12 @@ printcpuinfo(void)
        printf("%s (", cpu_model);
        switch(cpu_class) {
        case CPUCLASS_K8:
-               hw_clockrate = (tsc_freq + 5000) / 1000000;
-               printf("%jd.%02d-MHz ",
-                      (intmax_t)(tsc_freq + 4999) / 1000000,
-                      (u_int)((tsc_freq + 4999) / 10000) % 100);
+               if (tsc_freq != 0) {
+                       hw_clockrate = (tsc_freq + 5000) / 1000000;
+                       printf("%jd.%02d-MHz ",
+                              (intmax_t)(tsc_freq + 4999) / 1000000,
+                              (u_int)((tsc_freq + 4999) / 10000) % 100);
+               }
                printf("K8");
                break;
        default:

Modified: head/sys/amd64/amd64/prof_machdep.c
==============================================================================
--- head/sys/amd64/amd64/prof_machdep.c Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/amd64/amd64/prof_machdep.c Thu Mar 10 20:02:58 2011        
(r219461)
@@ -319,7 +319,7 @@ startguprof(gp)
        if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
                cputime_clock = CPUTIME_CLOCK_I8254;
 #if defined(I586_CPU) || defined(I686_CPU)
-               if (tsc_freq != 0 && !tsc_is_broken && mp_ncpus == 1)
+               if (tsc_freq != 0 && mp_ncpus == 1)
                        cputime_clock = CPUTIME_CLOCK_TSC;
 #endif
        }

Modified: head/sys/amd64/include/clock.h
==============================================================================
--- head/sys/amd64/include/clock.h      Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/amd64/include/clock.h      Thu Mar 10 20:02:58 2011        
(r219461)
@@ -18,7 +18,6 @@ extern int    clkintr_pending;
 extern u_int   i8254_freq;
 extern int     i8254_max_count;
 extern uint64_t        tsc_freq;
-extern int     tsc_is_broken;
 extern int     tsc_is_invariant;
 
 void   i8254_init(void);

Modified: head/sys/contrib/altq/altq/altq_subr.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_subr.c      Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/contrib/altq/altq/altq_subr.c      Thu Mar 10 20:02:58 2011        
(r219461)
@@ -79,10 +79,8 @@
 #endif
 #if defined(__amd64__) || defined(__i386__)
 #include <machine/cpufunc.h>           /* for pentium tsc */
+#if defined(__NetBSD__) || defined(__OpenBSD__)
 #include <machine/specialreg.h>                /* for CPUID_TSC */
-#ifdef __FreeBSD__
-#include <machine/md_var.h>            /* for cpu_feature */
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
 #include <machine/cpu.h>               /* for cpu_feature */
 #endif
 #endif /* __amd64 || __i386__ */
@@ -928,8 +926,11 @@ init_machclk_setup(void)
 #endif
 #if defined(__amd64__) || defined(__i386__)
        /* check if TSC is available */
-       if (machclk_usepcc == 1 && ((cpu_feature & CPUID_TSC) == 0 ||
-           tsc_is_broken))
+#ifdef __FreeBSD__
+       if (tsc_freq == 0)
+#else
+       if ((cpu_feature & CPUID_TSC) == 0)
+#endif
                machclk_usepcc = 0;
 #endif
 }

Modified: head/sys/i386/i386/identcpu.c
==============================================================================
--- head/sys/i386/i386/identcpu.c       Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/i386/i386/identcpu.c       Thu Mar 10 20:02:58 2011        
(r219461)
@@ -372,7 +372,7 @@ printcpuinfo(void)
                        break;
                case 0x500:
                        strcat(cpu_model, "K5 model 0");
-                       tsc_is_broken = 1;
+                       tsc_freq = 0;
                        break;
                case 0x510:
                        strcat(cpu_model, "K5 model 1");
@@ -570,7 +570,7 @@ printcpuinfo(void)
                switch (cpu_id & 0xff0) {
                case 0x540:
                        strcpy(cpu_model, "IDT WinChip C6");
-                       tsc_is_broken = 1;
+                       tsc_freq = 0;
                        break;
                case 0x580:
                        strcpy(cpu_model, "IDT WinChip 2");
@@ -607,7 +607,7 @@ printcpuinfo(void)
                case 0x540:
                        strcpy(cpu_model, "Geode SC1100");
                        cpu = CPU_GEODE1100;
-                       tsc_is_broken = 1;
+                       tsc_freq = 0;
                        break;
                default:
                        strcpy(cpu_model, "Geode/NSC unknown");
@@ -640,19 +640,23 @@ printcpuinfo(void)
 #endif
 #if defined(I586_CPU)
        case CPUCLASS_586:
-               hw_clockrate = (tsc_freq + 5000) / 1000000;
-               printf("%jd.%02d-MHz ",
-                      (intmax_t)(tsc_freq + 4999) / 1000000,
-                      (u_int)((tsc_freq + 4999) / 10000) % 100);
+               if (tsc_freq != 0) {
+                       hw_clockrate = (tsc_freq + 5000) / 1000000;
+                       printf("%jd.%02d-MHz ",
+                              (intmax_t)(tsc_freq + 4999) / 1000000,
+                              (u_int)((tsc_freq + 4999) / 10000) % 100);
+               }
                printf("586");
                break;
 #endif
 #if defined(I686_CPU)
        case CPUCLASS_686:
-               hw_clockrate = (tsc_freq + 5000) / 1000000;
-               printf("%jd.%02d-MHz ",
-                      (intmax_t)(tsc_freq + 4999) / 1000000,
-                      (u_int)((tsc_freq + 4999) / 10000) % 100);
+               if (tsc_freq != 0) {
+                       hw_clockrate = (tsc_freq + 5000) / 1000000;
+                       printf("%jd.%02d-MHz ",
+                              (intmax_t)(tsc_freq + 4999) / 1000000,
+                              (u_int)((tsc_freq + 4999) / 10000) % 100);
+               }
                printf("686");
                break;
 #endif

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c        Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/i386/i386/machdep.c        Thu Mar 10 20:02:58 2011        
(r219461)
@@ -1172,7 +1172,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 #endif
 
        tsc2 -= tsc1;
-       if (tsc_freq != 0 && !tsc_is_broken) {
+       if (tsc_freq != 0) {
                *rate = tsc2 * 1000;
                return (0);
        }

Modified: head/sys/i386/include/clock.h
==============================================================================
--- head/sys/i386/include/clock.h       Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/i386/include/clock.h       Thu Mar 10 20:02:58 2011        
(r219461)
@@ -18,7 +18,6 @@ extern int    clkintr_pending;
 extern u_int   i8254_freq;
 extern int     i8254_max_count;
 extern uint64_t        tsc_freq;
-extern int     tsc_is_broken;
 extern int     tsc_is_invariant;
 
 void   i8254_init(void);

Modified: head/sys/i386/isa/prof_machdep.c
==============================================================================
--- head/sys/i386/isa/prof_machdep.c    Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/i386/isa/prof_machdep.c    Thu Mar 10 20:02:58 2011        
(r219461)
@@ -289,7 +289,7 @@ startguprof(gp)
        if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
                cputime_clock = CPUTIME_CLOCK_I8254;
 #if defined(I586_CPU) || defined(I686_CPU)
-               if (tsc_freq != 0 && !tsc_is_broken && mp_ncpus == 1)
+               if (tsc_freq != 0 && mp_ncpus == 1)
                        cputime_clock = CPUTIME_CLOCK_TSC;
 #endif
        }

Modified: head/sys/pc98/pc98/machdep.c
==============================================================================
--- head/sys/pc98/pc98/machdep.c        Thu Mar 10 19:50:12 2011        
(r219460)
+++ head/sys/pc98/pc98/machdep.c        Thu Mar 10 20:02:58 2011        
(r219461)
@@ -1103,7 +1103,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 #endif
 
        tsc2 -= tsc1;
-       if (tsc_freq != 0 && !tsc_is_broken) {
+       if (tsc_freq != 0) {
                *rate = tsc2 * 1000;
                return (0);
        }

Modified: head/sys/x86/isa/clock.c
==============================================================================
--- head/sys/x86/isa/clock.c    Thu Mar 10 19:50:12 2011        (r219460)
+++ head/sys/x86/isa/clock.c    Thu Mar 10 20:02:58 2011        (r219461)
@@ -261,7 +261,7 @@ DELAY(int n)
        static int state = 0;
 #endif
 
-       if (tsc_freq != 0 && !tsc_is_broken) {
+       if (tsc_freq != 0) {
                uint64_t start, end, now;
 
                sched_pin();

Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c      Thu Mar 10 19:50:12 2011        (r219460)
+++ head/sys/x86/x86/tsc.c      Thu Mar 10 20:02:58 2011        (r219461)
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
 #include "cpufreq_if.h"
 
 uint64_t       tsc_freq;
-int            tsc_is_broken;
 int            tsc_is_invariant;
 int            tsc_present;
 static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag;
@@ -181,7 +180,7 @@ init_TSC_tc(void)
                tsc_timecounter.tc_quality = -100;
 #endif
 
-       if (tsc_freq != 0 && !tsc_is_broken) {
+       if (tsc_freq != 0) {
                tsc_timecounter.tc_frequency = tsc_freq;
                tc_init(&tsc_timecounter);
        }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to