aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bootmem.h
diff options
context:
space:
mode:
authorSantosh Shilimkar <santosh.shilimkar@ti.com>2014-01-21 18:50:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-21 19:19:46 -0500
commit26f09e9b3a0696f6fe20b021901300fba26fb579 (patch)
tree1f595392e4f88f44ea47652f799cc80497e1b9e7 /include/linux/bootmem.h
parentb115423357e0cda6d8f45d0c81df537d7b004020 (diff)
mm/memblock: add memblock memory allocation apis
Introduce memblock memory allocation APIs which allow to support PAE or LPAE extension on 32 bits archs where the physical memory start address can be beyond 4GB. In such cases, existing bootmem APIs which operate on 32 bit addresses won't work and needs memblock layer which operates on 64 bit addresses. So we add equivalent APIs so that we can replace usage of bootmem with memblock interfaces. Architectures already converted to NO_BOOTMEM use these new memblock interfaces. The architectures which are still not converted to NO_BOOTMEM continue to function as is because we still maintain the fal lback option of bootmem back-end supporting these new interfaces. So no functional change as such. In long run, once all the architectures moves to NO_BOOTMEM, we can get rid of bootmem layer completely. This is one step to remove the core code dependency with bootmem and also gives path for architectures to move away from bootmem. The proposed interface will became active if both CONFIG_HAVE_MEMBLOCK and CONFIG_NO_BOOTMEM are specified by arch. In case !CONFIG_NO_BOOTMEM, the memblock() wrappers will fallback to the existing bootmem apis so that arch's not converted to NO_BOOTMEM continue to work as is. The meaning of MEMBLOCK_ALLOC_ACCESSIBLE and MEMBLOCK_ALLOC_ANYWHERE is kept same. [akpm@linux-foundation.org: s/depricated/deprecated/] Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Cc: Yinghai Lu <yinghai@kernel.org> Cc: Tejun Heo <tj@kernel.org> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Paul Walmsley <paul@pwsan.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Russell King <linux@arm.linux.org.uk> Cc: Tony Lindgren <tony@atomide.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/bootmem.h')
-rw-r--r--include/linux/bootmem.h152
1 files changed, 152 insertions, 0 deletions
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 55d52fb7ac1d..2fae55def608 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -5,6 +5,7 @@
5#define _LINUX_BOOTMEM_H 5#define _LINUX_BOOTMEM_H
6 6
7#include <linux/mmzone.h> 7#include <linux/mmzone.h>
8#include <linux/mm_types.h>
8#include <asm/dma.h> 9#include <asm/dma.h>
9 10
10/* 11/*
@@ -141,6 +142,157 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
141#define alloc_bootmem_low_pages_node(pgdat, x) \ 142#define alloc_bootmem_low_pages_node(pgdat, x) \
142 __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0) 143 __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
143 144
145
146#if defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM)
147
148/* FIXME: use MEMBLOCK_ALLOC_* variants here */
149#define BOOTMEM_ALLOC_ACCESSIBLE 0
150#define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0)
151
152/* FIXME: Move to memblock.h at a point where we remove nobootmem.c */
153void *memblock_virt_alloc_try_nid_nopanic(phys_addr_t size,
154 phys_addr_t align, phys_addr_t min_addr,
155 phys_addr_t max_addr, int nid);
156void *memblock_virt_alloc_try_nid(phys_addr_t size, phys_addr_t align,
157 phys_addr_t min_addr, phys_addr_t max_addr, int nid);
158void __memblock_free_early(phys_addr_t base, phys_addr_t size);
159void __memblock_free_late(phys_addr_t base, phys_addr_t size);
160
161static inline void * __init memblock_virt_alloc(
162 phys_addr_t size, phys_addr_t align)
163{
164 return memblock_virt_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT,
165 BOOTMEM_ALLOC_ACCESSIBLE,
166 NUMA_NO_NODE);
167}
168
169static inline void * __init memblock_virt_alloc_nopanic(
170 phys_addr_t size, phys_addr_t align)
171{
172 return memblock_virt_alloc_try_nid_nopanic(size, align,
173 BOOTMEM_LOW_LIMIT,
174 BOOTMEM_ALLOC_ACCESSIBLE,
175 NUMA_NO_NODE);
176}
177
178static inline void * __init memblock_virt_alloc_from_nopanic(
179 phys_addr_t size, phys_addr_t align, phys_addr_t min_addr)
180{
181 return memblock_virt_alloc_try_nid_nopanic(size, align, min_addr,
182 BOOTMEM_ALLOC_ACCESSIBLE,
183 NUMA_NO_NODE);
184}
185
186static inline void * __init memblock_virt_alloc_node(
187 phys_addr_t size, int nid)
188{
189 return memblock_virt_alloc_try_nid(size, 0, BOOTMEM_LOW_LIMIT,
190 BOOTMEM_ALLOC_ACCESSIBLE, nid);
191}
192
193static inline void * __init memblock_virt_alloc_node_nopanic(
194 phys_addr_t size, int nid)
195{
196 return memblock_virt_alloc_try_nid_nopanic(size, 0, BOOTMEM_LOW_LIMIT,
197 BOOTMEM_ALLOC_ACCESSIBLE,
198 nid);
199}
200
201static inline void __init memblock_free_early(
202 phys_addr_t base, phys_addr_t size)
203{
204 __memblock_free_early(base, size);
205}
206
207static inline void __init memblock_free_early_nid(
208 phys_addr_t base, phys_addr_t size, int nid)
209{
210 __memblock_free_early(base, size);
211}
212
213static inline void __init memblock_free_late(
214 phys_addr_t base, phys_addr_t size)
215{
216 __memblock_free_late(base, size);
217}
218
219#else
220
221#define BOOTMEM_ALLOC_ACCESSIBLE 0
222
223
224/* Fall back to all the existing bootmem APIs */
225static inline void * __init memblock_virt_alloc(
226 phys_addr_t size, phys_addr_t align)
227{
228 if (!align)
229 align = SMP_CACHE_BYTES;
230 return __alloc_bootmem(size, align, BOOTMEM_LOW_LIMIT);
231}
232
233static inline void * __init memblock_virt_alloc_nopanic(
234 phys_addr_t size, phys_addr_t align)
235{
236 if (!align)
237 align = SMP_CACHE_BYTES;
238 return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT);
239}
240
241static inline void * __init memblock_virt_alloc_from_nopanic(
242 phys_addr_t size, phys_addr_t align, phys_addr_t min_addr)
243{
244 return __alloc_bootmem_nopanic(size, align, min_addr);
245}
246
247static inline void * __init memblock_virt_alloc_node(
248 phys_addr_t size, int nid)
249{
250 return __alloc_bootmem_node(NODE_DATA(nid), size, SMP_CACHE_BYTES,
251 BOOTMEM_LOW_LIMIT);
252}
253
254static inline void * __init memblock_virt_alloc_node_nopanic(
255 phys_addr_t size, int nid)
256{
257 return __alloc_bootmem_node_nopanic(NODE_DATA(nid), size,
258 SMP_CACHE_BYTES,
259 BOOTMEM_LOW_LIMIT);
260}
261
262static inline void * __init memblock_virt_alloc_try_nid(phys_addr_t size,
263 phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid)
264{
265 return __alloc_bootmem_node_high(NODE_DATA(nid), size, align,
266 min_addr);
267}
268
269static inline void * __init memblock_virt_alloc_try_nid_nopanic(
270 phys_addr_t size, phys_addr_t align,
271 phys_addr_t min_addr, phys_addr_t max_addr, int nid)
272{
273 return ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size, align,
274 min_addr, max_addr);
275}
276
277static inline void __init memblock_free_early(
278 phys_addr_t base, phys_addr_t size)
279{
280 free_bootmem(base, size);
281}
282
283static inline void __init memblock_free_early_nid(
284 phys_addr_t base, phys_addr_t size, int nid)
285{
286 free_bootmem_node(NODE_DATA(nid), base, size);
287}
288
289static inline void __init memblock_free_late(
290 phys_addr_t base, phys_addr_t size)
291{
292 free_bootmem_late(base, size);
293}
294#endif /* defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM) */
295
144#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP 296#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
145extern void *alloc_remap(int nid, unsigned long size); 297extern void *alloc_remap(int nid, unsigned long size);
146#else 298#else