From 98d68ca74180ecc5c33c021c3a2662b4465e1e09 Mon Sep 17 00:00:00 2001 From: jkim Date: Thu, 10 Mar 2011 20:02:58 +0000 Subject: Deprecate rarely used tsc_is_broken. Instead, we zero out tsc_freq because it is almost always used with tsc_freq any way. --- sys/amd64/amd64/identcpu.c | 10 ++++++---- sys/amd64/amd64/prof_machdep.c | 2 +- sys/amd64/include/clock.h | 1 - sys/contrib/altq/altq/altq_subr.c | 11 ++++++----- sys/i386/i386/identcpu.c | 26 +++++++++++++++----------- sys/i386/i386/machdep.c | 2 +- sys/i386/include/clock.h | 1 - sys/i386/isa/prof_machdep.c | 2 +- sys/pc98/pc98/machdep.c | 2 +- sys/x86/isa/clock.c | 2 +- sys/x86/x86/tsc.c | 3 +-- 11 files changed, 33 insertions(+), 29 deletions(-) (limited to 'sys') diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c index cd28d59..c91d507 100644 --- a/sys/amd64/amd64/identcpu.c +++ b/sys/amd64/amd64/identcpu.c @@ -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: diff --git a/sys/amd64/amd64/prof_machdep.c b/sys/amd64/amd64/prof_machdep.c index 6c848df..23c566f 100644 --- a/sys/amd64/amd64/prof_machdep.c +++ b/sys/amd64/amd64/prof_machdep.c @@ -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 } diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h index 97ae7cc..95888ce 100644 --- a/sys/amd64/include/clock.h +++ b/sys/amd64/include/clock.h @@ -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); diff --git a/sys/contrib/altq/altq/altq_subr.c b/sys/contrib/altq/altq/altq_subr.c index e5b86f8..7d2fc77 100644 --- a/sys/contrib/altq/altq/altq_subr.c +++ b/sys/contrib/altq/altq/altq_subr.c @@ -79,10 +79,8 @@ #endif #if defined(__amd64__) || defined(__i386__) #include /* for pentium tsc */ +#if defined(__NetBSD__) || defined(__OpenBSD__) #include /* for CPUID_TSC */ -#ifdef __FreeBSD__ -#include /* for cpu_feature */ -#elif defined(__NetBSD__) || defined(__OpenBSD__) #include /* 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 } diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c index 3bcc416..cb923b5 100644 --- a/sys/i386/i386/identcpu.c +++ b/sys/i386/i386/identcpu.c @@ -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 diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 10a80bd..c5c0dfc 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1172,7 +1172,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate) #endif tsc2 -= tsc1; - if (tsc_freq != 0 && !tsc_is_broken) { + if (tsc_freq != 0) { *rate = tsc2 * 1000; return (0); } diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h index 3da123e..a351462 100644 --- a/sys/i386/include/clock.h +++ b/sys/i386/include/clock.h @@ -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); diff --git a/sys/i386/isa/prof_machdep.c b/sys/i386/isa/prof_machdep.c index 5c8d771..adeddf2 100644 --- a/sys/i386/isa/prof_machdep.c +++ b/sys/i386/isa/prof_machdep.c @@ -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 } diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 94e5aee..07b3b84 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1103,7 +1103,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate) #endif tsc2 -= tsc1; - if (tsc_freq != 0 && !tsc_is_broken) { + if (tsc_freq != 0) { *rate = tsc2 * 1000; return (0); } diff --git a/sys/x86/isa/clock.c b/sys/x86/isa/clock.c index 13698ef..cb34eb4 100644 --- a/sys/x86/isa/clock.c +++ b/sys/x86/isa/clock.c @@ -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(); diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 4591abb..052535b 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -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); } -- cgit v1.1