dma-buf: rk_heaps: set name for dmabuf to debug

The rk_dma_heap_bufferfd_alloc has expand argument 'const char *name'
which is used for debug to oversee all dmabuf.

The dma_buf_set_name is provided and exported by dma-buf, also support
via ioctl of dma-buf. This patch set the name to dmabuf if support for
the CONFIG_DMABUF_RK_HEAPS_DEBUG.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Change-Id: I834a1f2009d5a1c6a6835ea78b3dd1aeec43e31f
This commit is contained in:
Jianqun Xu
2022-03-26 10:40:37 +08:00
committed by Tao Huang
parent b70b46407b
commit 4f69f3914b

View File

@@ -173,6 +173,8 @@ struct dma_buf *rk_dma_heap_buffer_alloc(struct rk_dma_heap *heap, size_t len,
unsigned int heap_flags,
const char *name)
{
struct dma_buf *dmabuf;
if (fd_flags & ~RK_DMA_HEAP_VALID_FD_FLAGS)
return ERR_PTR(-EINVAL);
@@ -186,7 +188,12 @@ struct dma_buf *rk_dma_heap_buffer_alloc(struct rk_dma_heap *heap, size_t len,
if (!len)
return ERR_PTR(-EINVAL);
return heap->ops->allocate(heap, len, fd_flags, heap_flags, name);
dmabuf = heap->ops->allocate(heap, len, fd_flags, heap_flags, name);
if (IS_ENABLED(CONFIG_DMABUF_RK_HEAPS_DEBUG) && !IS_ERR(dmabuf))
dma_buf_set_name(dmabuf, name);
return dmabuf;
}
EXPORT_SYMBOL_GPL(rk_dma_heap_buffer_alloc);
@@ -209,6 +216,7 @@ int rk_dma_heap_bufferfd_alloc(struct rk_dma_heap *heap, size_t len,
dma_buf_put(dmabuf);
/* just return, as put will call release and that will free */
}
return fd;
}