aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-07-06 18:39:01 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-08-04 22:56:07 -0400
commite63075a3c9377536d085bc013cd3fe6323162449 (patch)
tree28fde124dde6df867947882fc686d228502846df /arch/powerpc/kernel
parent27f574c223d2c09610058b3ec7a29582d63a3e06 (diff)
memblock: Introduce default allocation limit and use it to replace explicit ones
This introduce memblock.current_limit which is used to limit allocations from memblock_alloc() or memblock_alloc_base(..., MEMBLOCK_ALLOC_ACCESSIBLE). The old MEMBLOCK_ALLOC_ANYWHERE changes value from 0 to ~(u64)0 and can still be used with memblock_alloc_base() to allocate really anywhere. It is -no-longer- cropped to MEMBLOCK_REAL_LIMIT which disappears. Note to archs: I'm leaving the default limit to MEMBLOCK_ALLOC_ANYWHERE. I strongly recommend that you ensure that you set an appropriate limit during boot in order to guarantee that an memblock_alloc() at any time results in something that is accessible with a simple __va(). The reason is that a subsequent patch will introduce the ability for the array to resize itself by reallocating itself. The MEMBLOCK core will honor the current limit when performing those allocations. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/prom.c20
-rw-r--r--arch/powerpc/kernel/setup_32.c2
2 files changed, 20 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index fed9bf6187d1..3aec0b980f6a 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -98,7 +98,7 @@ static void __init move_device_tree(void)
98 98
99 if ((memory_limit && (start + size) > memory_limit) || 99 if ((memory_limit && (start + size) > memory_limit) ||
100 overlaps_crashkernel(start, size)) { 100 overlaps_crashkernel(start, size)) {
101 p = __va(memblock_alloc_base(size, PAGE_SIZE, memblock.rmo_size)); 101 p = __va(memblock_alloc(size, PAGE_SIZE));
102 memcpy(p, initial_boot_params, size); 102 memcpy(p, initial_boot_params, size);
103 initial_boot_params = (struct boot_param_header *)p; 103 initial_boot_params = (struct boot_param_header *)p;
104 DBG("Moved device tree to 0x%p\n", p); 104 DBG("Moved device tree to 0x%p\n", p);
@@ -655,6 +655,21 @@ static void __init phyp_dump_reserve_mem(void)
655static inline void __init phyp_dump_reserve_mem(void) {} 655static inline void __init phyp_dump_reserve_mem(void) {}
656#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */ 656#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */
657 657
658static void set_boot_memory_limit(void)
659{
660#ifdef CONFIG_PPC32
661 /* 601 can only access 16MB at the moment */
662 if (PVR_VER(mfspr(SPRN_PVR)) == 1)
663 memblock_set_current_limit(0x01000000);
664 /* 8xx can only access 8MB at the moment */
665 else if (PVR_VER(mfspr(SPRN_PVR)) == 0x50)
666 memblock_set_current_limit(0x00800000);
667 else
668 memblock_set_current_limit(0x10000000);
669#else
670 memblock_set_current_limit(memblock.rmo_size);
671#endif
672}
658 673
659void __init early_init_devtree(void *params) 674void __init early_init_devtree(void *params)
660{ 675{
@@ -683,6 +698,7 @@ void __init early_init_devtree(void *params)
683 698
684 /* Scan memory nodes and rebuild MEMBLOCKs */ 699 /* Scan memory nodes and rebuild MEMBLOCKs */
685 memblock_init(); 700 memblock_init();
701
686 of_scan_flat_dt(early_init_dt_scan_root, NULL); 702 of_scan_flat_dt(early_init_dt_scan_root, NULL);
687 of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); 703 of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
688 704
@@ -718,6 +734,8 @@ void __init early_init_devtree(void *params)
718 734
719 DBG("Phys. mem: %llx\n", memblock_phys_mem_size()); 735 DBG("Phys. mem: %llx\n", memblock_phys_mem_size());
720 736
737 set_boot_memory_limit();
738
721 /* We may need to relocate the flat tree, do it now. 739 /* We may need to relocate the flat tree, do it now.
722 * FIXME .. and the initrd too? */ 740 * FIXME .. and the initrd too? */
723 move_device_tree(); 741 move_device_tree();
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index a10ffc85ada7..b7eb1ded3b5f 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -246,7 +246,7 @@ static void __init irqstack_early_init(void)
246 unsigned int i; 246 unsigned int i;
247 247
248 /* interrupt stacks must be in lowmem, we get that for free on ppc32 248 /* interrupt stacks must be in lowmem, we get that for free on ppc32
249 * as the memblock is limited to lowmem by MEMBLOCK_REAL_LIMIT */ 249 * as the memblock is limited to lowmem by default */
250 for_each_possible_cpu(i) { 250 for_each_possible_cpu(i) {
251 softirq_ctx[i] = (struct thread_info *) 251 softirq_ctx[i] = (struct thread_info *)
252 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE)); 252 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));