* [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
* Re: [PATCH] x86_64: use apic core id bits for core nums
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-23 19:20 ` Yinghai Lu
0 siblings, 2 replies; 6+ messages in thread
From: Andi Kleen @ 2007-07-21 8:22 UTC (permalink / raw)
To: Yinghai Lu; +Cc: Andrew Morton, joachim.deguara, linux-kernel
On Saturday 21 July 2007 09:56:15 Yinghai Lu wrote:
> 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
Yes, you're right the patch is not good. It should probably use
information from the regular CPU setup code, not touch cpuid
directly
I'll drop it for now
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86_64: use apic core id bits for core nums
2007-07-21 8:22 ` Andi Kleen
@ 2007-07-21 11:21 ` Yinghai Lu
2007-07-21 12:28 ` Andi Kleen
2007-07-23 19:20 ` Yinghai Lu
1 sibling, 1 reply; 6+ messages in thread
From: Yinghai Lu @ 2007-07-21 11:21 UTC (permalink / raw)
To: Andi Kleen; +Cc: Andrew Morton, joachim.deguara, linux-kernel
On 7/21/07, Andi Kleen <ak@suse.de> wrote:
> On Saturday 21 July 2007 09:56:15 Yinghai Lu wrote:
> > 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
>
> Yes, you're right the patch is not good. It should probably use
> information from the regular CPU setup code, not touch cpuid
> directly
need move some code into early_identify_cpu from identify_cpu in
arch/x86_64/kernel/setup.c
then could use that bits in bsp cpu info.
BTW:
it seems for BSP only early_identify_cpu is called, and identify_cpu
is only use in smp_callin for AP. Do i miss sth.
YH
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86_64: use apic core id bits for core nums
2007-07-21 11:21 ` Yinghai Lu
@ 2007-07-21 12:28 ` Andi Kleen
2007-07-22 1:36 ` Yinghai Lu
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2007-07-21 12:28 UTC (permalink / raw)
To: Yinghai Lu; +Cc: Andrew Morton, joachim.deguara, linux-kernel
On Saturday 21 July 2007 13:21:34 Yinghai Lu wrote:
> On 7/21/07, Andi Kleen <ak@suse.de> wrote:
> > On Saturday 21 July 2007 09:56:15 Yinghai Lu wrote:
> > > 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
> >
> > Yes, you're right the patch is not good. It should probably use
> > information from the regular CPU setup code, not touch cpuid
> > directly
>
> need move some code into early_identify_cpu from identify_cpu in
> arch/x86_64/kernel/setup.c
> then could use that bits in bsp cpu info.
Yes something like this
> BTW:
> it seems for BSP only early_identify_cpu is called, and identify_cpu
> is only use in smp_callin for AP. Do i miss sth.
identify_cpu calls early_identify_cpu as first thing.
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86_64: use apic core id bits for core nums
2007-07-21 12:28 ` Andi Kleen
@ 2007-07-22 1:36 ` Yinghai Lu
0 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2007-07-22 1:36 UTC (permalink / raw)
To: Andi Kleen; +Cc: Andrew Morton, joachim.deguara, linux-kernel
On 7/21/07, Andi Kleen <ak@suse.de> wrote:
> On Saturday 21 July 2007 13:21:34 Yinghai Lu wrote:
> > On 7/21/07, Andi Kleen <ak@suse.de> wrote:
> > > On Saturday 21 July 2007 09:56:15 Yinghai Lu wrote:
> > > > 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
> > >
> > > Yes, you're right the patch is not good. It should probably use
> > > information from the regular CPU setup code, not touch cpuid
> > > directly
> >
> > need move some code into early_identify_cpu from identify_cpu in
> > arch/x86_64/kernel/setup.c
> > then could use that bits in bsp cpu info.
>
> Yes something like this
>
> > BTW:
> > it seems for BSP only early_identify_cpu is called, and identify_cpu
> > is only use in smp_callin for AP. Do i miss sth.
>
> identify_cpu calls early_identify_cpu as first thing.
the calling to identify_cpu in BSP is in check_bugs(). It is easy to
ignore it...
maybe we could move that to setup_arch directly.
YH
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86_64: use apic core id bits for core nums
2007-07-21 8:22 ` Andi Kleen
2007-07-21 11:21 ` Yinghai Lu
@ 2007-07-23 19:20 ` Yinghai Lu
1 sibling, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2007-07-23 19:20 UTC (permalink / raw)
To: Andi Kleen; +Cc: Andrew Morton, joachim.deguara, linux-kernel
On 7/21/07, Andi Kleen <ak@suse.de> wrote:
> On Saturday 21 July 2007 09:56:15 Yinghai Lu wrote:
> > 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
>
> Yes, you're right the patch is not good. It should probably use
> information from the regular CPU setup code, not touch cpuid
> directly
>
> I'll drop it for now
too bad, just figure out you dropped wrong one.
following one 36/48 is right. please apply it again.
37/48 got into the mainline. that is wrong. please use
http://lkml.org/lkml/2007/7/22/7
[PATCH 2/3] x86_64: use core id bits for apicid_to_node initialization v2
that is rebased to 37/48.
YH
From: "Joachim Deguara" <joachim.deguara@amd.com>
This just adds the PCI IDs of AMD's family 10h and 11h CPU's northbridges to
k8topology discovery.
Signed-off-by: Joachim Deguara <joachim.deguara@amd.com>
Signed-off-by: Andi Kleen <ak@suse.de>
--
---
arch/x86_64/mm/k8topology.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: linux/arch/x86_64/mm/k8topology.c
===================================================================
--- linux.orig/arch/x86_64/mm/k8topology.c
+++ linux/arch/x86_64/mm/k8topology.c
@@ -28,11 +28,15 @@ static __init int find_northbridge(void)
u32 header;
header = read_pci_config(0, num, 0, 0x00);
- if (header != (PCI_VENDOR_ID_AMD | (0x1100<<16)))
+ if (header != (PCI_VENDOR_ID_AMD | (0x1100<<16)) &&
+ header != (PCI_VENDOR_ID_AMD | (0x1200<<16)) &&
+ header != (PCI_VENDOR_ID_AMD | (0x1300<<16)) )
continue;
header = read_pci_config(0, num, 1, 0x00);
- if (header != (PCI_VENDOR_ID_AMD | (0x1101<<16)))
+ if (header != (PCI_VENDOR_ID_AMD | (0x1101<<16)) &&
+ header != (PCI_VENDOR_ID_AMD | (0x1201<<16)) &&
+ header != (PCI_VENDOR_ID_AMD | (0x1301<<16)) )
continue;
return num;
}
-
^ permalink raw reply [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