diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/memblock.h | 1 | ||||
-rw-r--r-- | arch/x86/mm/memblock.c | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index fc3c230812e6..2c304bb6e072 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h | |||
@@ -16,5 +16,6 @@ void memblock_x86_register_active_regions(int nid, unsigned long start_pfn, | |||
16 | u64 memblock_x86_hole_size(u64 start, u64 end); | 16 | u64 memblock_x86_hole_size(u64 start, u64 end); |
17 | u64 memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size, u64 align); | 17 | u64 memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size, u64 align); |
18 | u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); | 18 | u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); |
19 | u64 memblock_x86_memory_in_range(u64 addr, u64 limit); | ||
19 | 20 | ||
20 | #endif | 21 | #endif |
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 30d60cf29ce3..32ddad5dc932 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c | |||
@@ -211,7 +211,7 @@ void __init memblock_x86_to_bootmem(u64 start, u64 end) | |||
211 | } | 211 | } |
212 | #endif | 212 | #endif |
213 | 213 | ||
214 | u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) | 214 | static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free) |
215 | { | 215 | { |
216 | int i, count; | 216 | int i, count; |
217 | struct range *range; | 217 | struct range *range; |
@@ -240,6 +240,10 @@ u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) | |||
240 | } | 240 | } |
241 | subtract_range(range, count, 0, addr); | 241 | subtract_range(range, count, 0, addr); |
242 | subtract_range(range, count, limit, -1ULL); | 242 | subtract_range(range, count, limit, -1ULL); |
243 | |||
244 | /* Subtract memblock.reserved.region in range ? */ | ||
245 | if (!get_free) | ||
246 | goto sort_and_count_them; | ||
243 | for_each_memblock(reserved, r) { | 247 | for_each_memblock(reserved, r) { |
244 | final_start = PFN_DOWN(r->base); | 248 | final_start = PFN_DOWN(r->base); |
245 | final_end = PFN_UP(r->base + r->size); | 249 | final_end = PFN_UP(r->base + r->size); |
@@ -250,6 +254,8 @@ u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) | |||
250 | 254 | ||
251 | subtract_range(range, count, final_start, final_end); | 255 | subtract_range(range, count, final_start, final_end); |
252 | } | 256 | } |
257 | |||
258 | sort_and_count_them: | ||
253 | nr_range = clean_sort_range(range, count); | 259 | nr_range = clean_sort_range(range, count); |
254 | 260 | ||
255 | free_size = 0; | 261 | free_size = 0; |
@@ -259,6 +265,16 @@ u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) | |||
259 | return free_size << PAGE_SHIFT; | 265 | return free_size << PAGE_SHIFT; |
260 | } | 266 | } |
261 | 267 | ||
268 | u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) | ||
269 | { | ||
270 | return __memblock_x86_memory_in_range(addr, limit, true); | ||
271 | } | ||
272 | |||
273 | u64 __init memblock_x86_memory_in_range(u64 addr, u64 limit) | ||
274 | { | ||
275 | return __memblock_x86_memory_in_range(addr, limit, false); | ||
276 | } | ||
277 | |||
262 | void __init memblock_x86_reserve_range(u64 start, u64 end, char *name) | 278 | void __init memblock_x86_reserve_range(u64 start, u64 end, char *name) |
263 | { | 279 | { |
264 | if (start == end) | 280 | if (start == end) |