Skip to content

Commit 64898a8

Browse files
yhluIngo Molnar
authored andcommitted
x86: extend and use x86_quirks to clean up NUMAQ code
add these new x86_quirks methods: int *mpc_record; int (*mpc_apic_id)(struct mpc_config_processor *m); void (*mpc_oem_bus_info)(struct mpc_config_bus *m, char *name); void (*mpc_oem_pci_bus)(struct mpc_config_bus *m); void (*smp_read_mpc_oem)(struct mp_config_oemtable *oemtable, unsigned short oemsize); ... and move NUMAQ related mps table handling to numaq_32.c. also move the call to smp_read_mpc_oem() to smp_read_mpc() directly. Should not change functionality, albeit it would be nice to get it tested on real NUMAQ as well ... Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 3c9cb6d commit 64898a8

File tree

4 files changed

+212
-181
lines changed

4 files changed

+212
-181
lines changed

arch/x86/kernel/mpparse.c

Lines changed: 21 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -49,76 +49,6 @@ static int __init mpf_checksum(unsigned char *mp, int len)
4949
return sum & 0xFF;
5050
}
5151

52-
#ifdef CONFIG_X86_NUMAQ
53-
int found_numaq;
54-
/*
55-
* Have to match translation table entries to main table entries by counter
56-
* hence the mpc_record variable .... can't see a less disgusting way of
57-
* doing this ....
58-
*/
59-
struct mpc_config_translation {
60-
unsigned char mpc_type;
61-
unsigned char trans_len;
62-
unsigned char trans_type;
63-
unsigned char trans_quad;
64-
unsigned char trans_global;
65-
unsigned char trans_local;
66-
unsigned short trans_reserved;
67-
};
68-
69-
70-
static int mpc_record;
71-
static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY]
72-
__cpuinitdata;
73-
74-
static inline int generate_logical_apicid(int quad, int phys_apicid)
75-
{
76-
return (quad << 4) + (phys_apicid ? phys_apicid << 1 : 1);
77-
}
78-
79-
80-
static inline int mpc_apic_id(struct mpc_config_processor *m,
81-
struct mpc_config_translation *translation_record)
82-
{
83-
int quad = translation_record->trans_quad;
84-
int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid);
85-
86-
printk(KERN_DEBUG "Processor #%d %u:%u APIC version %d (quad %d, apic %d)\n",
87-
m->mpc_apicid,
88-
(m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
89-
(m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
90-
m->mpc_apicver, quad, logical_apicid);
91-
return logical_apicid;
92-
}
93-
94-
int mp_bus_id_to_node[MAX_MP_BUSSES];
95-
96-
int mp_bus_id_to_local[MAX_MP_BUSSES];
97-
98-
static void mpc_oem_bus_info(struct mpc_config_bus *m, char *name,
99-
struct mpc_config_translation *translation)
100-
{
101-
int quad = translation->trans_quad;
102-
int local = translation->trans_local;
103-
104-
mp_bus_id_to_node[m->mpc_busid] = quad;
105-
mp_bus_id_to_local[m->mpc_busid] = local;
106-
printk(KERN_INFO "Bus #%d is %s (node %d)\n",
107-
m->mpc_busid, name, quad);
108-
}
109-
110-
int quad_local_to_mp_bus_id [NR_CPUS/4][4];
111-
static void mpc_oem_pci_bus(struct mpc_config_bus *m,
112-
struct mpc_config_translation *translation)
113-
{
114-
int quad = translation->trans_quad;
115-
int local = translation->trans_local;
116-
117-
quad_local_to_mp_bus_id[quad][local] = m->mpc_busid;
118-
}
119-
120-
#endif
121-
12252
static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
12353
{
12454
int apicid;
@@ -128,14 +58,12 @@ static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
12858
disabled_cpus++;
12959
return;
13060
}
131-
#ifdef CONFIG_X86_NUMAQ
132-
if (found_numaq)
133-
apicid = mpc_apic_id(m, translation_table[mpc_record]);
61+
62+
if (x86_quirks->mpc_apic_id)
63+
apicid = x86_quirks->mpc_apic_id(m);
13464
else
13565
apicid = m->mpc_apicid;
136-
#else
137-
apicid = m->mpc_apicid;
138-
#endif
66+
13967
if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
14068
bootup_cpu = " (Bootup-CPU)";
14169
boot_cpu_physical_apicid = m->mpc_apicid;
@@ -152,12 +80,10 @@ static void __init MP_bus_info(struct mpc_config_bus *m)
15280
memcpy(str, m->mpc_bustype, 6);
15381
str[6] = 0;
15482

155-
#ifdef CONFIG_X86_NUMAQ
156-
if (found_numaq)
157-
mpc_oem_bus_info(m, str, translation_table[mpc_record]);
158-
#else
159-
printk(KERN_INFO "Bus #%d is %s\n", m->mpc_busid, str);
160-
#endif
83+
if (x86_quirks->mpc_oem_bus_info)
84+
x86_quirks->mpc_oem_bus_info(m, str);
85+
else
86+
printk(KERN_INFO "Bus #%d is %s\n", m->mpc_busid, str);
16187

16288
#if MAX_MP_BUSSES < 256
16389
if (m->mpc_busid >= MAX_MP_BUSSES) {
@@ -174,10 +100,9 @@ static void __init MP_bus_info(struct mpc_config_bus *m)
174100
mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
175101
#endif
176102
} else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) {
177-
#ifdef CONFIG_X86_NUMAQ
178-
if (found_numaq)
179-
mpc_oem_pci_bus(m, translation_table[mpc_record]);
180-
#endif
103+
if (x86_quirks->mpc_oem_pci_bus)
104+
x86_quirks->mpc_oem_pci_bus(m);
105+
181106
clear_bit(m->mpc_busid, mp_bus_not_pci);
182107
#if defined(CONFIG_EISA) || defined (CONFIG_MCA)
183108
mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI;
@@ -317,83 +242,6 @@ static void __init MP_lintsrc_info(struct mpc_config_lintsrc *m)
317242
m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
318243
}
319244

320-
#ifdef CONFIG_X86_NUMAQ
321-
static void __init MP_translation_info(struct mpc_config_translation *m)
322-
{
323-
printk(KERN_INFO
324-
"Translation: record %d, type %d, quad %d, global %d, local %d\n",
325-
mpc_record, m->trans_type, m->trans_quad, m->trans_global,
326-
m->trans_local);
327-
328-
if (mpc_record >= MAX_MPC_ENTRY)
329-
printk(KERN_ERR "MAX_MPC_ENTRY exceeded!\n");
330-
else
331-
translation_table[mpc_record] = m; /* stash this for later */
332-
if (m->trans_quad < MAX_NUMNODES && !node_online(m->trans_quad))
333-
node_set_online(m->trans_quad);
334-
}
335-
336-
/*
337-
* Read/parse the MPC oem tables
338-
*/
339-
340-
static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable,
341-
unsigned short oemsize)
342-
{
343-
int count = sizeof(*oemtable); /* the header size */
344-
unsigned char *oemptr = ((unsigned char *)oemtable) + count;
345-
346-
mpc_record = 0;
347-
printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n",
348-
oemtable);
349-
if (memcmp(oemtable->oem_signature, MPC_OEM_SIGNATURE, 4)) {
350-
printk(KERN_WARNING
351-
"SMP mpc oemtable: bad signature [%c%c%c%c]!\n",
352-
oemtable->oem_signature[0], oemtable->oem_signature[1],
353-
oemtable->oem_signature[2], oemtable->oem_signature[3]);
354-
return;
355-
}
356-
if (mpf_checksum((unsigned char *)oemtable, oemtable->oem_length)) {
357-
printk(KERN_WARNING "SMP oem mptable: checksum error!\n");
358-
return;
359-
}
360-
while (count < oemtable->oem_length) {
361-
switch (*oemptr) {
362-
case MP_TRANSLATION:
363-
{
364-
struct mpc_config_translation *m =
365-
(struct mpc_config_translation *)oemptr;
366-
MP_translation_info(m);
367-
oemptr += sizeof(*m);
368-
count += sizeof(*m);
369-
++mpc_record;
370-
break;
371-
}
372-
default:
373-
{
374-
printk(KERN_WARNING
375-
"Unrecognised OEM table entry type! - %d\n",
376-
(int)*oemptr);
377-
return;
378-
}
379-
}
380-
}
381-
}
382-
383-
void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem,
384-
char *productid)
385-
{
386-
if (strncmp(oem, "IBM NUMA", 8))
387-
printk("Warning! Not a NUMA-Q system!\n");
388-
else
389-
found_numaq = 1;
390-
391-
if (mpc->mpc_oemptr)
392-
smp_read_mpc_oem((struct mp_config_oemtable *)mpc->mpc_oemptr,
393-
mpc->mpc_oemsize);
394-
}
395-
#endif /* CONFIG_X86_NUMAQ */
396-
397245
/*
398246
* Read/parse the MPC
399247
*/
@@ -458,20 +306,24 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
458306
} else
459307
mps_oem_check(mpc, oem, str);
460308
#endif
461-
462309
/* save the local APIC address, it might be non-default */
463310
if (!acpi_lapic)
464311
mp_lapic_addr = mpc->mpc_lapic;
465312

466313
if (early)
467314
return 1;
468315

316+
if (mpc->mpc_oemptr && x86_quirks->smp_read_mpc_oem) {
317+
struct mp_config_oemtable *oem_table = (struct mp_config_oemtable *)(unsigned long)mpc->mpc_oemptr;
318+
x86_quirks->smp_read_mpc_oem(oem_table, mpc->mpc_oemsize);
319+
}
320+
469321
/*
470322
* Now process the configuration blocks.
471323
*/
472-
#ifdef CONFIG_X86_NUMAQ
473-
mpc_record = 0;
474-
#endif
324+
if (x86_quirks->mpc_record)
325+
*x86_quirks->mpc_record = 0;
326+
475327
while (count < mpc->mpc_length) {
476328
switch (*mpt) {
477329
case MP_PROCESSOR:
@@ -537,9 +389,8 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
537389
count = mpc->mpc_length;
538390
break;
539391
}
540-
#ifdef CONFIG_X86_NUMAQ
541-
++mpc_record;
542-
#endif
392+
if (x86_quirks->mpc_record)
393+
(*x86_quirks->mpc_record)++;
543394
}
544395

545396
#ifdef CONFIG_X86_GENERICARCH

0 commit comments

Comments
 (0)