Commit 95e5e682 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86-64: Clean up cpuid level detection

Small cleanup: save the CPUID level once instead of regetting it all the time.
Needed for some other patches.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 398120be
...@@ -637,7 +637,7 @@ static int __init get_model_name(struct cpuinfo_x86 *c) ...@@ -637,7 +637,7 @@ static int __init get_model_name(struct cpuinfo_x86 *c)
{ {
unsigned int *v; unsigned int *v;
if (cpuid_eax(0x80000000) < 0x80000004) if (c->x86_cpuid_level < 0x80000004)
return 0; return 0;
v = (unsigned int *) c->x86_model_id; v = (unsigned int *) c->x86_model_id;
...@@ -653,7 +653,7 @@ static void __init display_cacheinfo(struct cpuinfo_x86 *c) ...@@ -653,7 +653,7 @@ static void __init display_cacheinfo(struct cpuinfo_x86 *c)
{ {
unsigned int n, dummy, eax, ebx, ecx, edx; unsigned int n, dummy, eax, ebx, ecx, edx;
n = cpuid_eax(0x80000000); n = c->x86_cpuid_level;
if (n >= 0x80000005) { if (n >= 0x80000005) {
cpuid(0x80000005, &dummy, &ebx, &ecx, &edx); cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
...@@ -713,7 +713,7 @@ static int __init init_amd(struct cpuinfo_x86 *c) ...@@ -713,7 +713,7 @@ static int __init init_amd(struct cpuinfo_x86 *c)
} }
display_cacheinfo(c); display_cacheinfo(c);
if (cpuid_eax(0x80000000) >= 0x80000008) { if (c->x86_cpuid_level >= 0x80000008) {
c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1; c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
if (c->x86_num_cores & (c->x86_num_cores - 1)) if (c->x86_num_cores & (c->x86_num_cores - 1))
c->x86_num_cores = 1; c->x86_num_cores = 1;
...@@ -804,7 +804,7 @@ static void __init init_intel(struct cpuinfo_x86 *c) ...@@ -804,7 +804,7 @@ static void __init init_intel(struct cpuinfo_x86 *c)
unsigned n; unsigned n;
init_intel_cacheinfo(c); init_intel_cacheinfo(c);
n = cpuid_eax(0x80000000); n = c->x86_cpuid_level;
if (n >= 0x80000008) { if (n >= 0x80000008) {
unsigned eax = cpuid_eax(0x80000008); unsigned eax = cpuid_eax(0x80000008);
c->x86_virt_bits = (eax >> 8) & 0xff; c->x86_virt_bits = (eax >> 8) & 0xff;
...@@ -850,6 +850,7 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c) ...@@ -850,6 +850,7 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c)
c->x86_cache_alignment = c->x86_clflush_size; c->x86_cache_alignment = c->x86_clflush_size;
c->x86_num_cores = 1; c->x86_num_cores = 1;
c->x86_apicid = c == &boot_cpu_data ? 0 : c - cpu_data; c->x86_apicid = c == &boot_cpu_data ? 0 : c - cpu_data;
c->x86_cpuid_level = 0;
memset(&c->x86_capability, 0, sizeof c->x86_capability); memset(&c->x86_capability, 0, sizeof c->x86_capability);
/* Get vendor name */ /* Get vendor name */
...@@ -896,6 +897,7 @@ void __init identify_cpu(struct cpuinfo_x86 *c) ...@@ -896,6 +897,7 @@ void __init identify_cpu(struct cpuinfo_x86 *c)
/* AMD-defined flags: level 0x80000001 */ /* AMD-defined flags: level 0x80000001 */
xlvl = cpuid_eax(0x80000000); xlvl = cpuid_eax(0x80000000);
c->x86_cpuid_level = xlvl;
if ((xlvl & 0xffff0000) == 0x80000000) { if ((xlvl & 0xffff0000) == 0x80000000) {
if (xlvl >= 0x80000001) { if (xlvl >= 0x80000001) {
c->x86_capability[1] = cpuid_edx(0x80000001); c->x86_capability[1] = cpuid_edx(0x80000001);
...@@ -908,6 +910,7 @@ void __init identify_cpu(struct cpuinfo_x86 *c) ...@@ -908,6 +910,7 @@ void __init identify_cpu(struct cpuinfo_x86 *c)
/* Transmeta-defined flags: level 0x80860001 */ /* Transmeta-defined flags: level 0x80860001 */
xlvl = cpuid_eax(0x80860000); xlvl = cpuid_eax(0x80860000);
if ((xlvl & 0xffff0000) == 0x80860000) { if ((xlvl & 0xffff0000) == 0x80860000) {
/* Don't set x86_cpuid_level here for now to not confuse. */
if (xlvl >= 0x80860001) if (xlvl >= 0x80860001)
c->x86_capability[2] = cpuid_edx(0x80860001); c->x86_capability[2] = cpuid_edx(0x80860001);
} }
......
...@@ -64,6 +64,7 @@ struct cpuinfo_x86 { ...@@ -64,6 +64,7 @@ struct cpuinfo_x86 {
__u8 x86_num_cores; __u8 x86_num_cores;
__u8 x86_apicid; __u8 x86_apicid;
__u32 x86_power; __u32 x86_power;
__u32 x86_cpuid_level; /* Max CPUID function supported */
unsigned long loops_per_jiffy; unsigned long loops_per_jiffy;
} ____cacheline_aligned; } ____cacheline_aligned;
......
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