Commit b41e2939 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86_64: 386/x86-64 Further AMD dual core fixes

- Remove duplicated ifdef
- Make core_id match what Intel uses
- Initialize phys_proc_id correctly for non DC case
- Handle non power of two core numbers.

Fixes for both i386 and x86-64
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 b39c4fab
...@@ -195,7 +195,7 @@ static void __init init_amd(struct cpuinfo_x86 *c) ...@@ -195,7 +195,7 @@ static void __init init_amd(struct cpuinfo_x86 *c)
c->x86_num_cores = 1; c->x86_num_cores = 1;
} }
#ifdef CONFIG_X86_SMP #ifdef CONFIG_X86_HT
/* /*
* On a AMD dual core setup the lower bits of the APIC id * On a AMD dual core setup the lower bits of the APIC id
* distingush the cores. Assumes number of cores is a power * distingush the cores. Assumes number of cores is a power
...@@ -203,8 +203,11 @@ static void __init init_amd(struct cpuinfo_x86 *c) ...@@ -203,8 +203,11 @@ static void __init init_amd(struct cpuinfo_x86 *c)
*/ */
if (c->x86_num_cores > 1) { if (c->x86_num_cores > 1) {
int cpu = smp_processor_id(); int cpu = smp_processor_id();
/* Fix up the APIC ID following AMD specifications. */ unsigned bits = 0;
cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1); while ((1 << bits) < c->x86_num_cores)
bits++;
cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1);
phys_proc_id[cpu] >>= bits;
printk(KERN_INFO "CPU %d(%d) -> Core %d\n", printk(KERN_INFO "CPU %d(%d) -> Core %d\n",
cpu, c->x86_num_cores, cpu_core_id[cpu]); cpu, c->x86_num_cores, cpu_core_id[cpu]);
} }
......
...@@ -244,11 +244,8 @@ static void __init early_cpu_detect(void) ...@@ -244,11 +244,8 @@ static void __init early_cpu_detect(void)
early_intel_workaround(c); early_intel_workaround(c);
#ifdef CONFIG_SMP
#ifdef CONFIG_X86_HT #ifdef CONFIG_X86_HT
phys_proc_id[smp_processor_id()] = phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
#endif
cpu_core_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
#endif #endif
} }
......
...@@ -719,7 +719,6 @@ static void __init display_cacheinfo(struct cpuinfo_x86 *c) ...@@ -719,7 +719,6 @@ static void __init display_cacheinfo(struct cpuinfo_x86 *c)
} }
} }
#ifdef CONFIG_SMP
/* /*
* On a AMD dual core setup the lower bits of the APIC id distingush the cores. * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
* Assumes number of cores is a power of two. * Assumes number of cores is a power of two.
...@@ -729,16 +728,24 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c) ...@@ -729,16 +728,24 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
int cpu = smp_processor_id(); int cpu = smp_processor_id();
int node = 0; int node = 0;
unsigned bits;
if (c->x86_num_cores == 1) if (c->x86_num_cores == 1)
return; return;
/* Fix up the APIC ID following the AMD specification. */
cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1); bits = 0;
while ((1 << bits) < c->x86_num_cores)
bits++;
/* Low order bits define the core id (index of core in socket) */
cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1);
/* Convert the APIC ID into the socket ID */
phys_proc_id[cpu] >>= bits;
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
/* When an ACPI SRAT table is available use the mappings from SRAT /* When an ACPI SRAT table is available use the mappings from SRAT
instead. */ instead. */
if (acpi_numa <= 0) { if (acpi_numa <= 0) {
node = cpu_core_id[cpu]; node = phys_proc_id[cpu];
if (!node_online(node)) if (!node_online(node))
node = first_node(node_online_map); node = first_node(node_online_map);
cpu_to_node[cpu] = node; cpu_to_node[cpu] = node;
...@@ -746,18 +753,11 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c) ...@@ -746,18 +753,11 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
node = cpu_to_node[cpu]; node = cpu_to_node[cpu];
} }
#endif #endif
/* For now: - better than BAD_APIC_ID at least*/
phys_proc_id[cpu] = cpu_core_id[cpu];
printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n", printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
cpu, c->x86_num_cores, node, cpu_core_id[cpu]); cpu, c->x86_num_cores, node, cpu_core_id[cpu]);
#endif #endif
} }
#else
static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
{
}
#endif
static int __init init_amd(struct cpuinfo_x86 *c) static int __init init_amd(struct cpuinfo_x86 *c)
{ {
...@@ -963,8 +963,7 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c) ...@@ -963,8 +963,7 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c)
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
phys_proc_id[smp_processor_id()] = phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
cpu_core_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
#endif #endif
} }
......
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