public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86_64: use apic core id bits for core nums
@ 2007-07-21  7:56 Yinghai Lu
  2007-07-21  8:22 ` Andi Kleen
  0 siblings, 1 reply; 6+ messages in thread
From: Yinghai Lu @ 2007-07-21  7:56 UTC (permalink / raw)
  To: Andi Kleen, Andrew Morton; +Cc: joachim.deguara, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

please check my version, we should use core id bits instead.

it should replace
[PATCH for review] [37/48] x86_64: make k8topology multi-core aware

YH

[PATCH] x86_64: use apic core id bits for core nums

we need to use apic core id bits to get core num and use that get apic_to_node
correctly.
it will work with quad core downcores cpus.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

[-- Attachment #2: k8_core.diff --]
[-- Type: text/x-patch, Size: 1689 bytes --]

diff --git a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
index f983c75..3e8e47f 100644
--- a/arch/x86_64/mm/k8topology.c
+++ b/arch/x86_64/mm/k8topology.c
@@ -49,7 +49,10 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
 	int found = 0;
 	u32 reg;
 	unsigned numnodes;
-	unsigned dualcore = 0;
+	unsigned cores;
+	u32 ecx;
+	unsigned bits;
+	int j;
 
 	if (!early_pci_allowed())
 		return -1;
@@ -67,14 +70,26 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
 
 	printk(KERN_INFO "Number of nodes %d\n", numnodes);
 
+        ecx = cpuid_ecx(0x80000008);
+        cores = (ecx & 0xff) + 1;
+
+        /* CPU telling us the core id bits shift? */
+        bits = (ecx >> 12) & 0xF;
+
+        /* Otherwise recompute */
+        if (bits == 0) {
+                while ((1 << bits) < cores)
+                        bits++;
+        }
+
+	cores = (1<<bits);
+
 	memset(&nodes,0,sizeof(nodes)); 
 	prevbase = 0;
 	for (i = 0; i < 8; i++) { 
 		unsigned long base,limit; 
 		u32 nodeid;
 		
-		/* Undefined before E stepping, but hopefully 0 */
-		dualcore |= ((read_pci_config(0, nb, 3, 0xe8) >> 12) & 3) == 1;
 		base = read_pci_config(0, nb, 1, 0x40 + i*8);
 		limit = read_pci_config(0, nb, 1, 0x44 + i*8);
 
@@ -170,8 +185,8 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
 	for (i = 0; i < 8; i++) {
 		if (nodes[i].start != nodes[i].end) { 
 			nodeid = nodeids[i];
-			apicid_to_node[nodeid << dualcore] = i;
-			apicid_to_node[(nodeid << dualcore) + dualcore] = i;
+			for (j = 0; j < cores; j++)
+				apicid_to_node[(nodeid << bits) + j] = i;
 			setup_node_bootmem(i, nodes[i].start, nodes[i].end); 
 		} 
 	}

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-07-23 19:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-21  7:56 [PATCH] x86_64: use apic core id bits for core nums Yinghai Lu
2007-07-21  8:22 ` Andi Kleen
2007-07-21 11:21   ` Yinghai Lu
2007-07-21 12:28     ` Andi Kleen
2007-07-22  1:36       ` Yinghai Lu
2007-07-23 19:20   ` Yinghai Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox