Deprecate rarely used tsc_is_broken. Instead, we zero out tsc_freq because

it is almost always used with tsc_freq any way.
This commit is contained in:
Jung-uk Kim 2011-03-10 20:02:58 +00:00
parent c28a98e948
commit bc34c87e81
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=219461
11 changed files with 33 additions and 29 deletions

View File

@ -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:

View File

@ -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
}

View File

@ -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);

View File

@ -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
}

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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);
}