提交 7557244b 编写于 作者: J Joachim Deguara 提交者: Linus Torvalds

x86_64: make k8topology multi-core aware

This makes k8topology multicore aware instead of limited to signle- and
dual-core CPUs.  It uses the CPUID to be more future proof.
Signed-off-by: NJoachim Deguara <joachim.deguara@amd.com>
Signed-off-by: NAndi Kleen <ak@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 81e02d19
...@@ -44,12 +44,12 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end) ...@@ -44,12 +44,12 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
{ {
unsigned long prevbase; unsigned long prevbase;
struct bootnode nodes[8]; struct bootnode nodes[8];
int nodeid, i, nb; int nodeid, i, j, nb;
unsigned char nodeids[8]; unsigned char nodeids[8];
int found = 0; int found = 0;
u32 reg; u32 reg;
unsigned numnodes; unsigned numnodes;
unsigned dualcore = 0; unsigned num_cores;
if (!early_pci_allowed()) if (!early_pci_allowed())
return -1; return -1;
...@@ -60,6 +60,9 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end) ...@@ -60,6 +60,9 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
printk(KERN_INFO "Scanning NUMA topology in Northbridge %d\n", nb); printk(KERN_INFO "Scanning NUMA topology in Northbridge %d\n", nb);
num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
printk(KERN_INFO "CPU has %d num_cores\n", num_cores);
reg = read_pci_config(0, nb, 0, 0x60); reg = read_pci_config(0, nb, 0, 0x60);
numnodes = ((reg >> 4) & 0xF) + 1; numnodes = ((reg >> 4) & 0xF) + 1;
if (numnodes <= 1) if (numnodes <= 1)
...@@ -73,8 +76,6 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end) ...@@ -73,8 +76,6 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
unsigned long base,limit; unsigned long base,limit;
u32 nodeid; 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); base = read_pci_config(0, nb, 1, 0x40 + i*8);
limit = read_pci_config(0, nb, 1, 0x44 + i*8); limit = read_pci_config(0, nb, 1, 0x44 + i*8);
...@@ -170,8 +171,8 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end) ...@@ -170,8 +171,8 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (nodes[i].start != nodes[i].end) { if (nodes[i].start != nodes[i].end) {
nodeid = nodeids[i]; nodeid = nodeids[i];
apicid_to_node[nodeid << dualcore] = i; for (j = 0; j < num_cores; j++)
apicid_to_node[(nodeid << dualcore) + dualcore] = i; apicid_to_node[(nodeid * num_cores) + j] = i;
setup_node_bootmem(i, nodes[i].start, nodes[i].end); setup_node_bootmem(i, nodes[i].start, nodes[i].end);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册