diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-06-17 18:41:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-08 04:38:47 -0400 |
commit | 1c6e55032e24ff79668581a0f296c278ef7edd4e (patch) | |
tree | 5368ede51192cc0b4413ac8be9ea86bad211187c /arch/x86/kernel/srat_32.c | |
parent | 0699eae140a3eeca976df4e3b7699b1fa3f763cd (diff) |
x86: use acpi_numa_init to parse on 32-bit numa
seperate SRAT finding and parsing from get_memcfg_from_srat,
and let getmemcfg_from_srat only handle array from previous step.
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/srat_32.c')
-rw-r--r-- | arch/x86/kernel/srat_32.c | 200 |
1 files changed, 49 insertions, 151 deletions
diff --git a/arch/x86/kernel/srat_32.c b/arch/x86/kernel/srat_32.c index e9d91720a40f..5978023b799b 100644 --- a/arch/x86/kernel/srat_32.c +++ b/arch/x86/kernel/srat_32.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #define BMAP_TEST(bmap, bit) ((bmap)[NODE_ARRAY_INDEX(bit)] & (1 << NODE_ARRAY_OFFSET(bit))) | 42 | #define BMAP_TEST(bmap, bit) ((bmap)[NODE_ARRAY_INDEX(bit)] & (1 << NODE_ARRAY_OFFSET(bit))) |
43 | /* bitmap length; _PXM is at most 255 */ | 43 | /* bitmap length; _PXM is at most 255 */ |
44 | #define PXM_BITMAP_LEN (MAX_PXM_DOMAINS / 8) | 44 | #define PXM_BITMAP_LEN (MAX_PXM_DOMAINS / 8) |
45 | static u8 pxm_bitmap[PXM_BITMAP_LEN]; /* bitmap of proximity domains */ | 45 | static u8 __initdata pxm_bitmap[PXM_BITMAP_LEN]; /* bitmap of proximity domains */ |
46 | 46 | ||
47 | #define MAX_CHUNKS_PER_NODE 3 | 47 | #define MAX_CHUNKS_PER_NODE 3 |
48 | #define MAXCHUNKS (MAX_CHUNKS_PER_NODE * MAX_NUMNODES) | 48 | #define MAXCHUNKS (MAX_CHUNKS_PER_NODE * MAX_NUMNODES) |
@@ -53,16 +53,37 @@ struct node_memory_chunk_s { | |||
53 | u8 nid; // which cnode contains this chunk? | 53 | u8 nid; // which cnode contains this chunk? |
54 | u8 bank; // which mem bank on this node | 54 | u8 bank; // which mem bank on this node |
55 | }; | 55 | }; |
56 | static struct node_memory_chunk_s node_memory_chunk[MAXCHUNKS]; | 56 | static struct node_memory_chunk_s __initdata node_memory_chunk[MAXCHUNKS]; |
57 | 57 | ||
58 | static int num_memory_chunks; /* total number of memory chunks */ | 58 | static int __initdata num_memory_chunks; /* total number of memory chunks */ |
59 | static u8 __initdata apicid_to_pxm[MAX_APICID]; | 59 | static u8 __initdata apicid_to_pxm[MAX_APICID]; |
60 | 60 | ||
61 | int numa_off __initdata; | ||
62 | int acpi_numa __initdata; | ||
63 | |||
64 | static __init void bad_srat(void) | ||
65 | { | ||
66 | printk(KERN_ERR "SRAT: SRAT not used.\n"); | ||
67 | acpi_numa = -1; | ||
68 | num_memory_chunks = 0; | ||
69 | } | ||
70 | |||
71 | static __init inline int srat_disabled(void) | ||
72 | { | ||
73 | return numa_off || acpi_numa < 0; | ||
74 | } | ||
75 | |||
61 | /* Identify CPU proximity domains */ | 76 | /* Identify CPU proximity domains */ |
62 | static void __init parse_cpu_affinity_structure(char *p) | 77 | void __init |
78 | acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *cpu_affinity) | ||
63 | { | 79 | { |
64 | struct acpi_srat_cpu_affinity *cpu_affinity = | 80 | if (srat_disabled()) |
65 | (struct acpi_srat_cpu_affinity *) p; | 81 | return; |
82 | if (cpu_affinity->header.length != | ||
83 | sizeof(struct acpi_srat_cpu_affinity)) { | ||
84 | bad_srat(); | ||
85 | return; | ||
86 | } | ||
66 | 87 | ||
67 | if ((cpu_affinity->flags & ACPI_SRAT_CPU_ENABLED) == 0) | 88 | if ((cpu_affinity->flags & ACPI_SRAT_CPU_ENABLED) == 0) |
68 | return; /* empty entry */ | 89 | return; /* empty entry */ |
@@ -80,14 +101,21 @@ static void __init parse_cpu_affinity_structure(char *p) | |||
80 | * Identify memory proximity domains and hot-remove capabilities. | 101 | * Identify memory proximity domains and hot-remove capabilities. |
81 | * Fill node memory chunk list structure. | 102 | * Fill node memory chunk list structure. |
82 | */ | 103 | */ |
83 | static void __init parse_memory_affinity_structure (char *sratp) | 104 | void __init |
105 | acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *memory_affinity) | ||
84 | { | 106 | { |
85 | unsigned long long paddr, size; | 107 | unsigned long long paddr, size; |
86 | unsigned long start_pfn, end_pfn; | 108 | unsigned long start_pfn, end_pfn; |
87 | u8 pxm; | 109 | u8 pxm; |
88 | struct node_memory_chunk_s *p, *q, *pend; | 110 | struct node_memory_chunk_s *p, *q, *pend; |
89 | struct acpi_srat_mem_affinity *memory_affinity = | 111 | |
90 | (struct acpi_srat_mem_affinity *) sratp; | 112 | if (srat_disabled()) |
113 | return; | ||
114 | if (memory_affinity->header.length != | ||
115 | sizeof(struct acpi_srat_mem_affinity)) { | ||
116 | bad_srat(); | ||
117 | return; | ||
118 | } | ||
91 | 119 | ||
92 | if ((memory_affinity->flags & ACPI_SRAT_MEM_ENABLED) == 0) | 120 | if ((memory_affinity->flags & ACPI_SRAT_MEM_ENABLED) == 0) |
93 | return; /* empty entry */ | 121 | return; /* empty entry */ |
@@ -135,6 +163,14 @@ static void __init parse_memory_affinity_structure (char *sratp) | |||
135 | "enabled and removable" : "enabled" ) ); | 163 | "enabled and removable" : "enabled" ) ); |
136 | } | 164 | } |
137 | 165 | ||
166 | /* Callback for SLIT parsing */ | ||
167 | void __init acpi_numa_slit_init(struct acpi_table_slit *slit) | ||
168 | { | ||
169 | } | ||
170 | |||
171 | void acpi_numa_arch_fixup(void) | ||
172 | { | ||
173 | } | ||
138 | /* | 174 | /* |
139 | * The SRAT table always lists ascending addresses, so can always | 175 | * The SRAT table always lists ascending addresses, so can always |
140 | * assume that the first "start" address that you see is the real | 176 | * assume that the first "start" address that you see is the real |
@@ -167,39 +203,13 @@ static __init void node_read_chunk(int nid, struct node_memory_chunk_s *memory_c | |||
167 | node_end_pfn[nid] = memory_chunk->end_pfn; | 203 | node_end_pfn[nid] = memory_chunk->end_pfn; |
168 | } | 204 | } |
169 | 205 | ||
170 | /* Parse the ACPI Static Resource Affinity Table */ | 206 | int __init get_memcfg_from_srat(void) |
171 | static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) | ||
172 | { | 207 | { |
173 | u8 *start, *end, *p; | ||
174 | int i, j, nid; | 208 | int i, j, nid; |
175 | 209 | ||
176 | start = (u8 *)(&(sratp->reserved) + 1); /* skip header */ | ||
177 | p = start; | ||
178 | end = (u8 *)sratp + sratp->header.length; | ||
179 | 210 | ||
180 | memset(pxm_bitmap, 0, sizeof(pxm_bitmap)); /* init proximity domain bitmap */ | 211 | if (srat_disabled()) |
181 | memset(node_memory_chunk, 0, sizeof(node_memory_chunk)); | 212 | goto out_fail; |
182 | |||
183 | num_memory_chunks = 0; | ||
184 | while (p < end) { | ||
185 | switch (*p) { | ||
186 | case ACPI_SRAT_TYPE_CPU_AFFINITY: | ||
187 | parse_cpu_affinity_structure(p); | ||
188 | break; | ||
189 | case ACPI_SRAT_TYPE_MEMORY_AFFINITY: | ||
190 | parse_memory_affinity_structure(p); | ||
191 | break; | ||
192 | default: | ||
193 | printk("ACPI 2.0 SRAT: unknown entry skipped: type=0x%02X, len=%d\n", p[0], p[1]); | ||
194 | break; | ||
195 | } | ||
196 | p += p[1]; | ||
197 | if (p[1] == 0) { | ||
198 | printk("acpi20_parse_srat: Entry length value is zero;" | ||
199 | " can't parse any further!\n"); | ||
200 | break; | ||
201 | } | ||
202 | } | ||
203 | 213 | ||
204 | if (num_memory_chunks == 0) { | 214 | if (num_memory_chunks == 0) { |
205 | printk("could not finy any ACPI SRAT memory areas.\n"); | 215 | printk("could not finy any ACPI SRAT memory areas.\n"); |
@@ -248,7 +258,7 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) | |||
248 | e820_register_active_regions(chunk->nid, chunk->start_pfn, | 258 | e820_register_active_regions(chunk->nid, chunk->start_pfn, |
249 | min(chunk->end_pfn, max_pfn)); | 259 | min(chunk->end_pfn, max_pfn)); |
250 | } | 260 | } |
251 | 261 | ||
252 | for_each_online_node(nid) { | 262 | for_each_online_node(nid) { |
253 | unsigned long start = node_start_pfn[nid]; | 263 | unsigned long start = node_start_pfn[nid]; |
254 | unsigned long end = min(node_end_pfn[nid], max_pfn); | 264 | unsigned long end = min(node_end_pfn[nid], max_pfn); |
@@ -258,118 +268,6 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) | |||
258 | } | 268 | } |
259 | return 1; | 269 | return 1; |
260 | out_fail: | 270 | out_fail: |
261 | return 0; | ||
262 | } | ||
263 | |||
264 | struct acpi_static_rsdt { | ||
265 | struct acpi_table_rsdt table; | ||
266 | u32 padding[32]; /* Allow for 32 more table entries */ | ||
267 | }; | ||
268 | |||
269 | int __init get_memcfg_from_srat(void) | ||
270 | { | ||
271 | struct acpi_table_header *header = NULL; | ||
272 | struct acpi_table_rsdp *rsdp = NULL; | ||
273 | struct acpi_table_rsdt *rsdt = NULL; | ||
274 | acpi_native_uint rsdp_address = 0; | ||
275 | struct acpi_static_rsdt saved_rsdt; | ||
276 | int tables = 0; | ||
277 | int i = 0; | ||
278 | |||
279 | rsdp_address = acpi_os_get_root_pointer(); | ||
280 | if (!rsdp_address) { | ||
281 | printk("%s: System description tables not found\n", | ||
282 | __func__); | ||
283 | goto out_err; | ||
284 | } | ||
285 | |||
286 | printk("%s: assigning address to rsdp\n", __func__); | ||
287 | rsdp = (struct acpi_table_rsdp *)(u32)rsdp_address; | ||
288 | if (!rsdp) { | ||
289 | printk("%s: Didn't find ACPI root!\n", __func__); | ||
290 | goto out_err; | ||
291 | } | ||
292 | |||
293 | printk(KERN_INFO "%.8s v%d [%.6s]\n", rsdp->signature, rsdp->revision, | ||
294 | rsdp->oem_id); | ||
295 | |||
296 | if (strncmp(rsdp->signature, ACPI_SIG_RSDP,strlen(ACPI_SIG_RSDP))) { | ||
297 | printk(KERN_WARNING "%s: RSDP table signature incorrect\n", __func__); | ||
298 | goto out_err; | ||
299 | } | ||
300 | |||
301 | rsdt = (struct acpi_table_rsdt *) | ||
302 | early_ioremap(rsdp->rsdt_physical_address, sizeof(saved_rsdt)); | ||
303 | |||
304 | if (!rsdt) { | ||
305 | printk(KERN_WARNING | ||
306 | "%s: ACPI: Invalid root system description tables (RSDT)\n", | ||
307 | __func__); | ||
308 | goto out_err; | ||
309 | } | ||
310 | |||
311 | header = &rsdt->header; | ||
312 | |||
313 | if (strncmp(header->signature, ACPI_SIG_RSDT, strlen(ACPI_SIG_RSDT))) { | ||
314 | printk(KERN_WARNING "ACPI: RSDT signature incorrect\n"); | ||
315 | early_iounmap(rsdt, sizeof(saved_rsdt)); | ||
316 | goto out_err; | ||
317 | } | ||
318 | |||
319 | /* | ||
320 | * The number of tables is computed by taking the | ||
321 | * size of all entries (header size minus total | ||
322 | * size of RSDT) divided by the size of each entry | ||
323 | * (4-byte table pointers). | ||
324 | */ | ||
325 | tables = (header->length - sizeof(struct acpi_table_header)) / sizeof(u32); | ||
326 | |||
327 | if (!tables) | ||
328 | goto out_err; | ||
329 | |||
330 | memcpy(&saved_rsdt, rsdt, sizeof(saved_rsdt)); | ||
331 | early_iounmap(rsdt, sizeof(saved_rsdt)); | ||
332 | if (saved_rsdt.table.header.length > sizeof(saved_rsdt)) { | ||
333 | printk(KERN_WARNING "ACPI: Too big length in RSDT: %d\n", | ||
334 | saved_rsdt.table.header.length); | ||
335 | goto out_err; | ||
336 | } | ||
337 | |||
338 | printk("Begin SRAT table scan....%d\n", tables); | ||
339 | |||
340 | for (i = 0; i < tables; i++){ | ||
341 | int result; | ||
342 | u32 length; | ||
343 | /* Map in header, then map in full table length. */ | ||
344 | header = (struct acpi_table_header *) | ||
345 | early_ioremap(saved_rsdt.table.table_offset_entry[i], sizeof(struct acpi_table_header)); | ||
346 | if (!header) | ||
347 | break; | ||
348 | |||
349 | printk(KERN_INFO "ACPI: %4.4s %08lX, %04X\n", | ||
350 | header->signature, | ||
351 | (unsigned long)saved_rsdt.table.table_offset_entry[i], | ||
352 | header->length); | ||
353 | |||
354 | if (strncmp((char *) &header->signature, ACPI_SIG_SRAT, 4)) { | ||
355 | early_iounmap(header, sizeof(struct acpi_table_header)); | ||
356 | continue; | ||
357 | } | ||
358 | |||
359 | length = header->length; | ||
360 | early_iounmap(header, sizeof(struct acpi_table_header)); | ||
361 | header = (struct acpi_table_header *) | ||
362 | early_ioremap(saved_rsdt.table.table_offset_entry[i], length); | ||
363 | if (!header) | ||
364 | break; | ||
365 | |||
366 | /* we've found the srat table. don't need to look at any more tables */ | ||
367 | result = acpi20_parse_srat((struct acpi_table_srat *)header); | ||
368 | early_iounmap(header, length); | ||
369 | return result; | ||
370 | } | ||
371 | out_err: | ||
372 | remove_all_active_ranges(); | ||
373 | printk("failed to get NUMA memory information from SRAT table\n"); | 271 | printk("failed to get NUMA memory information from SRAT table\n"); |
374 | return 0; | 272 | return 0; |
375 | } | 273 | } |