On 11/11/18 11:29 AM, Alexey Skidanov wrote:
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.skida...@intel.com>
---
  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);
+


This solves a problem but not enough of the problem.

We need to be able to support more than one chunk/carveout
heap. This also assumes that the memory has already been
reserved/placed and that you know the base and size to
pass on the command line. Part of the issue with the carveout
heaps is that we need a way to tell the kernel to reserve
the memory early enough and then get that information to
Ion. Hard coding memory locations tends to be buggy from
my past experience with Ion.

If you'd like to see about coming up with a complete solution,
feel free to resubmit but I'm still strongly considering
removing these heaps.

Thanks,
Laura
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to