Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a84b66a authored by Hyesoo Yu's avatar Hyesoo Yu Committed by Hridya Valsaraju
Browse files

ANDROID: staging: ion: implement vmap for built-in heaps



dma_buf_vmap() on ION buffers returns -EOPNOTSUPP
if the heap of ION buffer does not implement its own
vmap callback. Even the default system heap does not
implement vmap callback, so vmap attempt of ION buffer
will always fail. However vmap of ION buffer is much
more reasonable to be supported by default than errors,
so this patch implements vmap callback.

Bug: 150258007

Signed-off-by: default avatarHyesoo Yu <hyesoo.yu@samsung.com>
Change-Id: I243eb7ded49843e719532ad1b1cb7ab37e84460d
parent fa04c81b
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -287,11 +287,16 @@ static void *ion_dma_buf_vmap(struct dma_buf *dmabuf)
{
	struct ion_buffer *buffer = dmabuf->priv;
	struct ion_heap *heap = buffer->heap;
	void *vaddr;

	if (!heap->buf_ops.vmap)
		return ERR_PTR(-EOPNOTSUPP);

	if (heap->buf_ops.vmap)
		return heap->buf_ops.vmap(dmabuf);

	mutex_lock(&buffer->lock);
	vaddr = ion_buffer_kmap_get(buffer);
	mutex_unlock(&buffer->lock);

	return vaddr;
}

static void ion_dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
@@ -299,10 +304,14 @@ static void ion_dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
	struct ion_buffer *buffer = dmabuf->priv;
	struct ion_heap *heap = buffer->heap;

	if (!heap->buf_ops.vunmap)
	if (heap->buf_ops.vunmap) {
		heap->buf_ops.vunmap(dmabuf, vaddr);
		return;
	}

	return heap->buf_ops.vunmap(dmabuf, vaddr);
	mutex_lock(&buffer->lock);
	ion_buffer_kmap_put(buffer);
	mutex_unlock(&buffer->lock);
}

static int ion_dma_buf_get_flags(struct dma_buf *dmabuf, unsigned long *flags)