diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-08 05:14:58 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-08 05:14:58 -0400 |
commit | 3de352bbd86f890dd0c5e1c09a6a1b0b29e0f8ce (patch) | |
tree | d4c5eba8cd2abefd7c9f16d089393f0f5999cf63 /arch/x86/kernel/srat_32.c | |
parent | 1b8ba39a3fad9c58532f6dad12c94d6e675be656 (diff) | |
parent | 9340e1ccdf7b9b22a2be7f51cd74e8b5e11961bf (diff) |
Merge branch 'x86/mpparse' into x86/devel
Conflicts:
arch/x86/Kconfig
arch/x86/kernel/io_apic_32.c
arch/x86/kernel/setup_64.c
arch/x86/mm/init_32.c
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 | 191 |
1 files changed, 53 insertions, 138 deletions
diff --git a/arch/x86/kernel/srat_32.c b/arch/x86/kernel/srat_32.c index 70e4a374b4e8..5978023b799b 100644 --- a/arch/x86/kernel/srat_32.c +++ b/arch/x86/kernel/srat_32.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <asm/srat.h> | 31 | #include <asm/srat.h> |
32 | #include <asm/topology.h> | 32 | #include <asm/topology.h> |
33 | #include <asm/smp.h> | 33 | #include <asm/smp.h> |
34 | #include <asm/e820.h> | ||
34 | 35 | ||
35 | /* | 36 | /* |
36 | * proximity macros and definitions | 37 | * proximity macros and definitions |
@@ -41,7 +42,7 @@ | |||
41 | #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))) |
42 | /* bitmap length; _PXM is at most 255 */ | 43 | /* bitmap length; _PXM is at most 255 */ |
43 | #define PXM_BITMAP_LEN (MAX_PXM_DOMAINS / 8) | 44 | #define PXM_BITMAP_LEN (MAX_PXM_DOMAINS / 8) |
44 | static u8 pxm_bitmap[PXM_BITMAP_LEN]; /* bitmap of proximity domains */ | 45 | static u8 __initdata pxm_bitmap[PXM_BITMAP_LEN]; /* bitmap of proximity domains */ |
45 | 46 | ||
46 | #define MAX_CHUNKS_PER_NODE 3 | 47 | #define MAX_CHUNKS_PER_NODE 3 |
47 | #define MAXCHUNKS (MAX_CHUNKS_PER_NODE * MAX_NUMNODES) | 48 | #define MAXCHUNKS (MAX_CHUNKS_PER_NODE * MAX_NUMNODES) |
@@ -52,16 +53,37 @@ struct node_memory_chunk_s { | |||
52 | u8 nid; // which cnode contains this chunk? | 53 | u8 nid; // which cnode contains this chunk? |
53 | u8 bank; // which mem bank on this node | 54 | u8 bank; // which mem bank on this node |
54 | }; | 55 | }; |
55 | static struct node_memory_chunk_s node_memory_chunk[MAXCHUNKS]; | 56 | static struct node_memory_chunk_s __initdata node_memory_chunk[MAXCHUNKS]; |
56 | 57 | ||
57 | static int num_memory_chunks; /* total number of memory chunks */ | 58 | static int __initdata num_memory_chunks; /* total number of memory chunks */ |
58 | static u8 __initdata apicid_to_pxm[MAX_APICID]; | 59 | static u8 __initdata apicid_to_pxm[MAX_APICID]; |
59 | 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 | |||
60 | /* Identify CPU proximity domains */ | 76 | /* Identify CPU proximity domains */ |
61 | 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) | ||
62 | { | 79 | { |
63 | struct acpi_srat_cpu_affinity *cpu_affinity = | 80 | if (srat_disabled()) |
64 | (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 | } | ||
65 | 87 | ||
66 | if ((cpu_affinity->flags & ACPI_SRAT_CPU_ENABLED) == 0) | 88 | if ((cpu_affinity->flags & ACPI_SRAT_CPU_ENABLED) == 0) |
67 | return; /* empty entry */ | 89 | return; /* empty entry */ |
@@ -79,14 +101,21 @@ static void __init parse_cpu_affinity_structure(char *p) | |||
79 | * Identify memory proximity domains and hot-remove capabilities. | 101 | * Identify memory proximity domains and hot-remove capabilities. |
80 | * Fill node memory chunk list structure. | 102 | * Fill node memory chunk list structure. |
81 | */ | 103 | */ |
82 | 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) | ||
83 | { | 106 | { |
84 | unsigned long long paddr, size; | 107 | unsigned long long paddr, size; |
85 | unsigned long start_pfn, end_pfn; | 108 | unsigned long start_pfn, end_pfn; |
86 | u8 pxm; | 109 | u8 pxm; |
87 | struct node_memory_chunk_s *p, *q, *pend; | 110 | struct node_memory_chunk_s *p, *q, *pend; |
88 | struct acpi_srat_mem_affinity *memory_affinity = | 111 | |
89 | (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 | } | ||
90 | 119 | ||
91 | if ((memory_affinity->flags & ACPI_SRAT_MEM_ENABLED) == 0) | 120 | if ((memory_affinity->flags & ACPI_SRAT_MEM_ENABLED) == 0) |
92 | return; /* empty entry */ | 121 | return; /* empty entry */ |
@@ -134,6 +163,14 @@ static void __init parse_memory_affinity_structure (char *sratp) | |||
134 | "enabled and removable" : "enabled" ) ); | 163 | "enabled and removable" : "enabled" ) ); |
135 | } | 164 | } |
136 | 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 | } | ||
137 | /* | 174 | /* |
138 | * The SRAT table always lists ascending addresses, so can always | 175 | * The SRAT table always lists ascending addresses, so can always |
139 | * 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 |
@@ -166,39 +203,13 @@ static __init void node_read_chunk(int nid, struct node_memory_chunk_s *memory_c | |||
166 | node_end_pfn[nid] = memory_chunk->end_pfn; | 203 | node_end_pfn[nid] = memory_chunk->end_pfn; |
167 | } | 204 | } |
168 | 205 | ||
169 | /* Parse the ACPI Static Resource Affinity Table */ | 206 | int __init get_memcfg_from_srat(void) |
170 | static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) | ||
171 | { | 207 | { |
172 | u8 *start, *end, *p; | ||
173 | int i, j, nid; | 208 | int i, j, nid; |
174 | 209 | ||
175 | start = (u8 *)(&(sratp->reserved) + 1); /* skip header */ | ||
176 | p = start; | ||
177 | end = (u8 *)sratp + sratp->header.length; | ||
178 | |||
179 | memset(pxm_bitmap, 0, sizeof(pxm_bitmap)); /* init proximity domain bitmap */ | ||
180 | memset(node_memory_chunk, 0, sizeof(node_memory_chunk)); | ||
181 | 210 | ||
182 | num_memory_chunks = 0; | 211 | if (srat_disabled()) |
183 | while (p < end) { | 212 | goto out_fail; |
184 | switch (*p) { | ||
185 | case ACPI_SRAT_TYPE_CPU_AFFINITY: | ||
186 | parse_cpu_affinity_structure(p); | ||
187 | break; | ||
188 | case ACPI_SRAT_TYPE_MEMORY_AFFINITY: | ||
189 | parse_memory_affinity_structure(p); | ||
190 | break; | ||
191 | default: | ||
192 | printk("ACPI 2.0 SRAT: unknown entry skipped: type=0x%02X, len=%d\n", p[0], p[1]); | ||
193 | break; | ||
194 | } | ||
195 | p += p[1]; | ||
196 | if (p[1] == 0) { | ||
197 | printk("acpi20_parse_srat: Entry length value is zero;" | ||
198 | " can't parse any further!\n"); | ||
199 | break; | ||
200 | } | ||
201 | } | ||
202 | 213 | ||
203 | if (num_memory_chunks == 0) { | 214 | if (num_memory_chunks == 0) { |
204 | printk("could not finy any ACPI SRAT memory areas.\n"); | 215 | printk("could not finy any ACPI SRAT memory areas.\n"); |
@@ -244,115 +255,19 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) | |||
244 | printk("chunk %d nid %d start_pfn %08lx end_pfn %08lx\n", | 255 | printk("chunk %d nid %d start_pfn %08lx end_pfn %08lx\n", |
245 | j, chunk->nid, chunk->start_pfn, chunk->end_pfn); | 256 | j, chunk->nid, chunk->start_pfn, chunk->end_pfn); |
246 | node_read_chunk(chunk->nid, chunk); | 257 | node_read_chunk(chunk->nid, chunk); |
247 | add_active_range(chunk->nid, chunk->start_pfn, chunk->end_pfn); | 258 | e820_register_active_regions(chunk->nid, chunk->start_pfn, |
259 | min(chunk->end_pfn, max_pfn)); | ||
248 | } | 260 | } |
249 | 261 | ||
250 | for_each_online_node(nid) { | 262 | for_each_online_node(nid) { |
251 | unsigned long start = node_start_pfn[nid]; | 263 | unsigned long start = node_start_pfn[nid]; |
252 | unsigned long end = node_end_pfn[nid]; | 264 | unsigned long end = min(node_end_pfn[nid], max_pfn); |
253 | 265 | ||
254 | memory_present(nid, start, end); | 266 | memory_present(nid, start, end); |
255 | node_remap_size[nid] = node_memmap_size_bytes(nid, start, end); | 267 | node_remap_size[nid] = node_memmap_size_bytes(nid, start, end); |
256 | } | 268 | } |
257 | return 1; | 269 | return 1; |
258 | out_fail: | 270 | out_fail: |
259 | return 0; | ||
260 | } | ||
261 | |||
262 | struct acpi_static_rsdt { | ||
263 | struct acpi_table_rsdt table; | ||
264 | u32 padding[7]; /* Allow for 7 more table entries */ | ||
265 | }; | ||
266 | |||
267 | int __init get_memcfg_from_srat(void) | ||
268 | { | ||
269 | struct acpi_table_header *header = NULL; | ||
270 | struct acpi_table_rsdp *rsdp = NULL; | ||
271 | struct acpi_table_rsdt *rsdt = NULL; | ||
272 | acpi_native_uint rsdp_address = 0; | ||
273 | struct acpi_static_rsdt saved_rsdt; | ||
274 | int tables = 0; | ||
275 | int i = 0; | ||
276 | |||
277 | rsdp_address = acpi_os_get_root_pointer(); | ||
278 | if (!rsdp_address) { | ||
279 | printk("%s: System description tables not found\n", | ||
280 | __func__); | ||
281 | goto out_err; | ||
282 | } | ||
283 | |||
284 | printk("%s: assigning address to rsdp\n", __func__); | ||
285 | rsdp = (struct acpi_table_rsdp *)(u32)rsdp_address; | ||
286 | if (!rsdp) { | ||
287 | printk("%s: Didn't find ACPI root!\n", __func__); | ||
288 | goto out_err; | ||
289 | } | ||
290 | |||
291 | printk(KERN_INFO "%.8s v%d [%.6s]\n", rsdp->signature, rsdp->revision, | ||
292 | rsdp->oem_id); | ||
293 | |||
294 | if (strncmp(rsdp->signature, ACPI_SIG_RSDP,strlen(ACPI_SIG_RSDP))) { | ||
295 | printk(KERN_WARNING "%s: RSDP table signature incorrect\n", __func__); | ||
296 | goto out_err; | ||
297 | } | ||
298 | |||
299 | rsdt = (struct acpi_table_rsdt *) | ||
300 | early_ioremap(rsdp->rsdt_physical_address, sizeof(struct acpi_table_rsdt)); | ||
301 | |||
302 | if (!rsdt) { | ||
303 | printk(KERN_WARNING | ||
304 | "%s: ACPI: Invalid root system description tables (RSDT)\n", | ||
305 | __func__); | ||
306 | goto out_err; | ||
307 | } | ||
308 | |||
309 | header = &rsdt->header; | ||
310 | |||
311 | if (strncmp(header->signature, ACPI_SIG_RSDT, strlen(ACPI_SIG_RSDT))) { | ||
312 | printk(KERN_WARNING "ACPI: RSDT signature incorrect\n"); | ||
313 | goto out_err; | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * The number of tables is computed by taking the | ||
318 | * size of all entries (header size minus total | ||
319 | * size of RSDT) divided by the size of each entry | ||
320 | * (4-byte table pointers). | ||
321 | */ | ||
322 | tables = (header->length - sizeof(struct acpi_table_header)) / 4; | ||
323 | |||
324 | if (!tables) | ||
325 | goto out_err; | ||
326 | |||
327 | memcpy(&saved_rsdt, rsdt, sizeof(saved_rsdt)); | ||
328 | |||
329 | if (saved_rsdt.table.header.length > sizeof(saved_rsdt)) { | ||
330 | printk(KERN_WARNING "ACPI: Too big length in RSDT: %d\n", | ||
331 | saved_rsdt.table.header.length); | ||
332 | goto out_err; | ||
333 | } | ||
334 | |||
335 | printk("Begin SRAT table scan....\n"); | ||
336 | |||
337 | for (i = 0; i < tables; i++) { | ||
338 | /* Map in header, then map in full table length. */ | ||
339 | header = (struct acpi_table_header *) | ||
340 | early_ioremap(saved_rsdt.table.table_offset_entry[i], sizeof(struct acpi_table_header)); | ||
341 | if (!header) | ||
342 | break; | ||
343 | header = (struct acpi_table_header *) | ||
344 | early_ioremap(saved_rsdt.table.table_offset_entry[i], header->length); | ||
345 | if (!header) | ||
346 | break; | ||
347 | |||
348 | if (strncmp((char *) &header->signature, ACPI_SIG_SRAT, 4)) | ||
349 | continue; | ||
350 | |||
351 | /* we've found the srat table. don't need to look at any more tables */ | ||
352 | return acpi20_parse_srat((struct acpi_table_srat *)header); | ||
353 | } | ||
354 | out_err: | ||
355 | remove_all_active_ranges(); | ||
356 | printk("failed to get NUMA memory information from SRAT table\n"); | 271 | printk("failed to get NUMA memory information from SRAT table\n"); |
357 | return 0; | 272 | return 0; |
358 | } | 273 | } |