diff mbox

gpu: ion: Use memblock_remove when reserving carveout memory

Message ID 1360595911-25460-1-git-send-email-johan.mossberg@stericsson.com
State New
Headers show

Commit Message

Johan Mossberg Feb. 11, 2013, 3:18 p.m. UTC
__arm_ioremap, which is used by the carveout heap, refuses to map
memory already mapped as lowmem, probably to avoid having multiple
mappings with different cache settings pointing at the same memory.
By using memblock_remove rather than memblock_reserve the carveout
heap's memory will not be included in lowmem i.e no problem.

Signed-off-by: Johan Mossberg <johan.mossberg@stericsson.com>
---
 drivers/gpu/ion/ion.c |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index 0fc02fd..b8b43bb 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1323,29 +1323,32 @@  void __init ion_reserve(struct ion_platform_data *data)
 	int i;
 
 	for (i = 0; i < data->nr; i++) {
+		int ret;
+
 		if (data->heaps[i].size == 0)
 			continue;
 
 		if (data->heaps[i].base == 0) {
-			phys_addr_t paddr;
-			paddr = memblock_alloc_base(data->heaps[i].size,
-						    data->heaps[i].align,
-						    MEMBLOCK_ALLOC_ANYWHERE);
-			if (!paddr) {
-				pr_err("%s: error allocating memblock for "
-				       "heap %d\n",
-					__func__, i);
+			data->heaps[i].base = memblock_find_in_range_node(
+						0,
+						MEMBLOCK_ALLOC_ANYWHERE,
+						data->heaps[i].size,
+						data->heaps[i].align,
+						MAX_NUMNODES);
+			if (data->heaps[i].base == 0) {
+				pr_err("%s: error allocating memblock for heap %d\n",
+						__func__, data->heaps[i].id);
 				continue;
 			}
-			data->heaps[i].base = paddr;
-		} else {
-			int 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);
 		}
+
+		ret = memblock_remove(data->heaps[i].base, data->heaps[i].size);
+		if (ret < 0) {
+			pr_err("%s: could not remove heap %d memory from kernel\n",
+					__func__, data->heaps[i].id);
+			continue;
+		}
+
 		pr_info("%s: %s reserved base %lx size %d\n", __func__,
 			data->heaps[i].name,
 			data->heaps[i].base,