aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memblock.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index 1c2ef2c7edab..9c0aeef19440 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -266,31 +266,34 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
266 } 266 }
267} 267}
268 268
269#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
270
269phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info( 271phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
270 phys_addr_t *addr) 272 phys_addr_t *addr)
271{ 273{
272 if (memblock.reserved.regions == memblock_reserved_init_regions) 274 if (memblock.reserved.regions == memblock_reserved_init_regions)
273 return 0; 275 return 0;
274 276
275 /*
276 * Don't allow nobootmem allocator to free reserved memory regions
277 * array if
278 * - CONFIG_DEBUG_FS is enabled;
279 * - CONFIG_ARCH_DISCARD_MEMBLOCK is not enabled;
280 * - reserved memory regions array have been resized during boot.
281 * Otherwise debug_fs entry "sys/kernel/debug/memblock/reserved"
282 * will show garbage instead of state of memory reservations.
283 */
284 if (IS_ENABLED(CONFIG_DEBUG_FS) &&
285 !IS_ENABLED(CONFIG_ARCH_DISCARD_MEMBLOCK))
286 return 0;
287
288 *addr = __pa(memblock.reserved.regions); 277 *addr = __pa(memblock.reserved.regions);
289 278
290 return PAGE_ALIGN(sizeof(struct memblock_region) * 279 return PAGE_ALIGN(sizeof(struct memblock_region) *
291 memblock.reserved.max); 280 memblock.reserved.max);
292} 281}
293 282
283phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
284 phys_addr_t *addr)
285{
286 if (memblock.memory.regions == memblock_memory_init_regions)
287 return 0;
288
289 *addr = __pa(memblock.memory.regions);
290
291 return PAGE_ALIGN(sizeof(struct memblock_region) *
292 memblock.memory.max);
293}
294
295#endif
296
294/** 297/**
295 * memblock_double_array - double the size of the memblock regions array 298 * memblock_double_array - double the size of the memblock regions array
296 * @type: memblock type of the regions array being doubled 299 * @type: memblock type of the regions array being doubled