Add physical memory hotremove API
This provides the physical memory hotremove API (this is needed since our physical memory removal is done by powering it off, which needs to be requested by userspace, not by someone physically pulling memory out of a machine). Change-Id: Ic34426a91a1aac2bd4a45677ee00c2b7a3f84746 Signed-off-by: Larry Bassel <lbassel@codeaurora.org> (cherry picked from commit d651b6964bbb50d3c1fee6f76467a0f867286dfb)
This commit is contained in:
committed by
Stephen Boyd
parent
f53e4210e3
commit
c80281297a
@@ -241,3 +241,4 @@ extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map,
|
||||
unsigned long pnum);
|
||||
|
||||
#endif /* __LINUX_MEMORY_HOTPLUG_H */
|
||||
extern int physical_remove_memory(u64 start, u64 size);
|
||||
|
||||
@@ -677,6 +677,34 @@ out:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(add_memory);
|
||||
|
||||
int __ref physical_remove_memory(u64 start, u64 size)
|
||||
{
|
||||
int ret;
|
||||
struct resource *res, *res_old;
|
||||
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
|
||||
BUG_ON(!res);
|
||||
|
||||
/* call arch's memory hotremove */
|
||||
ret = arch_physical_remove_memory(start, size);
|
||||
if (ret) {
|
||||
kfree(res);
|
||||
return ret;
|
||||
}
|
||||
|
||||
res->name = "System RAM";
|
||||
res->start = start;
|
||||
res->end = start + size - 1;
|
||||
res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
|
||||
|
||||
res_old = locate_resource(&iomem_resource, res);
|
||||
if (res_old)
|
||||
release_memory_resource(res_old);
|
||||
kfree(res);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(physical_remove_memory);
|
||||
|
||||
#ifdef CONFIG_MEMORY_HOTREMOVE
|
||||
/*
|
||||
* A free page on the buddy free lists (not the per-cpu lists) has PageBuddy
|
||||
|
||||
Reference in New Issue
Block a user