From 6cc665a6431dfef0158d537214cbc66612d1f83a Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Mon, 25 Apr 2022 14:23:13 +0800 Subject: [PATCH] dma-buf: rk_heaps: rk-cma-heap replace orig_alloc by dmabuf->name For dmabuf, owner has set a name for the buffer, use the dmabuf->name to replace orig_alloc to save several memory. Signed-off-by: Jianqun Xu Change-Id: Ifad14ed886580d2a9f3000900e1849b0b5a3858e --- drivers/dma-buf/rk_heaps/rk-cma-heap.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/dma-buf/rk_heaps/rk-cma-heap.c b/drivers/dma-buf/rk_heaps/rk-cma-heap.c index 1010d33c57c1..8b9a78006413 100644 --- a/drivers/dma-buf/rk_heaps/rk-cma-heap.c +++ b/drivers/dma-buf/rk_heaps/rk-cma-heap.c @@ -284,12 +284,11 @@ static void rk_cma_heap_remove_dmabuf_list(struct dma_buf *dmabuf) list_for_each_entry(buf, &heap->dmabuf_list, node) { if (buf->dmabuf == dmabuf) { dma_heap_print("<%s> free dmabuf@[%pa-%pa] to heap-<%s>\n", - buf->orig_alloc, + dmabuf->name, dmabuf->file->f_inode->i_ino, &buf->start, &buf->end, rk_dma_heap_get_name(heap)); list_del(&buf->node); - kfree(buf->orig_alloc); kfree(buf); break; } @@ -303,7 +302,6 @@ static int rk_cma_heap_add_dmabuf_list(struct dma_buf *dmabuf, const char *name) struct rk_cma_heap_buffer *buffer = dmabuf->priv; struct rk_cma_heap *cma_heap = buffer->heap; struct rk_dma_heap *heap = cma_heap->heap; - const char *name_tmp; buf = kzalloc(sizeof(*buf), GFP_KERNEL); if (!buf) @@ -311,17 +309,6 @@ static int rk_cma_heap_add_dmabuf_list(struct dma_buf *dmabuf, const char *name) INIT_LIST_HEAD(&buf->node); buf->dmabuf = dmabuf; - if (!name) - name_tmp = current->comm; - else - name_tmp = name; - - buf->orig_alloc = kstrndup(name_tmp, RK_DMA_HEAP_NAME_LEN, GFP_KERNEL); - if (!buf->orig_alloc) { - kfree(buf); - return -ENOMEM; - } - buf->start = buffer->phys; buf->end = buf->start + buffer->len - 1; mutex_lock(&heap->dmabuf_lock); @@ -329,7 +316,7 @@ static int rk_cma_heap_add_dmabuf_list(struct dma_buf *dmabuf, const char *name) mutex_unlock(&heap->dmabuf_lock); dma_heap_print("<%s> alloc dmabuf@[%pa-%pa] from heap-<%s>\n", - buf->orig_alloc, dmabuf->file->f_inode->i_ino, + dmabuf->name, dmabuf->file->f_inode->i_ino, &buf->start, &buf->end, rk_dma_heap_get_name(heap)); return 0;