From 4f69f3914b44ea00ce18dd4e2150cbb298ed9002 Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Sat, 26 Mar 2022 10:40:37 +0800 Subject: [PATCH] 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 Change-Id: I834a1f2009d5a1c6a6835ea78b3dd1aeec43e31f --- drivers/dma-buf/rk_heaps/rk-dma-heap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/rk_heaps/rk-dma-heap.c b/drivers/dma-buf/rk_heaps/rk-dma-heap.c index 9e1b7b50a46c..2b0ea08fcdfd 100644 --- a/drivers/dma-buf/rk_heaps/rk-dma-heap.c +++ b/drivers/dma-buf/rk_heaps/rk-dma-heap.c @@ -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; }