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:
Larry Bassel 2009-12-02 15:54:24 -08:00 committed by Stephen Boyd
parent d3afd06d51
commit 699e626db7
2 changed files with 29 additions and 0 deletions

View file

@ -259,3 +259,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);

View file

@ -1171,6 +1171,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