Commit 24551f64 authored by Michael Ellerman's avatar Michael Ellerman Committed by Benjamin Herrenschmidt

lmb: Add lmb_free()

We can free memory allocated with lmb_alloc() by removing it from the
list of reserved LMBs. Rework lmb_remove() to allow that possibility
and add lmb_free() which exploits it.

BenH: Removed some useless parenthesis
Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 859aefc5
...@@ -42,6 +42,7 @@ extern void __init lmb_init(void); ...@@ -42,6 +42,7 @@ extern void __init lmb_init(void);
extern void __init lmb_analyze(void); extern void __init lmb_analyze(void);
extern long lmb_add(u64 base, u64 size); extern long lmb_add(u64 base, u64 size);
extern long lmb_remove(u64 base, u64 size); extern long lmb_remove(u64 base, u64 size);
extern long __init lmb_free(u64 base, u64 size);
extern long __init lmb_reserve(u64 base, u64 size); extern long __init lmb_reserve(u64 base, u64 size);
extern u64 __init lmb_alloc_nid(u64 size, u64 align, int nid, extern u64 __init lmb_alloc_nid(u64 size, u64 align, int nid,
u64 (*nid_range)(u64, u64, int *)); u64 (*nid_range)(u64, u64, int *));
......
...@@ -205,9 +205,8 @@ long lmb_add(u64 base, u64 size) ...@@ -205,9 +205,8 @@ long lmb_add(u64 base, u64 size)
} }
long lmb_remove(u64 base, u64 size) static long __lmb_remove(struct lmb_region *rgn, u64 base, u64 size)
{ {
struct lmb_region *rgn = &(lmb.memory);
u64 rgnbegin, rgnend; u64 rgnbegin, rgnend;
u64 end = base + size; u64 end = base + size;
int i; int i;
...@@ -254,6 +253,16 @@ long lmb_remove(u64 base, u64 size) ...@@ -254,6 +253,16 @@ long lmb_remove(u64 base, u64 size)
return lmb_add_region(rgn, end, rgnend - end); return lmb_add_region(rgn, end, rgnend - end);
} }
long lmb_remove(u64 base, u64 size)
{
return __lmb_remove(&lmb.memory, base, size);
}
long __init lmb_free(u64 base, u64 size)
{
return __lmb_remove(&lmb.reserved, base, size);
}
long __init lmb_reserve(u64 base, u64 size) long __init lmb_reserve(u64 base, u64 size)
{ {
struct lmb_region *_rgn = &lmb.reserved; struct lmb_region *_rgn = &lmb.reserved;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment