diff options
author | Ravikiran G Thirumalai <kiran@scalex86.org> | 2006-01-06 03:11:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 11:33:26 -0500 |
commit | 008857c1a49ccffc31a54c3ea7e182833bd61304 (patch) | |
tree | ba65452db097f57e05d2e3df550d55d45feabc94 | |
parent | 085cc7d5de3cc662da7ea78296464a0d52f3f01f (diff) |
[PATCH] Cleanup bootmem allocator and fix alloc_bootmem_low
Patch cleans up the alloc_bootmem fix for swiotlb. Patch removes
alloc_bootmem_*_limit api and fixes alloc_boot_*low api to do the right
thing -- allocate from low32 memory.
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/linux/bootmem.h | 46 | ||||
-rw-r--r-- | lib/swiotlb.c | 3 | ||||
-rw-r--r-- | mm/bootmem.c | 38 |
3 files changed, 44 insertions, 43 deletions
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 3b03b0b868dd..993da8cc9706 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h | |||
@@ -43,50 +43,38 @@ typedef struct bootmem_data { | |||
43 | extern unsigned long __init bootmem_bootmap_pages (unsigned long); | 43 | extern unsigned long __init bootmem_bootmap_pages (unsigned long); |
44 | extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend); | 44 | extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend); |
45 | extern void __init free_bootmem (unsigned long addr, unsigned long size); | 45 | extern void __init free_bootmem (unsigned long addr, unsigned long size); |
46 | extern void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal, unsigned long limit); | 46 | extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal); |
47 | extern void * __init __alloc_bootmem_low(unsigned long size, | ||
48 | unsigned long align, | ||
49 | unsigned long goal); | ||
50 | extern void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, | ||
51 | unsigned long size, | ||
52 | unsigned long align, | ||
53 | unsigned long goal); | ||
47 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE | 54 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE |
48 | extern void __init reserve_bootmem (unsigned long addr, unsigned long size); | 55 | extern void __init reserve_bootmem (unsigned long addr, unsigned long size); |
49 | #define alloc_bootmem(x) \ | 56 | #define alloc_bootmem(x) \ |
50 | __alloc_bootmem((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) | 57 | __alloc_bootmem((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) |
51 | #define alloc_bootmem_low(x) \ | 58 | #define alloc_bootmem_low(x) \ |
52 | __alloc_bootmem((x), SMP_CACHE_BYTES, 0) | 59 | __alloc_bootmem_low((x), SMP_CACHE_BYTES, 0) |
53 | #define alloc_bootmem_pages(x) \ | 60 | #define alloc_bootmem_pages(x) \ |
54 | __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) | 61 | __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) |
55 | #define alloc_bootmem_low_pages(x) \ | 62 | #define alloc_bootmem_low_pages(x) \ |
56 | __alloc_bootmem((x), PAGE_SIZE, 0) | 63 | __alloc_bootmem_low((x), PAGE_SIZE, 0) |
57 | |||
58 | #define alloc_bootmem_limit(x, limit) \ | ||
59 | __alloc_bootmem_limit((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit)) | ||
60 | #define alloc_bootmem_low_limit(x, limit) \ | ||
61 | __alloc_bootmem_limit((x), SMP_CACHE_BYTES, 0, (limit)) | ||
62 | #define alloc_bootmem_pages_limit(x, limit) \ | ||
63 | __alloc_bootmem_limit((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit)) | ||
64 | #define alloc_bootmem_low_pages_limit(x, limit) \ | ||
65 | __alloc_bootmem_limit((x), PAGE_SIZE, 0, (limit)) | ||
66 | |||
67 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ | 64 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ |
68 | extern unsigned long __init free_all_bootmem (void); | 65 | extern unsigned long __init free_all_bootmem (void); |
69 | 66 | extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal); | |
70 | extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn); | 67 | extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn); |
71 | extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size); | 68 | extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size); |
72 | extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size); | 69 | extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size); |
73 | extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat); | 70 | extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat); |
74 | extern void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal, unsigned long limit); | ||
75 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE | 71 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE |
76 | #define alloc_bootmem_node(pgdat, x) \ | 72 | #define alloc_bootmem_node(pgdat, x) \ |
77 | __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) | 73 | __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) |
78 | #define alloc_bootmem_pages_node(pgdat, x) \ | 74 | #define alloc_bootmem_pages_node(pgdat, x) \ |
79 | __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) | 75 | __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) |
80 | #define alloc_bootmem_low_pages_node(pgdat, x) \ | 76 | #define alloc_bootmem_low_pages_node(pgdat, x) \ |
81 | __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0) | 77 | __alloc_bootmem_low_node((pgdat), (x), PAGE_SIZE, 0) |
82 | |||
83 | #define alloc_bootmem_node_limit(pgdat, x, limit) \ | ||
84 | __alloc_bootmem_node_limit((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit)) | ||
85 | #define alloc_bootmem_pages_node_limit(pgdat, x, limit) \ | ||
86 | __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit)) | ||
87 | #define alloc_bootmem_low_pages_node_limit(pgdat, x, limit) \ | ||
88 | __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, 0, (limit)) | ||
89 | |||
90 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ | 78 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ |
91 | 79 | ||
92 | #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP | 80 | #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP |
@@ -123,15 +111,5 @@ extern void *__init alloc_large_system_hash(const char *tablename, | |||
123 | #endif | 111 | #endif |
124 | extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */ | 112 | extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */ |
125 | 113 | ||
126 | static inline void *__alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal) | ||
127 | { | ||
128 | return __alloc_bootmem_limit(size, align, goal, 0); | ||
129 | } | ||
130 | |||
131 | static inline void *__alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, | ||
132 | unsigned long goal) | ||
133 | { | ||
134 | return __alloc_bootmem_node_limit(pgdat, size, align, goal, 0); | ||
135 | } | ||
136 | 114 | ||
137 | #endif /* _LINUX_BOOTMEM_H */ | 115 | #endif /* _LINUX_BOOTMEM_H */ |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 1ff8dcebf7c6..3b482052f403 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -142,8 +142,7 @@ swiotlb_init_with_default_size (size_t default_size) | |||
142 | /* | 142 | /* |
143 | * Get IO TLB memory from the low pages | 143 | * Get IO TLB memory from the low pages |
144 | */ | 144 | */ |
145 | io_tlb_start = alloc_bootmem_low_pages_limit(io_tlb_nslabs * | 145 | io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs * (1 << IO_TLB_SHIFT)); |
146 | (1 << IO_TLB_SHIFT), 0x100000000); | ||
147 | if (!io_tlb_start) | 146 | if (!io_tlb_start) |
148 | panic("Cannot allocate SWIOTLB buffer"); | 147 | panic("Cannot allocate SWIOTLB buffer"); |
149 | io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT); | 148 | io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT); |
diff --git a/mm/bootmem.c b/mm/bootmem.c index 16b9465eb4eb..cbb82ee14fb5 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -393,15 +393,14 @@ unsigned long __init free_all_bootmem (void) | |||
393 | return(free_all_bootmem_core(NODE_DATA(0))); | 393 | return(free_all_bootmem_core(NODE_DATA(0))); |
394 | } | 394 | } |
395 | 395 | ||
396 | void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal, | 396 | void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal) |
397 | unsigned long limit) | ||
398 | { | 397 | { |
399 | pg_data_t *pgdat = pgdat_list; | 398 | pg_data_t *pgdat = pgdat_list; |
400 | void *ptr; | 399 | void *ptr; |
401 | 400 | ||
402 | for_each_pgdat(pgdat) | 401 | for_each_pgdat(pgdat) |
403 | if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, | 402 | if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, |
404 | align, goal, limit))) | 403 | align, goal, 0))) |
405 | return(ptr); | 404 | return(ptr); |
406 | 405 | ||
407 | /* | 406 | /* |
@@ -413,15 +412,40 @@ void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, un | |||
413 | } | 412 | } |
414 | 413 | ||
415 | 414 | ||
416 | void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align, | 415 | void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, unsigned long align, |
417 | unsigned long goal, unsigned long limit) | 416 | unsigned long goal) |
418 | { | 417 | { |
419 | void *ptr; | 418 | void *ptr; |
420 | 419 | ||
421 | ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal, limit); | 420 | ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal, 0); |
422 | if (ptr) | 421 | if (ptr) |
423 | return (ptr); | 422 | return (ptr); |
424 | 423 | ||
425 | return __alloc_bootmem_limit(size, align, goal, limit); | 424 | return __alloc_bootmem(size, align, goal); |
426 | } | 425 | } |
427 | 426 | ||
427 | #define LOW32LIMIT 0xffffffff | ||
428 | |||
429 | void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal) | ||
430 | { | ||
431 | pg_data_t *pgdat = pgdat_list; | ||
432 | void *ptr; | ||
433 | |||
434 | for_each_pgdat(pgdat) | ||
435 | if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, | ||
436 | align, goal, LOW32LIMIT))) | ||
437 | return(ptr); | ||
438 | |||
439 | /* | ||
440 | * Whoops, we cannot satisfy the allocation request. | ||
441 | */ | ||
442 | printk(KERN_ALERT "low bootmem alloc of %lu bytes failed!\n", size); | ||
443 | panic("Out of low memory"); | ||
444 | return NULL; | ||
445 | } | ||
446 | |||
447 | void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, | ||
448 | unsigned long align, unsigned long goal) | ||
449 | { | ||
450 | return __alloc_bootmem_core(pgdat->bdata, size, align, goal, LOW32LIMIT); | ||
451 | } | ||