aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2005-05-20 17:27:55 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-20 18:48:20 -0400
commitb41e29398a873945d02e0009ce7e57608fdb4042 (patch)
treedc2e4cfd8cb20ce788bc341e9d734adbcebedd27 /arch
parentb39c4fab259b216148e705344a892c96efe1946d (diff)
[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: Andi Kleen <ak@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/i386/kernel/cpu/amd.c9
-rw-r--r--arch/i386/kernel/cpu/common.c5
-rw-r--r--arch/x86_64/kernel/setup.c25
3 files changed, 19 insertions, 20 deletions
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index fa34a06c0d7..73aeaf5a9d4 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -195,7 +195,7 @@ static void __init init_amd(struct cpuinfo_x86 *c)
195 c->x86_num_cores = 1; 195 c->x86_num_cores = 1;
196 } 196 }
197 197
198#ifdef CONFIG_X86_SMP 198#ifdef CONFIG_X86_HT
199 /* 199 /*
200 * On a AMD dual core setup the lower bits of the APIC id 200 * On a AMD dual core setup the lower bits of the APIC id
201 * distingush the cores. Assumes number of cores is a power 201 * distingush the cores. Assumes number of cores is a power
@@ -203,8 +203,11 @@ static void __init init_amd(struct cpuinfo_x86 *c)
203 */ 203 */
204 if (c->x86_num_cores > 1) { 204 if (c->x86_num_cores > 1) {
205 int cpu = smp_processor_id(); 205 int cpu = smp_processor_id();
206 /* Fix up the APIC ID following AMD specifications. */ 206 unsigned bits = 0;
207 cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1); 207 while ((1 << bits) < c->x86_num_cores)
208 bits++;
209 cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1);
210 phys_proc_id[cpu] >>= bits;
208 printk(KERN_INFO "CPU %d(%d) -> Core %d\n", 211 printk(KERN_INFO "CPU %d(%d) -> Core %d\n",
209 cpu, c->x86_num_cores, cpu_core_id[cpu]); 212 cpu, c->x86_num_cores, cpu_core_id[cpu]);
210 } 213 }
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 11e6e6f23fa..d199e525680 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -244,11 +244,8 @@ static void __init early_cpu_detect(void)
244 244
245 early_intel_workaround(c); 245 early_intel_workaround(c);
246 246
247#ifdef CONFIG_SMP
248#ifdef CONFIG_X86_HT 247#ifdef CONFIG_X86_HT
249 phys_proc_id[smp_processor_id()] = 248 phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
250#endif
251 cpu_core_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
252#endif 249#endif
253} 250}
254 251
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index b9fd0252c27..99f038ede23 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -719,7 +719,6 @@ static void __init display_cacheinfo(struct cpuinfo_x86 *c)
719 } 719 }
720} 720}
721 721
722#ifdef CONFIG_SMP
723/* 722/*
724 * On a AMD dual core setup the lower bits of the APIC id distingush the cores. 723 * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
725 * Assumes number of cores is a power of two. 724 * Assumes number of cores is a power of two.
@@ -729,16 +728,24 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
729#ifdef CONFIG_SMP 728#ifdef CONFIG_SMP
730 int cpu = smp_processor_id(); 729 int cpu = smp_processor_id();
731 int node = 0; 730 int node = 0;
731 unsigned bits;
732 if (c->x86_num_cores == 1) 732 if (c->x86_num_cores == 1)
733 return; 733 return;
734 /* Fix up the APIC ID following the AMD specification. */ 734
735 cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1); 735 bits = 0;
736 while ((1 << bits) < c->x86_num_cores)
737 bits++;
738
739 /* Low order bits define the core id (index of core in socket) */
740 cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1);
741 /* Convert the APIC ID into the socket ID */
742 phys_proc_id[cpu] >>= bits;
736 743
737#ifdef CONFIG_NUMA 744#ifdef CONFIG_NUMA
738 /* When an ACPI SRAT table is available use the mappings from SRAT 745 /* When an ACPI SRAT table is available use the mappings from SRAT
739 instead. */ 746 instead. */
740 if (acpi_numa <= 0) { 747 if (acpi_numa <= 0) {
741 node = cpu_core_id[cpu]; 748 node = phys_proc_id[cpu];
742 if (!node_online(node)) 749 if (!node_online(node))
743 node = first_node(node_online_map); 750 node = first_node(node_online_map);
744 cpu_to_node[cpu] = node; 751 cpu_to_node[cpu] = node;
@@ -746,18 +753,11 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
746 node = cpu_to_node[cpu]; 753 node = cpu_to_node[cpu];
747 } 754 }
748#endif 755#endif
749 /* For now: - better than BAD_APIC_ID at least*/
750 phys_proc_id[cpu] = cpu_core_id[cpu];
751 756
752 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n", 757 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
753 cpu, c->x86_num_cores, node, cpu_core_id[cpu]); 758 cpu, c->x86_num_cores, node, cpu_core_id[cpu]);
754#endif 759#endif
755} 760}
756#else
757static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
758{
759}
760#endif
761 761
762static int __init init_amd(struct cpuinfo_x86 *c) 762static int __init init_amd(struct cpuinfo_x86 *c)
763{ 763{
@@ -963,8 +963,7 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c)
963 } 963 }
964 964
965#ifdef CONFIG_SMP 965#ifdef CONFIG_SMP
966 phys_proc_id[smp_processor_id()] = 966 phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
967 cpu_core_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
968#endif 967#endif
969} 968}
970 969