gpu: ion: fix missing unmap_kernel function in CMA heap

Message ID CA+M3ks4N4nRgzq-DiBck68_1maV_CEAbQmdwCJzEvDfLKDCv_g@mail.gmail.com
State New
Headers show

Commit Message

Benjamin Gaignard Sept. 18, 2013, 12:32 p.m.
After calling dma_alloc_coherent memory is mapped in kernel space.
CMA heap doesn't map/unmap so only create a function to avoid segfault
when ion call it without check it.

Add a check at heap creation to be sure that unmap_kernel ops is implemented.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 drivers/gpu/ion/ion.c          |    2 +-
 drivers/gpu/ion/ion_cma_heap.c |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

  .free = ion_cma_free,
@@ -178,6 +184,7 @@ static struct ion_heap_ops ion_cma_ops = {
  .phys = ion_cma_phys,
  .map_user = ion_cma_mmap,
  .map_kernel = ion_cma_map_kernel,
+ .unmap_kernel = ion_cma_unmap_kernel,
 };

 struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *data)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index 71b650e..5dd0ea2 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1390,7 +1390,7 @@  DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops,
debug_shrink_get,
 void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
 {
  if (!heap->ops->allocate || !heap->ops->free || !heap->ops->map_dma ||
-    !heap->ops->unmap_dma)
+    !heap->ops->unmap_dma || !heap->ops->unmap_kernel)
  pr_err("%s: can not add heap with invalid ops struct.\n",
        __func__);

diff --git a/drivers/gpu/ion/ion_cma_heap.c b/drivers/gpu/ion/ion_cma_heap.c
index 1eaa8c1..b98dcc4a 100644
--- a/drivers/gpu/ion/ion_cma_heap.c
+++ b/drivers/gpu/ion/ion_cma_heap.c
@@ -170,6 +170,12 @@  void *ion_cma_map_kernel(struct ion_heap *heap,
struct ion_buffer *buffer)
  return info->cpu_addr;
 }

+void  ion_cma_unmap_kernel(struct ion_heap *heap, struct ion_buffer *buffer)
+{
+ /* do nothing because we keep the mapping*/
+ return;
+}
+
 static struct ion_heap_ops ion_cma_ops = {
  .allocate = ion_cma_allocate,