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)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 2b2d378..1e66a53 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -677,6 +677,34 @@
 }
 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