diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-07-19 21:01:16 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-20 03:25:52 -0400 |
commit | 64898a8bad8c94ad7a4bd5cc86b66edfbb081f4a (patch) | |
tree | 013c56a97a533c0843d28d838bc94e6de3da9e2c /arch/x86/kernel/numaq_32.c | |
parent | 3c9cb6de1e5ad37d1558fdb0d9d2bed5a7bac0d9 (diff) |
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>
Diffstat (limited to 'arch/x86/kernel/numaq_32.c')
-rw-r--r-- | arch/x86/kernel/numaq_32.c | 190 |
1 files changed, 179 insertions, 11 deletions
diff --git a/arch/x86/kernel/numaq_32.c b/arch/x86/kernel/numaq_32.c index a23e8233b9ac..7f4e00d1d893 100644 --- a/arch/x86/kernel/numaq_32.c +++ b/arch/x86/kernel/numaq_32.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/processor.h> | 33 | #include <asm/processor.h> |
34 | #include <asm/mpspec.h> | 34 | #include <asm/mpspec.h> |
35 | #include <asm/e820.h> | 35 | #include <asm/e820.h> |
36 | #include <asm/setup.h> | ||
36 | 37 | ||
37 | #define MB_TO_PAGES(addr) ((addr) << (20 - PAGE_SHIFT)) | 38 | #define MB_TO_PAGES(addr) ((addr) << (20 - PAGE_SHIFT)) |
38 | 39 | ||
@@ -71,6 +72,181 @@ static void __init smp_dump_qct(void) | |||
71 | } | 72 | } |
72 | } | 73 | } |
73 | 74 | ||
75 | |||
76 | void __init numaq_tsc_disable(void) | ||
77 | { | ||
78 | if (!found_numaq) | ||
79 | return; | ||
80 | |||
81 | if (num_online_nodes() > 1) { | ||
82 | printk(KERN_DEBUG "NUMAQ: disabling TSC\n"); | ||
83 | setup_clear_cpu_cap(X86_FEATURE_TSC); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | int found_numaq; | ||
88 | /* | ||
89 | * Have to match translation table entries to main table entries by counter | ||
90 | * hence the mpc_record variable .... can't see a less disgusting way of | ||
91 | * doing this .... | ||
92 | */ | ||
93 | struct mpc_config_translation { | ||
94 | unsigned char mpc_type; | ||
95 | unsigned char trans_len; | ||
96 | unsigned char trans_type; | ||
97 | unsigned char trans_quad; | ||
98 | unsigned char trans_global; | ||
99 | unsigned char trans_local; | ||
100 | unsigned short trans_reserved; | ||
101 | }; | ||
102 | |||
103 | /* x86_quirks member */ | ||
104 | static int mpc_record; | ||
105 | static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] | ||
106 | __cpuinitdata; | ||
107 | |||
108 | static inline int generate_logical_apicid(int quad, int phys_apicid) | ||
109 | { | ||
110 | return (quad << 4) + (phys_apicid ? phys_apicid << 1 : 1); | ||
111 | } | ||
112 | |||
113 | /* x86_quirks member */ | ||
114 | static int mpc_apic_id(struct mpc_config_processor *m) | ||
115 | { | ||
116 | int quad = translation_table[mpc_record]->trans_quad; | ||
117 | int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid); | ||
118 | |||
119 | printk(KERN_DEBUG "Processor #%d %u:%u APIC version %d (quad %d, apic %d)\n", | ||
120 | m->mpc_apicid, | ||
121 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
122 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
123 | m->mpc_apicver, quad, logical_apicid); | ||
124 | return logical_apicid; | ||
125 | } | ||
126 | |||
127 | int mp_bus_id_to_node[MAX_MP_BUSSES]; | ||
128 | |||
129 | int mp_bus_id_to_local[MAX_MP_BUSSES]; | ||
130 | |||
131 | /* x86_quirks member */ | ||
132 | static void mpc_oem_bus_info(struct mpc_config_bus *m, char *name) | ||
133 | { | ||
134 | int quad = translation_table[mpc_record]->trans_quad; | ||
135 | int local = translation_table[mpc_record]->trans_local; | ||
136 | |||
137 | mp_bus_id_to_node[m->mpc_busid] = quad; | ||
138 | mp_bus_id_to_local[m->mpc_busid] = local; | ||
139 | printk(KERN_INFO "Bus #%d is %s (node %d)\n", | ||
140 | m->mpc_busid, name, quad); | ||
141 | } | ||
142 | |||
143 | int quad_local_to_mp_bus_id [NR_CPUS/4][4]; | ||
144 | |||
145 | /* x86_quirks member */ | ||
146 | static void mpc_oem_pci_bus(struct mpc_config_bus *m) | ||
147 | { | ||
148 | int quad = translation_table[mpc_record]->trans_quad; | ||
149 | int local = translation_table[mpc_record]->trans_local; | ||
150 | |||
151 | quad_local_to_mp_bus_id[quad][local] = m->mpc_busid; | ||
152 | } | ||
153 | |||
154 | static void __init MP_translation_info(struct mpc_config_translation *m) | ||
155 | { | ||
156 | printk(KERN_INFO | ||
157 | "Translation: record %d, type %d, quad %d, global %d, local %d\n", | ||
158 | mpc_record, m->trans_type, m->trans_quad, m->trans_global, | ||
159 | m->trans_local); | ||
160 | |||
161 | if (mpc_record >= MAX_MPC_ENTRY) | ||
162 | printk(KERN_ERR "MAX_MPC_ENTRY exceeded!\n"); | ||
163 | else | ||
164 | translation_table[mpc_record] = m; /* stash this for later */ | ||
165 | if (m->trans_quad < MAX_NUMNODES && !node_online(m->trans_quad)) | ||
166 | node_set_online(m->trans_quad); | ||
167 | } | ||
168 | |||
169 | static int __init mpf_checksum(unsigned char *mp, int len) | ||
170 | { | ||
171 | int sum = 0; | ||
172 | |||
173 | while (len--) | ||
174 | sum += *mp++; | ||
175 | |||
176 | return sum & 0xFF; | ||
177 | } | ||
178 | |||
179 | /* | ||
180 | * Read/parse the MPC oem tables | ||
181 | */ | ||
182 | |||
183 | static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, | ||
184 | unsigned short oemsize) | ||
185 | { | ||
186 | int count = sizeof(*oemtable); /* the header size */ | ||
187 | unsigned char *oemptr = ((unsigned char *)oemtable) + count; | ||
188 | |||
189 | mpc_record = 0; | ||
190 | printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n", | ||
191 | oemtable); | ||
192 | if (memcmp(oemtable->oem_signature, MPC_OEM_SIGNATURE, 4)) { | ||
193 | printk(KERN_WARNING | ||
194 | "SMP mpc oemtable: bad signature [%c%c%c%c]!\n", | ||
195 | oemtable->oem_signature[0], oemtable->oem_signature[1], | ||
196 | oemtable->oem_signature[2], oemtable->oem_signature[3]); | ||
197 | return; | ||
198 | } | ||
199 | if (mpf_checksum((unsigned char *)oemtable, oemtable->oem_length)) { | ||
200 | printk(KERN_WARNING "SMP oem mptable: checksum error!\n"); | ||
201 | return; | ||
202 | } | ||
203 | while (count < oemtable->oem_length) { | ||
204 | switch (*oemptr) { | ||
205 | case MP_TRANSLATION: | ||
206 | { | ||
207 | struct mpc_config_translation *m = | ||
208 | (struct mpc_config_translation *)oemptr; | ||
209 | MP_translation_info(m); | ||
210 | oemptr += sizeof(*m); | ||
211 | count += sizeof(*m); | ||
212 | ++mpc_record; | ||
213 | break; | ||
214 | } | ||
215 | default: | ||
216 | { | ||
217 | printk(KERN_WARNING | ||
218 | "Unrecognised OEM table entry type! - %d\n", | ||
219 | (int)*oemptr); | ||
220 | return; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | static struct x86_quirks numaq_x86_quirks __initdata = { | ||
227 | .arch_time_init = NULL, | ||
228 | .arch_pre_intr_init = NULL, | ||
229 | .arch_memory_setup = NULL, | ||
230 | .arch_intr_init = NULL, | ||
231 | .arch_trap_init = NULL, | ||
232 | .mach_get_smp_config = NULL, | ||
233 | .mach_find_smp_config = NULL, | ||
234 | .mpc_record = &mpc_record, | ||
235 | .mpc_apic_id = mpc_apic_id, | ||
236 | .mpc_oem_bus_info = mpc_oem_bus_info, | ||
237 | .mpc_oem_pci_bus = mpc_oem_pci_bus, | ||
238 | .smp_read_mpc_oem = smp_read_mpc_oem, | ||
239 | }; | ||
240 | |||
241 | void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem, | ||
242 | char *productid) | ||
243 | { | ||
244 | if (strncmp(oem, "IBM NUMA", 8)) | ||
245 | printk("Warning! Not a NUMA-Q system!\n"); | ||
246 | else | ||
247 | found_numaq = 1; | ||
248 | } | ||
249 | |||
74 | static __init void early_check_numaq(void) | 250 | static __init void early_check_numaq(void) |
75 | { | 251 | { |
76 | /* | 252 | /* |
@@ -82,6 +258,9 @@ static __init void early_check_numaq(void) | |||
82 | */ | 258 | */ |
83 | if (smp_found_config) | 259 | if (smp_found_config) |
84 | early_get_smp_config(); | 260 | early_get_smp_config(); |
261 | |||
262 | if (found_numaq) | ||
263 | x86_quirks = &numaq_x86_quirks; | ||
85 | } | 264 | } |
86 | 265 | ||
87 | int __init get_memcfg_numaq(void) | 266 | int __init get_memcfg_numaq(void) |
@@ -92,14 +271,3 @@ int __init get_memcfg_numaq(void) | |||
92 | smp_dump_qct(); | 271 | smp_dump_qct(); |
93 | return 1; | 272 | return 1; |
94 | } | 273 | } |
95 | |||
96 | void __init numaq_tsc_disable(void) | ||
97 | { | ||
98 | if (!found_numaq) | ||
99 | return; | ||
100 | |||
101 | if (num_online_nodes() > 1) { | ||
102 | printk(KERN_DEBUG "NUMAQ: disabling TSC\n"); | ||
103 | setup_clear_cpu_cap(X86_FEATURE_TSC); | ||
104 | } | ||
105 | } | ||