diff options
Diffstat (limited to 'mm/memblock.c')
-rw-r--r-- | mm/memblock.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/mm/memblock.c b/mm/memblock.c index 945dc31258eb..b44875f5a996 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -804,44 +804,28 @@ phys_addr_t __init_memblock memblock_end_of_DRAM(void) | |||
804 | } | 804 | } |
805 | 805 | ||
806 | /* You must call memblock_analyze() after this. */ | 806 | /* You must call memblock_analyze() after this. */ |
807 | void __init memblock_enforce_memory_limit(phys_addr_t memory_limit) | 807 | void __init memblock_enforce_memory_limit(phys_addr_t limit) |
808 | { | 808 | { |
809 | unsigned long i; | 809 | unsigned long i; |
810 | phys_addr_t limit; | 810 | phys_addr_t max_addr = (phys_addr_t)ULLONG_MAX; |
811 | struct memblock_region *p; | ||
812 | 811 | ||
813 | if (!memory_limit) | 812 | if (!limit) |
814 | return; | 813 | return; |
815 | 814 | ||
816 | /* Truncate the memblock regions to satisfy the memory limit. */ | 815 | /* find out max address */ |
817 | limit = memory_limit; | ||
818 | for (i = 0; i < memblock.memory.cnt; i++) { | 816 | for (i = 0; i < memblock.memory.cnt; i++) { |
819 | if (limit > memblock.memory.regions[i].size) { | 817 | struct memblock_region *r = &memblock.memory.regions[i]; |
820 | limit -= memblock.memory.regions[i].size; | ||
821 | continue; | ||
822 | } | ||
823 | |||
824 | memblock.memory.regions[i].size = limit; | ||
825 | memblock.memory.cnt = i + 1; | ||
826 | break; | ||
827 | } | ||
828 | |||
829 | memory_limit = memblock_end_of_DRAM(); | ||
830 | 818 | ||
831 | /* And truncate any reserves above the limit also. */ | 819 | if (limit <= r->size) { |
832 | for (i = 0; i < memblock.reserved.cnt; i++) { | 820 | max_addr = r->base + limit; |
833 | p = &memblock.reserved.regions[i]; | 821 | break; |
834 | |||
835 | if (p->base > memory_limit) | ||
836 | p->size = 0; | ||
837 | else if ((p->base + p->size) > memory_limit) | ||
838 | p->size = memory_limit - p->base; | ||
839 | |||
840 | if (p->size == 0) { | ||
841 | memblock_remove_region(&memblock.reserved, i); | ||
842 | i--; | ||
843 | } | 822 | } |
823 | limit -= r->size; | ||
844 | } | 824 | } |
825 | |||
826 | /* truncate both memory and reserved regions */ | ||
827 | __memblock_remove(&memblock.memory, max_addr, (phys_addr_t)ULLONG_MAX); | ||
828 | __memblock_remove(&memblock.reserved, max_addr, (phys_addr_t)ULLONG_MAX); | ||
845 | } | 829 | } |
846 | 830 | ||
847 | static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr) | 831 | static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr) |