aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/mm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ia64/mm')
-rw-r--r--arch/ia64/mm/contig.c67
-rw-r--r--arch/ia64/mm/discontig.c44
-rw-r--r--arch/ia64/mm/init.c12
3 files changed, 36 insertions, 87 deletions
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 537c2f3833ee..daf977ff2920 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -26,7 +26,6 @@
26#include <asm/mca.h> 26#include <asm/mca.h>
27 27
28#ifdef CONFIG_VIRTUAL_MEM_MAP 28#ifdef CONFIG_VIRTUAL_MEM_MAP
29static unsigned long num_dma_physpages;
30static unsigned long max_gap; 29static unsigned long max_gap;
31#endif 30#endif
32 31
@@ -219,18 +218,6 @@ count_pages (u64 start, u64 end, void *arg)
219 return 0; 218 return 0;
220} 219}
221 220
222#ifdef CONFIG_VIRTUAL_MEM_MAP
223static int
224count_dma_pages (u64 start, u64 end, void *arg)
225{
226 unsigned long *count = arg;
227
228 if (start < MAX_DMA_ADDRESS)
229 *count += (min(end, MAX_DMA_ADDRESS) - start) >> PAGE_SHIFT;
230 return 0;
231}
232#endif
233
234/* 221/*
235 * Set up the page tables. 222 * Set up the page tables.
236 */ 223 */
@@ -239,45 +226,22 @@ void __init
239paging_init (void) 226paging_init (void)
240{ 227{
241 unsigned long max_dma; 228 unsigned long max_dma;
242 unsigned long zones_size[MAX_NR_ZONES]; 229 unsigned long nid = 0;
243#ifdef CONFIG_VIRTUAL_MEM_MAP 230 unsigned long max_zone_pfns[MAX_NR_ZONES];
244 unsigned long zholes_size[MAX_NR_ZONES];
245#endif
246
247 /* initialize mem_map[] */
248
249 memset(zones_size, 0, sizeof(zones_size));
250 231
251 num_physpages = 0; 232 num_physpages = 0;
252 efi_memmap_walk(count_pages, &num_physpages); 233 efi_memmap_walk(count_pages, &num_physpages);
253 234
254 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT; 235 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
236 max_zone_pfns[ZONE_DMA] = max_dma;
237 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
255 238
256#ifdef CONFIG_VIRTUAL_MEM_MAP 239#ifdef CONFIG_VIRTUAL_MEM_MAP
257 memset(zholes_size, 0, sizeof(zholes_size)); 240 efi_memmap_walk(register_active_ranges, &nid);
258
259 num_dma_physpages = 0;
260 efi_memmap_walk(count_dma_pages, &num_dma_physpages);
261
262 if (max_low_pfn < max_dma) {
263 zones_size[ZONE_DMA] = max_low_pfn;
264 zholes_size[ZONE_DMA] = max_low_pfn - num_dma_physpages;
265 } else {
266 zones_size[ZONE_DMA] = max_dma;
267 zholes_size[ZONE_DMA] = max_dma - num_dma_physpages;
268 if (num_physpages > num_dma_physpages) {
269 zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
270 zholes_size[ZONE_NORMAL] =
271 ((max_low_pfn - max_dma) -
272 (num_physpages - num_dma_physpages));
273 }
274 }
275
276 efi_memmap_walk(find_largest_hole, (u64 *)&max_gap); 241 efi_memmap_walk(find_largest_hole, (u64 *)&max_gap);
277 if (max_gap < LARGE_GAP) { 242 if (max_gap < LARGE_GAP) {
278 vmem_map = (struct page *) 0; 243 vmem_map = (struct page *) 0;
279 free_area_init_node(0, NODE_DATA(0), zones_size, 0, 244 free_area_init_nodes(max_zone_pfns);
280 zholes_size);
281 } else { 245 } else {
282 unsigned long map_size; 246 unsigned long map_size;
283 247
@@ -289,20 +253,19 @@ paging_init (void)
289 vmem_map = (struct page *) vmalloc_end; 253 vmem_map = (struct page *) vmalloc_end;
290 efi_memmap_walk(create_mem_map_page_table, NULL); 254 efi_memmap_walk(create_mem_map_page_table, NULL);
291 255
292 NODE_DATA(0)->node_mem_map = vmem_map; 256 /*
293 free_area_init_node(0, NODE_DATA(0), zones_size, 257 * alloc_node_mem_map makes an adjustment for mem_map
294 0, zholes_size); 258 * which isn't compatible with vmem_map.
259 */
260 NODE_DATA(0)->node_mem_map = vmem_map +
261 find_min_pfn_with_active_regions();
262 free_area_init_nodes(max_zone_pfns);
295 263
296 printk("Virtual mem_map starts at 0x%p\n", mem_map); 264 printk("Virtual mem_map starts at 0x%p\n", mem_map);
297 } 265 }
298#else /* !CONFIG_VIRTUAL_MEM_MAP */ 266#else /* !CONFIG_VIRTUAL_MEM_MAP */
299 if (max_low_pfn < max_dma) 267 add_active_range(0, 0, max_low_pfn);
300 zones_size[ZONE_DMA] = max_low_pfn; 268 free_area_init_nodes(max_zone_pfns);
301 else {
302 zones_size[ZONE_DMA] = max_dma;
303 zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
304 }
305 free_area_init(zones_size);
306#endif /* !CONFIG_VIRTUAL_MEM_MAP */ 269#endif /* !CONFIG_VIRTUAL_MEM_MAP */
307 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page)); 270 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
308} 271}
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 6ea279766334..d497b6b0f5b2 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -654,6 +654,7 @@ static __init int count_node_pages(unsigned long start, unsigned long len, int n
654{ 654{
655 unsigned long end = start + len; 655 unsigned long end = start + len;
656 656
657 add_active_range(node, start >> PAGE_SHIFT, end >> PAGE_SHIFT);
657 mem_data[node].num_physpages += len >> PAGE_SHIFT; 658 mem_data[node].num_physpages += len >> PAGE_SHIFT;
658 if (start <= __pa(MAX_DMA_ADDRESS)) 659 if (start <= __pa(MAX_DMA_ADDRESS))
659 mem_data[node].num_dma_physpages += 660 mem_data[node].num_dma_physpages +=
@@ -678,10 +679,10 @@ static __init int count_node_pages(unsigned long start, unsigned long len, int n
678void __init paging_init(void) 679void __init paging_init(void)
679{ 680{
680 unsigned long max_dma; 681 unsigned long max_dma;
681 unsigned long zones_size[MAX_NR_ZONES];
682 unsigned long zholes_size[MAX_NR_ZONES];
683 unsigned long pfn_offset = 0; 682 unsigned long pfn_offset = 0;
683 unsigned long max_pfn = 0;
684 int node; 684 int node;
685 unsigned long max_zone_pfns[MAX_NR_ZONES];
685 686
686 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT; 687 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
687 688
@@ -698,47 +699,20 @@ void __init paging_init(void)
698#endif 699#endif
699 700
700 for_each_online_node(node) { 701 for_each_online_node(node) {
701 memset(zones_size, 0, sizeof(zones_size));
702 memset(zholes_size, 0, sizeof(zholes_size));
703
704 num_physpages += mem_data[node].num_physpages; 702 num_physpages += mem_data[node].num_physpages;
705
706 if (mem_data[node].min_pfn >= max_dma) {
707 /* All of this node's memory is above ZONE_DMA */
708 zones_size[ZONE_NORMAL] = mem_data[node].max_pfn -
709 mem_data[node].min_pfn;
710 zholes_size[ZONE_NORMAL] = mem_data[node].max_pfn -
711 mem_data[node].min_pfn -
712 mem_data[node].num_physpages;
713 } else if (mem_data[node].max_pfn < max_dma) {
714 /* All of this node's memory is in ZONE_DMA */
715 zones_size[ZONE_DMA] = mem_data[node].max_pfn -
716 mem_data[node].min_pfn;
717 zholes_size[ZONE_DMA] = mem_data[node].max_pfn -
718 mem_data[node].min_pfn -
719 mem_data[node].num_dma_physpages;
720 } else {
721 /* This node has memory in both zones */
722 zones_size[ZONE_DMA] = max_dma -
723 mem_data[node].min_pfn;
724 zholes_size[ZONE_DMA] = zones_size[ZONE_DMA] -
725 mem_data[node].num_dma_physpages;
726 zones_size[ZONE_NORMAL] = mem_data[node].max_pfn -
727 max_dma;
728 zholes_size[ZONE_NORMAL] = zones_size[ZONE_NORMAL] -
729 (mem_data[node].num_physpages -
730 mem_data[node].num_dma_physpages);
731 }
732
733 pfn_offset = mem_data[node].min_pfn; 703 pfn_offset = mem_data[node].min_pfn;
734 704
735#ifdef CONFIG_VIRTUAL_MEM_MAP 705#ifdef CONFIG_VIRTUAL_MEM_MAP
736 NODE_DATA(node)->node_mem_map = vmem_map + pfn_offset; 706 NODE_DATA(node)->node_mem_map = vmem_map + pfn_offset;
737#endif 707#endif
738 free_area_init_node(node, NODE_DATA(node), zones_size, 708 if (mem_data[node].max_pfn > max_pfn)
739 pfn_offset, zholes_size); 709 max_pfn = mem_data[node].max_pfn;
740 } 710 }
741 711
712 max_zone_pfns[ZONE_DMA] = max_dma;
713 max_zone_pfns[ZONE_NORMAL] = max_pfn;
714 free_area_init_nodes(max_zone_pfns);
715
742 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page)); 716 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
743} 717}
744 718
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 30617ccb4f7e..ff87a5cba399 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -593,6 +593,18 @@ find_largest_hole (u64 start, u64 end, void *arg)
593 last_end = end; 593 last_end = end;
594 return 0; 594 return 0;
595} 595}
596
597int __init
598register_active_ranges(u64 start, u64 end, void *nid)
599{
600 BUG_ON(nid == NULL);
601 BUG_ON(*(unsigned long *)nid >= MAX_NUMNODES);
602
603 add_active_range(*(unsigned long *)nid,
604 __pa(start) >> PAGE_SHIFT,
605 __pa(end) >> PAGE_SHIFT);
606 return 0;
607}
596#endif /* CONFIG_VIRTUAL_MEM_MAP */ 608#endif /* CONFIG_VIRTUAL_MEM_MAP */
597 609
598static int __init 610static int __init