aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/memblock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/memblock.h')
-rw-r--r--include/linux/memblock.h151
1 files changed, 147 insertions, 4 deletions
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 9d46a7204975..1b4d85879cbe 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -15,6 +15,19 @@
15 15
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <asm/dma.h>
19
20extern unsigned long max_low_pfn;
21extern unsigned long min_low_pfn;
22
23/*
24 * highest page
25 */
26extern unsigned long max_pfn;
27/*
28 * highest possible page
29 */
30extern unsigned long long max_possible_pfn;
18 31
19#define INIT_MEMBLOCK_REGIONS 128 32#define INIT_MEMBLOCK_REGIONS 128
20#define INIT_PHYSMEM_REGIONS 4 33#define INIT_PHYSMEM_REGIONS 4
@@ -119,6 +132,10 @@ int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
119int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); 132int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
120enum memblock_flags choose_memblock_flags(void); 133enum memblock_flags choose_memblock_flags(void);
121 134
135unsigned long memblock_free_all(void);
136void reset_node_managed_pages(pg_data_t *pgdat);
137void reset_all_zones_managed_pages(void);
138
122/* Low level functions */ 139/* Low level functions */
123int memblock_add_range(struct memblock_type *type, 140int memblock_add_range(struct memblock_type *type,
124 phys_addr_t base, phys_addr_t size, 141 phys_addr_t base, phys_addr_t size,
@@ -300,11 +317,116 @@ static inline int memblock_get_region_node(const struct memblock_region *r)
300} 317}
301#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ 318#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
302 319
320/* Flags for memblock allocation APIs */
321#define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0)
322#define MEMBLOCK_ALLOC_ACCESSIBLE 0
323
324/* We are using top down, so it is safe to use 0 here */
325#define MEMBLOCK_LOW_LIMIT 0
326
327#ifndef ARCH_LOW_ADDRESS_LIMIT
328#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
329#endif
330
303phys_addr_t memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); 331phys_addr_t memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align, int nid);
304phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); 332phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid);
305 333
306phys_addr_t memblock_phys_alloc(phys_addr_t size, phys_addr_t align); 334phys_addr_t memblock_phys_alloc(phys_addr_t size, phys_addr_t align);
307 335
336void *memblock_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align,
337 phys_addr_t min_addr, phys_addr_t max_addr,
338 int nid);
339void *memblock_alloc_try_nid_nopanic(phys_addr_t size, phys_addr_t align,
340 phys_addr_t min_addr, phys_addr_t max_addr,
341 int nid);
342void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align,
343 phys_addr_t min_addr, phys_addr_t max_addr,
344 int nid);
345
346static inline void * __init memblock_alloc(phys_addr_t size, phys_addr_t align)
347{
348 return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT,
349 MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE);
350}
351
352static inline void * __init memblock_alloc_raw(phys_addr_t size,
353 phys_addr_t align)
354{
355 return memblock_alloc_try_nid_raw(size, align, MEMBLOCK_LOW_LIMIT,
356 MEMBLOCK_ALLOC_ACCESSIBLE,
357 NUMA_NO_NODE);
358}
359
360static inline void * __init memblock_alloc_from(phys_addr_t size,
361 phys_addr_t align,
362 phys_addr_t min_addr)
363{
364 return memblock_alloc_try_nid(size, align, min_addr,
365 MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE);
366}
367
368static inline void * __init memblock_alloc_nopanic(phys_addr_t size,
369 phys_addr_t align)
370{
371 return memblock_alloc_try_nid_nopanic(size, align, MEMBLOCK_LOW_LIMIT,
372 MEMBLOCK_ALLOC_ACCESSIBLE,
373 NUMA_NO_NODE);
374}
375
376static inline void * __init memblock_alloc_low(phys_addr_t size,
377 phys_addr_t align)
378{
379 return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT,
380 ARCH_LOW_ADDRESS_LIMIT, NUMA_NO_NODE);
381}
382static inline void * __init memblock_alloc_low_nopanic(phys_addr_t size,
383 phys_addr_t align)
384{
385 return memblock_alloc_try_nid_nopanic(size, align, MEMBLOCK_LOW_LIMIT,
386 ARCH_LOW_ADDRESS_LIMIT,
387 NUMA_NO_NODE);
388}
389
390static inline void * __init memblock_alloc_from_nopanic(phys_addr_t size,
391 phys_addr_t align,
392 phys_addr_t min_addr)
393{
394 return memblock_alloc_try_nid_nopanic(size, align, min_addr,
395 MEMBLOCK_ALLOC_ACCESSIBLE,
396 NUMA_NO_NODE);
397}
398
399static inline void * __init memblock_alloc_node(phys_addr_t size,
400 phys_addr_t align, int nid)
401{
402 return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT,
403 MEMBLOCK_ALLOC_ACCESSIBLE, nid);
404}
405
406static inline void * __init memblock_alloc_node_nopanic(phys_addr_t size,
407 int nid)
408{
409 return memblock_alloc_try_nid_nopanic(size, 0, MEMBLOCK_LOW_LIMIT,
410 MEMBLOCK_ALLOC_ACCESSIBLE, nid);
411}
412
413static inline void __init memblock_free_early(phys_addr_t base,
414 phys_addr_t size)
415{
416 __memblock_free_early(base, size);
417}
418
419static inline void __init memblock_free_early_nid(phys_addr_t base,
420 phys_addr_t size, int nid)
421{
422 __memblock_free_early(base, size);
423}
424
425static inline void __init memblock_free_late(phys_addr_t base, phys_addr_t size)
426{
427 __memblock_free_late(base, size);
428}
429
308/* 430/*
309 * Set the allocation direction to bottom-up or top-down. 431 * Set the allocation direction to bottom-up or top-down.
310 */ 432 */
@@ -323,10 +445,6 @@ static inline bool memblock_bottom_up(void)
323 return memblock.bottom_up; 445 return memblock.bottom_up;
324} 446}
325 447
326/* Flags for memblock_alloc_base() amd __memblock_alloc_base() */
327#define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0)
328#define MEMBLOCK_ALLOC_ACCESSIBLE 0
329
330phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, 448phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align,
331 phys_addr_t start, phys_addr_t end, 449 phys_addr_t start, phys_addr_t end,
332 enum memblock_flags flags); 450 enum memblock_flags flags);
@@ -432,6 +550,31 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
432 i < memblock_type->cnt; \ 550 i < memblock_type->cnt; \
433 i++, rgn = &memblock_type->regions[i]) 551 i++, rgn = &memblock_type->regions[i])
434 552
553extern void *alloc_large_system_hash(const char *tablename,
554 unsigned long bucketsize,
555 unsigned long numentries,
556 int scale,
557 int flags,
558 unsigned int *_hash_shift,
559 unsigned int *_hash_mask,
560 unsigned long low_limit,
561 unsigned long high_limit);
562
563#define HASH_EARLY 0x00000001 /* Allocating during early boot? */
564#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min
565 * shift passed via *_hash_shift */
566#define HASH_ZERO 0x00000004 /* Zero allocated hash table */
567
568/* Only NUMA needs hash distribution. 64bit NUMA architectures have
569 * sufficient vmalloc space.
570 */
571#ifdef CONFIG_NUMA
572#define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT)
573extern int hashdist; /* Distribute hashes across NUMA nodes? */
574#else
575#define hashdist (0)
576#endif
577
435#ifdef CONFIG_MEMTEST 578#ifdef CONFIG_MEMTEST
436extern void early_memtest(phys_addr_t start, phys_addr_t end); 579extern void early_memtest(phys_addr_t start, phys_addr_t end);
437#else 580#else