Commit ec66b46d authored by Brian Gerst's avatar Brian Gerst Committed by Linus Torvalds

[PATCH] remaining cpu_has cleanups

This patch cleans up the remaining direct tests against x86_capability.
      It moves the cpu_has_* macros to the more appropriate
cpufeature.h.  It also introduces the cpu_has() macro to test features
for individual cpus.
parent 7a1fc3a6
......@@ -68,11 +68,11 @@ static void __init intel_init_thermal(struct cpuinfo_x86 *c)
unsigned int cpu = smp_processor_id();
/* Thermal monitoring */
if (!test_bit(X86_FEATURE_ACPI, c->x86_capability))
if (!cpu_has(c, X86_FEATURE_ACPI))
return; /* -ENODEV */
/* Clock modulation */
if (!test_bit(X86_FEATURE_ACC, c->x86_capability))
if (!cpu_has(c, X86_FEATURE_ACC))
return; /* -ENODEV */
rdmsr(MSR_IA32_MISC_ENABLE, l, h);
......@@ -274,7 +274,7 @@ static void __init intel_mcheck_init(struct cpuinfo_x86 *c)
* Check for MCE support
*/
if( !test_bit(X86_FEATURE_MCE, c->x86_capability) )
if( !cpu_has(c, X86_FEATURE_MCE) )
return;
/*
......@@ -304,7 +304,7 @@ static void __init intel_mcheck_init(struct cpuinfo_x86 *c)
* Check for PPro style MCA
*/
if( !test_bit(X86_FEATURE_MCA, c->x86_capability) )
if( !cpu_has(c, X86_FEATURE_MCA) )
return;
/* Ok machine check is available */
......
......@@ -211,7 +211,7 @@ static void do_update_one(void *unused)
req->err = 1; /* assume update will fail on this cpu */
if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
test_bit(X86_FEATURE_IA64, c->x86_capability)){
cpu_has(c, X86_FEATURE_IA64)) {
printk(KERN_ERR "microcode: CPU%d not a capable Intel processor\n", cpu_num);
return;
}
......
......@@ -236,7 +236,7 @@ static int msr_open(struct inode *inode, struct file *file)
if ( !(cpu_online_map & (1UL << cpu)) )
return -ENXIO; /* No such CPU */
if ( !test_bit(X86_FEATURE_MSR, c->x86_capability) )
if ( !cpu_has(c, X86_FEATURE_MSR) )
return -EIO; /* MSR not supported */
return 0;
......
......@@ -387,7 +387,7 @@ static void set_mtrr_prepare_save (struct set_mtrr_context *ctxt)
return;
/* Save value of CR4 and clear Page Global Enable (bit 7) */
if ( test_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability) ) {
if ( cpu_has_pge ) {
ctxt->cr4val = read_cr4();
write_cr4(ctxt->cr4val & (unsigned char) ~(1<<7));
}
......@@ -448,7 +448,7 @@ static void set_mtrr_done (struct set_mtrr_context *ctxt)
write_cr0( read_cr0() & 0xbfffffff );
/* Restore value of CR4 */
if ( test_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability) )
if ( cpu_has_pge )
write_cr4(ctxt->cr4val);
/* Re-enable interrupts locally (if enabled previously) */
......@@ -2122,7 +2122,7 @@ static void __init centaur_mcr_init(void)
static int __init mtrr_setup(void)
{
if ( test_bit(X86_FEATURE_MTRR, boot_cpu_data.x86_capability) ) {
if ( cpu_has_mtrr ) {
/* Intel (P6) standard MTRRs */
mtrr_if = MTRR_IF_INTEL;
get_mtrr = intel_get_mtrr;
......@@ -2166,14 +2166,14 @@ static int __init mtrr_setup(void)
break;
}
} else if ( test_bit(X86_FEATURE_K6_MTRR, boot_cpu_data.x86_capability) ) {
} else if ( cpu_has_k6_mtrr ) {
/* Pre-Athlon (K6) AMD CPU MTRRs */
mtrr_if = MTRR_IF_AMD_K6;
get_mtrr = amd_get_mtrr;
set_mtrr_up = amd_set_mtrr_up;
size_or_mask = 0xfff00000; /* 32 bits */
size_and_mask = 0;
} else if ( test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) ) {
} else if ( cpu_has_cyrix_arr ) {
/* Cyrix ARRs */
mtrr_if = MTRR_IF_CYRIX_ARR;
get_mtrr = cyrix_get_arr;
......@@ -2182,7 +2182,7 @@ static int __init mtrr_setup(void)
cyrix_arr_init();
size_or_mask = 0xfff00000; /* 32 bits */
size_and_mask = 0;
} else if ( test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability) ) {
} else if ( cpu_has_centaur_mcr ) {
/* Centaur MCRs */
mtrr_if = MTRR_IF_CENTAUR_MCR;
get_mtrr = centaur_get_mcr;
......
......@@ -1226,7 +1226,7 @@ static int __init init_amd(struct cpuinfo_x86 *c)
* here.
*/
if (c->x86_model == 6 || c->x86_model == 7) {
if (!test_bit(X86_FEATURE_XMM, c->x86_capability)) {
if (!cpu_has(c, X86_FEATURE_XMM)) {
printk(KERN_INFO "Enabling disabled K7/SSE Support.\n");
rdmsr(MSR_K7_HWCR, l, h);
l &= ~0x00008000;
......@@ -2153,7 +2153,7 @@ static void __init init_intel(struct cpuinfo_x86 *c)
strcpy(c->x86_model_id, p);
#ifdef CONFIG_SMP
if (test_bit(X86_FEATURE_HT, c->x86_capability)) {
if (cpu_has(c, X86_FEATURE_HT)) {
extern int phys_proc_id[NR_CPUS];
u32 eax, ebx, ecx, edx;
......@@ -2322,8 +2322,7 @@ static int __init deep_magic_nexgen_probe(void)
static void __init squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
{
if( test_bit(X86_FEATURE_PN, c->x86_capability) &&
disable_x86_serial_nr ) {
if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr ) {
/* Disable processor serial number */
unsigned long lo,hi;
rdmsr(MSR_IA32_BBL_CR_CTL,lo,hi);
......@@ -2760,7 +2759,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
else
seq_printf(m, "stepping\t: unknown\n");
if ( test_bit(X86_FEATURE_TSC, c->x86_capability) ) {
if ( cpu_has(c, X86_FEATURE_TSC) ) {
seq_printf(m, "cpu MHz\t\t: %lu.%03lu\n",
cpu_khz / 1000, (cpu_khz % 1000));
}
......
......@@ -1087,8 +1087,7 @@ void __init smp_boot_cpus(void)
/*
* If we couldn't find a local APIC, then get out of here now!
*/
if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) &&
!test_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability)) {
if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) && !cpu_has_apic) {
printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
boot_cpu_physical_apicid);
printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
......@@ -1203,8 +1202,7 @@ void __init smp_boot_cpus(void)
* If Hyper-Threading is avaialble, construct cpu_sibling_map[], so
* that we can tell the sibling CPU efficiently.
*/
if (test_bit(X86_FEATURE_HT, boot_cpu_data.x86_capability)
&& smp_num_siblings > 1) {
if (cpu_has_ht && smp_num_siblings > 1) {
for (cpu = 0; cpu < NR_CPUS; cpu++)
cpu_sibling_map[cpu] = NO_PROC_ID;
......
......@@ -736,7 +736,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
int entropy = 0;
#if defined (__i386__) || defined (__x86_64__)
if (cpu_has_tsc)
if (cpu_has_tsc) {
__u32 high;
rdtsc(time, high);
num ^= high;
......
......@@ -186,7 +186,7 @@ static void __init check_config(void)
*/
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_GOOD_APIC)
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL
&& test_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability)
&& cpu_has_apic
&& boot_cpu_data.x86 == 5
&& boot_cpu_data.x86_model == 2
&& (boot_cpu_data.x86_mask < 6 || boot_cpu_data.x86_mask == 11))
......
......@@ -7,9 +7,6 @@
#ifndef __ASM_I386_CPUFEATURE_H
#define __ASM_I386_CPUFEATURE_H
/* Sample usage: CPU_FEATURE_P(cpu.x86_capability, FPU) */
#define CPU_FEATURE_P(CAP, FEATURE) test_bit(CAP, X86_FEATURE_##FEATURE ##_BIT)
#define NCAPINTS 4 /* Currently we have 4 32-bit words worth of info */
/* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
......@@ -65,6 +62,28 @@
#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
#define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
#define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
#define cpu_has_mp boot_cpu_has(X86_FEATURE_MP)
#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
#endif /* __ASM_I386_CPUFEATURE_H */
/*
......
......@@ -77,19 +77,6 @@ extern struct cpuinfo_x86 cpu_data[];
#define current_cpu_data boot_cpu_data
#endif
#define cpu_has_pge (test_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability))
#define cpu_has_pse (test_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability))
#define cpu_has_pae (test_bit(X86_FEATURE_PAE, boot_cpu_data.x86_capability))
#define cpu_has_tsc (test_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability))
#define cpu_has_de (test_bit(X86_FEATURE_DE, boot_cpu_data.x86_capability))
#define cpu_has_vme (test_bit(X86_FEATURE_VME, boot_cpu_data.x86_capability))
#define cpu_has_fxsr (test_bit(X86_FEATURE_FXSR, boot_cpu_data.x86_capability))
#define cpu_has_mmx (test_bit(X86_FEATURE_MMX, boot_cpu_data.x86_capability))
#define cpu_has_xmm (test_bit(X86_FEATURE_XMM, boot_cpu_data.x86_capability))
#define cpu_has_fpu (test_bit(X86_FEATURE_FPU, boot_cpu_data.x86_capability))
#define cpu_has_apic (test_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability))
#define cpu_has_mp (test_bit(X86_FEATURE_MP, boot_cpu_data.x86_capability))
extern char ignore_irq13;
extern void identify_cpu(struct cpuinfo_x86 *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment