diff options
author | Yinghai Lu <yinghai@kernel.org> | 2013-01-25 00:20:09 +0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2013-01-30 07:32:57 +0400 |
commit | 595ad9af8584908ea5fb698b836169d05b99f186 (patch) | |
tree | 851492cc2fa5c02b4b5122b7af154f7a8d7777c3 /mm/memblock.c | |
parent | d1af6d045fba6b070fa81f54dfe9227214be99ea (diff) | |
download | linux-595ad9af8584908ea5fb698b836169d05b99f186.tar.xz |
memblock: Add memblock_mem_size()
Use it to get mem size under the limit_pfn.
to replace local version in x86 reserved_initrd.
-v2: remove not needed cast that is pointed out by HPA.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1359058816-7615-29-git-send-email-yinghai@kernel.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r-- | mm/memblock.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mm/memblock.c b/mm/memblock.c index 88adc8afb610..b8d9147e5c08 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -828,6 +828,23 @@ phys_addr_t __init memblock_phys_mem_size(void) return memblock.memory.total_size; } +phys_addr_t __init memblock_mem_size(unsigned long limit_pfn) +{ + unsigned long pages = 0; + struct memblock_region *r; + unsigned long start_pfn, end_pfn; + + for_each_memblock(memory, r) { + start_pfn = memblock_region_memory_base_pfn(r); + end_pfn = memblock_region_memory_end_pfn(r); + start_pfn = min_t(unsigned long, start_pfn, limit_pfn); + end_pfn = min_t(unsigned long, end_pfn, limit_pfn); + pages += end_pfn - start_pfn; + } + + return (phys_addr_t)pages << PAGE_SHIFT; +} + /* lowest address */ phys_addr_t __init_memblock memblock_start_of_DRAM(void) { |