ion: Add reserve function to ion
authorRebecca Schultz Zavin <rebecca@android.com>
Tue, 31 Jan 2012 17:40:30 +0000 (09:40 -0800)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 20:40:46 +0000 (13:40 -0700)
Rather than requiring each platform call memblock_remove or reserve
from the board file, add this to ion

Change-Id: Ie418a692c13e9e0cfe93ecc83d253d3ce860fc83
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
drivers/gpu/ion/ion.c
include/linux/ion.h

index 45147e284faad88798b452df0099186c72ece8f0..344d66d6fab2b980a047ae265ba11ecd5aedc9dc 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/anon_inodes.h>
 #include <linux/ion.h>
 #include <linux/list.h>
+#include <linux/memblock.h>
 #include <linux/miscdevice.h>
 #include <linux/export.h>
 #include <linux/mm.h>
@@ -1185,3 +1186,19 @@ void ion_device_destroy(struct ion_device *dev)
        /* XXX need to free the heaps and clients ? */
        kfree(dev);
 }
+
+void __init ion_reserve(struct ion_platform_data *data)
+{
+       int i, ret;
+
+       for (i = 0; i < data->nr; i++) {
+               if (data->heaps[i].size == 0)
+                       continue;
+               ret = memblock_reserve(data->heaps[i].base,
+                                      data->heaps[i].size);
+               if (ret)
+                       pr_err("memblock reserve of %x@%lx failed\n",
+                              data->heaps[i].size,
+                              data->heaps[i].base);
+       }
+}
index 9d196e2f9bb36d0cef763f55d2d092acbfd54a3f..860b160ab5ed54bd99213325b0749f6b7d62c943 100644 (file)
@@ -86,6 +86,17 @@ struct ion_platform_data {
        struct ion_platform_heap heaps[];
 };
 
+/**
+ * ion_reserve() - reserve memory for ion heaps if applicable
+ * @data:      platform data specifying starting physical address and
+ *             size
+ *
+ * Calls memblock reserve to set aside memory for heaps that are
+ * located at specific memory addresses or of specfic sizes not
+ * managed by the kernel
+ */
+void ion_reserve(struct ion_platform_data *data);
+
 /**
  * ion_client_create() -  allocate a client and returns it
  * @dev:       the global ion device