[PATCH] staging: android: ion: Add chunk heap initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Create chunk heap of specified size and base address by adding
"ion_chunk_heap=size@start" kernel boot parameter.

Signed-off-by: Alexey Skidanov <alexey.skidanov@xxxxxxxxx>
---
 drivers/staging/android/ion/ion_chunk_heap.c | 40 ++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c
index 159d72f..67573aa4 100644
--- a/drivers/staging/android/ion/ion_chunk_heap.c
+++ b/drivers/staging/android/ion/ion_chunk_heap.c
@@ -135,6 +135,7 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
 	}
 	chunk_heap->base = heap_data->base;
 	chunk_heap->size = heap_data->size;
+	chunk_heap->heap.name = heap_data->name;
 	chunk_heap->allocated = 0;
 
 	gen_pool_add(chunk_heap->pool, chunk_heap->base, heap_data->size, -1);
@@ -151,3 +152,42 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
 	return ERR_PTR(ret);
 }
 
+static u64 base;
+static u64 size;
+
+static int __init setup_heap(char *param)
+{
+	char *p, *pp;
+
+	size = memparse(param, &p);
+	if (param == p)
+		return -EINVAL;
+
+	if (*p == '@')
+		base = memparse(p + 1, &pp);
+	else
+		return -EINVAL;
+
+	if (p == pp)
+		return -EINVAL;
+
+	return 0;
+}
+
+__setup("ion_chunk_heap=", setup_heap);
+
+static int ion_add_chunk_heap(void)
+{
+	struct ion_heap *heap;
+	struct ion_platform_heap plat_heap = {.base = base,
+					      .size = size,
+					      .name = "chunk_heap",
+					      .priv = (void *)PAGE_SIZE};
+	heap = ion_chunk_heap_create(&plat_heap);
+	if (heap)
+		ion_device_add_heap(heap);
+
+	return 0;
+}
+device_initcall(ion_add_chunk_heap);
+
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux