* Re: [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation @ 2020-09-26 10:11 kernel test robot 2020-09-26 10:11 ` [PATCH] dma-buf: heaps: fix returnvar.cocci warnings kernel test robot 0 siblings, 1 reply; 6+ messages in thread From: kernel test robot @ 2020-09-26 10:11 UTC (permalink / raw) To: kbuild [-- Attachment #1: Type: text/plain, Size: 1636 bytes --] CC: kbuild-all(a)lists.01.org In-Reply-To: <20200926042453.67517-3-john.stultz@linaro.org> References: <20200926042453.67517-3-john.stultz@linaro.org> TO: John Stultz <john.stultz@linaro.org> Hi John, [FYI, it's a private test report for your RFC patch.] [auto build test WARNING on linux/master] [also build test WARNING on tegra-drm/drm/tegra/for-next linus/master next-20200925] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/John-Stultz/dma-buf-Performance-improvements-for-system-heap/20200926-122541 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bcf876870b95592b52519ed4aafcf9d95999bc9c :::::: branch date: 6 hours ago :::::: commit date: 6 hours ago config: x86_64-randconfig-c002-20200925 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> Reported-by: Julia Lawall <julia.lawall@lip6.fr> coccinelle warnings: (new ones prefixed by >>) >> drivers/dma-buf/heaps/cma_heap.c:203:2-8: preceding lock on line 200 drivers/dma-buf/heaps/cma_heap.c:208:2-8: preceding lock on line 200 -- >> drivers/dma-buf/heaps/cma_heap.c:119:5-8: Unneeded variable: "ret". Return "0" on line 131 Please review and possibly fold the followup patch. --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 34164 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] dma-buf: heaps: fix returnvar.cocci warnings 2020-09-26 10:11 [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation kernel test robot @ 2020-09-26 10:11 ` kernel test robot 0 siblings, 0 replies; 6+ messages in thread From: kernel test robot @ 2020-09-26 10:11 UTC (permalink / raw) To: kbuild [-- Attachment #1: Type: text/plain, Size: 1543 bytes --] CC: kbuild-all(a)lists.01.org In-Reply-To: <20200926042453.67517-3-john.stultz@linaro.org> References: <20200926042453.67517-3-john.stultz@linaro.org> TO: John Stultz <john.stultz@linaro.org> From: kernel test robot <lkp@intel.com> drivers/dma-buf/heaps/cma_heap.c:119:5-8: Unneeded variable: "ret". Return "0" on line 131 Remove unneeded variable used to store return value. Generated by: scripts/coccinelle/misc/returnvar.cocci CC: John Stultz <john.stultz@linaro.org> Signed-off-by: kernel test robot <lkp@intel.com> --- url: https://github.com/0day-ci/linux/commits/John-Stultz/dma-buf-Performance-improvements-for-system-heap/20200926-122541 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bcf876870b95592b52519ed4aafcf9d95999bc9c :::::: branch date: 6 hours ago :::::: commit date: 6 hours ago Please take the patch only if it's a positive warning. Thanks! cma_heap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -116,7 +116,6 @@ static int cma_heap_dma_buf_begin_cpu_ac { struct cma_heap_buffer *buffer = dmabuf->priv; struct dma_heap_attachment *a; - int ret = 0; if (buffer->vmap_cnt) invalidate_kernel_vmap_range(buffer->vaddr, buffer->len); @@ -128,7 +127,7 @@ static int cma_heap_dma_buf_begin_cpu_ac } mutex_unlock(&buffer->lock); - return ret; + return 0; } static int cma_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf, ^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC][PATCH 0/6] dma-buf: Performance improvements for system heap
@ 2020-09-26 4:24 John Stultz
2020-09-26 4:24 ` John Stultz
0 siblings, 1 reply; 6+ messages in thread
From: John Stultz @ 2020-09-26 4:24 UTC (permalink / raw)
To: lkml
Cc: Sandeep Patil, dri-devel, Ezequiel Garcia, Robin Murphy,
James Jones, Liam Mark, Laura Abbott, Hridya Valsaraju,
Ørjan Eide, Suren Baghdasaryan, linux-media
Hey All,
So this patch series contains a series of performance
optimizations to the dma-buf system heap.
Unfortunately, in working these up, I realized the heap-helpers
infrastructure we tried to add to miniimize code duplication is
not as generic as we intended. For some heaps it makes sense to
deal with page lists, for other heaps it makes more sense to
track things with sgtables.
So this series reworks the system heap to use sgtables, and then
consolidates the pagelist method from the heap-helpers into the
CMA heap. After which the heap-helpers logic is removed (as it
is unused). I'd still like to find a better way to avoid some of
the logic duplication in implementing the entire dma_buf_ops
handlers per heap. But unfortunately that code is tied somewhat
to how the buffer's memory is tracked.
After this, the series introduces two optimizations to the the
system heap, utilizing large order pages, and adding a page-pool
(maybe abusing the pagepool logic from the network code, but it
seems silly to reimplement it).
I implemented a simple allocation microbenchmark to compare
dmabuf heaps vs ion:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?h=dev/dma-buf-heap-perf&id=e33aabd34b300f8f8be8d71ec7253dd0abe702f2
With these changes, the allocation path is *much* improved,
performing better then ION (though to be fair, the repeated
allocating and freeing of the same size buffer is the ideal
case for the pagepool logic, so don't read too much into it).
I charted some datapoints from the microbenchmark with each
of the patches should folks be interested.
https://docs.google.com/spreadsheets/d/1-1C8ZQpmkl_0DISkI6z4xelE08MlNAN7oEu34AnO4Ao/edit#gid=0
Finally, a port of a patch that Ørjan Eide implemented for ION
that avoids calling sync on attachments that don't have a
mapping.
Feedback on these would be great!
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Laura Abbott <labbott@kernel.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Ørjan Eide <orjan.eide@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Ezequiel Garcia <ezequiel@collabora.com>
Cc: Simon Ser <contact@emersion.fr>
Cc: James Jones <jajones@nvidia.com>
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
John Stultz (6):
dma-buf: system_heap: Rework system heap to use sgtables instead of
pagelists
dma-buf: heaps: Move heap-helper logic into the cma_heap
implementation
dma-buf: heaps: Remove heap-helpers code
dma-buf: system_heap: Allocate higher order pages if available
dma-buf: system_heap: Add pagepool support to system heap
dma-buf: heaps: Skip sync if not mapped
drivers/dma-buf/heaps/Kconfig | 1 +
drivers/dma-buf/heaps/Makefile | 1 -
drivers/dma-buf/heaps/cma_heap.c | 332 +++++++++++++++++----
drivers/dma-buf/heaps/heap-helpers.c | 271 -----------------
drivers/dma-buf/heaps/heap-helpers.h | 53 ----
drivers/dma-buf/heaps/system_heap.c | 426 ++++++++++++++++++++++++---
6 files changed, 660 insertions(+), 424 deletions(-)
delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c
delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation 2020-09-26 4:24 [RFC][PATCH 0/6] dma-buf: Performance improvements for system heap John Stultz @ 2020-09-26 4:24 ` John Stultz 0 siblings, 0 replies; 6+ messages in thread From: John Stultz @ 2020-09-26 4:24 UTC (permalink / raw) To: lkml Cc: Sandeep Patil, dri-devel, Ezequiel Garcia, Robin Murphy, James Jones, Liam Mark, Laura Abbott, Hridya Valsaraju, Ørjan Eide, Suren Baghdasaryan, linux-media Since the heap-helpers logic ended up not being as generic as hoped, move the heap-helpers dma_buf_ops implementations into the cma_heap directly. This will allow us to remove the heap_helpers code in a following patch. Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Liam Mark <lmark@codeaurora.org> Cc: Laura Abbott <labbott@kernel.org> Cc: Brian Starkey <Brian.Starkey@arm.com> Cc: Hridya Valsaraju <hridya@google.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sandeep Patil <sspatil@google.com> Cc: Ørjan Eide <orjan.eide@arm.com> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Ezequiel Garcia <ezequiel@collabora.com> Cc: Simon Ser <contact@emersion.fr> Cc: James Jones <jajones@nvidia.com> Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz <john.stultz@linaro.org> --- drivers/dma-buf/heaps/cma_heap.c | 322 ++++++++++++++++++++++++++----- 1 file changed, 270 insertions(+), 52 deletions(-) diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 626cf7fd033a..3adfdbed0829 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -2,76 +2,291 @@ /* * DMABUF CMA heap exporter * - * Copyright (C) 2012, 2019 Linaro Ltd. + * Copyright (C) 2012, 2019, 2020 Linaro Ltd. * Author: <benjamin.gaignard@linaro.org> for ST-Ericsson. + * + * Also utilizing parts of Andrew Davis' SRAM heap: + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ + * Andrew F. Davis <afd@ti.com> */ - #include <linux/cma.h> -#include <linux/device.h> #include <linux/dma-buf.h> -#include <linux/dma-heap.h> #include <linux/dma-contiguous.h> +#include <linux/dma-heap.h> +#include <linux/dma-mapping.h> #include <linux/err.h> -#include <linux/errno.h> #include <linux/highmem.h> +#include <linux/io.h> +#include <linux/mm.h> #include <linux/module.h> -#include <linux/slab.h> #include <linux/scatterlist.h> -#include <linux/sched/signal.h> +#include <linux/slab.h> -#include "heap-helpers.h" struct cma_heap { struct dma_heap *heap; struct cma *cma; }; -static void cma_heap_free(struct heap_helper_buffer *buffer) +struct cma_heap_buffer { + struct cma_heap *heap; + struct list_head attachments; + struct mutex lock; + unsigned long len; + struct page *cma_pages; + struct page **pages; + pgoff_t pagecount; + int vmap_cnt; + void *vaddr; +}; + +struct dma_heap_attachment { + struct device *dev; + struct sg_table table; + struct list_head list; +}; + +static int cma_heap_attach(struct dma_buf *dmabuf, + struct dma_buf_attachment *attachment) { - struct cma_heap *cma_heap = dma_heap_get_drvdata(buffer->heap); - unsigned long nr_pages = buffer->pagecount; - struct page *cma_pages = buffer->priv_virt; + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a; + int ret; - /* free page list */ - kfree(buffer->pages); - /* release memory */ - cma_release(cma_heap->cma, cma_pages, nr_pages); + a = kzalloc(sizeof(*a), GFP_KERNEL); + if (!a) + return -ENOMEM; + + ret = sg_alloc_table_from_pages(&a->table, buffer->pages, + buffer->pagecount, 0, + buffer->pagecount << PAGE_SHIFT, + GFP_KERNEL); + if (ret) { + kfree(a); + return ret; + } + + a->dev = attachment->dev; + INIT_LIST_HEAD(&a->list); + + attachment->priv = a; + + mutex_lock(&buffer->lock); + list_add(&a->list, &buffer->attachments); + mutex_unlock(&buffer->lock); + + return 0; +} + +static void cma_heap_detatch(struct dma_buf *dmabuf, + struct dma_buf_attachment *attachment) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a = attachment->priv; + + mutex_lock(&buffer->lock); + list_del(&a->list); + mutex_unlock(&buffer->lock); + + sg_free_table(&a->table); + kfree(a); +} + +static struct sg_table *cma_heap_map_dma_buf(struct dma_buf_attachment *attachment, + enum dma_data_direction direction) +{ + struct dma_heap_attachment *a = attachment->priv; + struct sg_table *table = &a->table; + + if (!dma_map_sg(attachment->dev, table->sgl, table->nents, + direction)) + table = ERR_PTR(-ENOMEM); + return table; +} + +static void cma_heap_unmap_dma_buf(struct dma_buf_attachment *attachment, + struct sg_table *table, + enum dma_data_direction direction) +{ + dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction); +} + +static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, + enum dma_data_direction direction) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a; + int ret = 0; + + if (buffer->vmap_cnt) + invalidate_kernel_vmap_range(buffer->vaddr, buffer->len); + + mutex_lock(&buffer->lock); + list_for_each_entry(a, &buffer->attachments, list) { + dma_sync_sg_for_cpu(a->dev, a->table.sgl, a->table.nents, + direction); + } + mutex_unlock(&buffer->lock); + + return ret; +} + +static int cma_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf, + enum dma_data_direction direction) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a; + + if (buffer->vmap_cnt) + flush_kernel_vmap_range(buffer->vaddr, buffer->len); + + mutex_lock(&buffer->lock); + list_for_each_entry(a, &buffer->attachments, list) { + dma_sync_sg_for_device(a->dev, a->table.sgl, a->table.nents, + direction); + } + mutex_unlock(&buffer->lock); + + return 0; +} + +static vm_fault_t cma_heap_vm_fault(struct vm_fault *vmf) +{ + struct vm_area_struct *vma = vmf->vma; + struct cma_heap_buffer *buffer = vma->vm_private_data; + + if (vmf->pgoff > buffer->pagecount) + return VM_FAULT_SIGBUS; + + vmf->page = buffer->pages[vmf->pgoff]; + get_page(vmf->page); + + return 0; +} + +static const struct vm_operations_struct dma_heap_vm_ops = { + .fault = cma_heap_vm_fault, +}; + +static int cma_heap_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + + if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) + return -EINVAL; + + vma->vm_ops = &dma_heap_vm_ops; + vma->vm_private_data = buffer; + + return 0; +} + +static void *cma_heap_do_vmap(struct cma_heap_buffer *buffer) +{ + void *vaddr; + + vaddr = vmap(buffer->pages, buffer->pagecount, VM_MAP, PAGE_KERNEL); + if (!vaddr) + return ERR_PTR(-ENOMEM); + + return vaddr; +} + +static void *cma_heap_vmap(struct dma_buf *dmabuf) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + void *vaddr; + + mutex_lock(&buffer->lock); + if (buffer->vmap_cnt) { + buffer->vmap_cnt++; + return buffer->vaddr; + } + + vaddr = cma_heap_do_vmap(buffer); + if (IS_ERR(vaddr)) + return vaddr; + + buffer->vaddr = vaddr; + buffer->vmap_cnt++; + mutex_unlock(&buffer->lock); + + return vaddr; +} + +static void cma_heap_vunmap(struct dma_buf *dmabuf, void *vaddr) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + + mutex_lock(&buffer->lock); + if (!--buffer->vmap_cnt) { + vunmap(buffer->vaddr); + buffer->vaddr = NULL; + } + mutex_unlock(&buffer->lock); +} + +static void cma_heap_dma_buf_release(struct dma_buf *dmabuf) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct cma_heap *cma_heap = buffer->heap; + + if (buffer->vmap_cnt > 0) { + WARN(1, "%s: buffer still mapped in the kernel\n", __func__); + vunmap(buffer->vaddr); + } + + cma_release(cma_heap->cma, buffer->cma_pages, buffer->pagecount); kfree(buffer); } -/* dmabuf heap CMA operations functions */ +const struct dma_buf_ops cma_heap_buf_ops = { + .attach = cma_heap_attach, + .detach = cma_heap_detatch, + .map_dma_buf = cma_heap_map_dma_buf, + .unmap_dma_buf = cma_heap_unmap_dma_buf, + .begin_cpu_access = cma_heap_dma_buf_begin_cpu_access, + .end_cpu_access = cma_heap_dma_buf_end_cpu_access, + .mmap = cma_heap_mmap, + .vmap = cma_heap_vmap, + .vunmap = cma_heap_vunmap, + .release = cma_heap_dma_buf_release, +}; + static int cma_heap_allocate(struct dma_heap *heap, - unsigned long len, - unsigned long fd_flags, - unsigned long heap_flags) + unsigned long len, + unsigned long fd_flags, + unsigned long heap_flags) { struct cma_heap *cma_heap = dma_heap_get_drvdata(heap); - struct heap_helper_buffer *helper_buffer; - struct page *cma_pages; + struct cma_heap_buffer *buffer; + DEFINE_DMA_BUF_EXPORT_INFO(exp_info); size_t size = PAGE_ALIGN(len); - unsigned long nr_pages = size >> PAGE_SHIFT; + pgoff_t pagecount = size >> PAGE_SHIFT; unsigned long align = get_order(size); + struct page *cma_pages; struct dma_buf *dmabuf; - int ret = -ENOMEM; pgoff_t pg; + int ret; - if (align > CONFIG_CMA_ALIGNMENT) - align = CONFIG_CMA_ALIGNMENT; - - helper_buffer = kzalloc(sizeof(*helper_buffer), GFP_KERNEL); - if (!helper_buffer) + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); + if (!buffer) return -ENOMEM; - init_heap_helper_buffer(helper_buffer, cma_heap_free); - helper_buffer->heap = heap; - helper_buffer->size = len; + INIT_LIST_HEAD(&buffer->attachments); + mutex_init(&buffer->lock); + buffer->len = size; - cma_pages = cma_alloc(cma_heap->cma, nr_pages, align, false); + if (align > CONFIG_CMA_ALIGNMENT) + align = CONFIG_CMA_ALIGNMENT; + + cma_pages = cma_alloc(cma_heap->cma, pagecount, align, false); if (!cma_pages) - goto free_buf; + goto free_buffer; + /* Clear the cma pages */ if (PageHighMem(cma_pages)) { - unsigned long nr_clear_pages = nr_pages; + unsigned long nr_clear_pages = pagecount; struct page *page = cma_pages; while (nr_clear_pages > 0) { @@ -85,7 +300,6 @@ static int cma_heap_allocate(struct dma_heap *heap, */ if (fatal_signal_pending(current)) goto free_cma; - page++; nr_clear_pages--; } @@ -93,28 +307,30 @@ static int cma_heap_allocate(struct dma_heap *heap, memset(page_address(cma_pages), 0, size); } - helper_buffer->pagecount = nr_pages; - helper_buffer->pages = kmalloc_array(helper_buffer->pagecount, - sizeof(*helper_buffer->pages), - GFP_KERNEL); - if (!helper_buffer->pages) { + buffer->pages = kmalloc_array(pagecount, sizeof(*buffer->pages), GFP_KERNEL); + if (!buffer->pages) { ret = -ENOMEM; goto free_cma; } - for (pg = 0; pg < helper_buffer->pagecount; pg++) - helper_buffer->pages[pg] = &cma_pages[pg]; + for (pg = 0; pg < pagecount; pg++) + buffer->pages[pg] = &cma_pages[pg]; + + buffer->cma_pages = cma_pages; + buffer->heap = cma_heap; + buffer->pagecount = pagecount; /* create the dmabuf */ - dmabuf = heap_helper_export_dmabuf(helper_buffer, fd_flags); + exp_info.ops = &cma_heap_buf_ops; + exp_info.size = buffer->len; + exp_info.flags = fd_flags; + exp_info.priv = buffer; + dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) { ret = PTR_ERR(dmabuf); goto free_pages; } - helper_buffer->dmabuf = dmabuf; - helper_buffer->priv_virt = cma_pages; - ret = dma_buf_fd(dmabuf, fd_flags); if (ret < 0) { dma_buf_put(dmabuf); @@ -125,15 +341,16 @@ static int cma_heap_allocate(struct dma_heap *heap, return ret; free_pages: - kfree(helper_buffer->pages); + kfree(buffer->pages); free_cma: - cma_release(cma_heap->cma, cma_pages, nr_pages); -free_buf: - kfree(helper_buffer); + cma_release(cma_heap->cma, cma_pages, pagecount); +free_buffer: + kfree(buffer); + return ret; } -static const struct dma_heap_ops cma_heap_ops = { +static struct dma_heap_ops cma_heap_ops = { .allocate = cma_heap_allocate, }; @@ -175,3 +392,4 @@ static int add_default_cma_heap(void) module_init(add_default_cma_heap); MODULE_DESCRIPTION("DMA-BUF CMA Heap"); MODULE_LICENSE("GPL v2"); + -- 2.17.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation @ 2020-09-26 4:24 ` John Stultz 0 siblings, 0 replies; 6+ messages in thread From: John Stultz @ 2020-09-26 4:24 UTC (permalink / raw) To: lkml Cc: John Stultz, Sumit Semwal, Liam Mark, Laura Abbott, Brian Starkey, Hridya Valsaraju, Suren Baghdasaryan, Sandeep Patil, Ørjan Eide, Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones, linux-media, dri-devel Since the heap-helpers logic ended up not being as generic as hoped, move the heap-helpers dma_buf_ops implementations into the cma_heap directly. This will allow us to remove the heap_helpers code in a following patch. Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Liam Mark <lmark@codeaurora.org> Cc: Laura Abbott <labbott@kernel.org> Cc: Brian Starkey <Brian.Starkey@arm.com> Cc: Hridya Valsaraju <hridya@google.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sandeep Patil <sspatil@google.com> Cc: Ørjan Eide <orjan.eide@arm.com> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Ezequiel Garcia <ezequiel@collabora.com> Cc: Simon Ser <contact@emersion.fr> Cc: James Jones <jajones@nvidia.com> Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz <john.stultz@linaro.org> --- drivers/dma-buf/heaps/cma_heap.c | 322 ++++++++++++++++++++++++++----- 1 file changed, 270 insertions(+), 52 deletions(-) diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 626cf7fd033a..3adfdbed0829 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -2,76 +2,291 @@ /* * DMABUF CMA heap exporter * - * Copyright (C) 2012, 2019 Linaro Ltd. + * Copyright (C) 2012, 2019, 2020 Linaro Ltd. * Author: <benjamin.gaignard@linaro.org> for ST-Ericsson. + * + * Also utilizing parts of Andrew Davis' SRAM heap: + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ + * Andrew F. Davis <afd@ti.com> */ - #include <linux/cma.h> -#include <linux/device.h> #include <linux/dma-buf.h> -#include <linux/dma-heap.h> #include <linux/dma-contiguous.h> +#include <linux/dma-heap.h> +#include <linux/dma-mapping.h> #include <linux/err.h> -#include <linux/errno.h> #include <linux/highmem.h> +#include <linux/io.h> +#include <linux/mm.h> #include <linux/module.h> -#include <linux/slab.h> #include <linux/scatterlist.h> -#include <linux/sched/signal.h> +#include <linux/slab.h> -#include "heap-helpers.h" struct cma_heap { struct dma_heap *heap; struct cma *cma; }; -static void cma_heap_free(struct heap_helper_buffer *buffer) +struct cma_heap_buffer { + struct cma_heap *heap; + struct list_head attachments; + struct mutex lock; + unsigned long len; + struct page *cma_pages; + struct page **pages; + pgoff_t pagecount; + int vmap_cnt; + void *vaddr; +}; + +struct dma_heap_attachment { + struct device *dev; + struct sg_table table; + struct list_head list; +}; + +static int cma_heap_attach(struct dma_buf *dmabuf, + struct dma_buf_attachment *attachment) { - struct cma_heap *cma_heap = dma_heap_get_drvdata(buffer->heap); - unsigned long nr_pages = buffer->pagecount; - struct page *cma_pages = buffer->priv_virt; + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a; + int ret; - /* free page list */ - kfree(buffer->pages); - /* release memory */ - cma_release(cma_heap->cma, cma_pages, nr_pages); + a = kzalloc(sizeof(*a), GFP_KERNEL); + if (!a) + return -ENOMEM; + + ret = sg_alloc_table_from_pages(&a->table, buffer->pages, + buffer->pagecount, 0, + buffer->pagecount << PAGE_SHIFT, + GFP_KERNEL); + if (ret) { + kfree(a); + return ret; + } + + a->dev = attachment->dev; + INIT_LIST_HEAD(&a->list); + + attachment->priv = a; + + mutex_lock(&buffer->lock); + list_add(&a->list, &buffer->attachments); + mutex_unlock(&buffer->lock); + + return 0; +} + +static void cma_heap_detatch(struct dma_buf *dmabuf, + struct dma_buf_attachment *attachment) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a = attachment->priv; + + mutex_lock(&buffer->lock); + list_del(&a->list); + mutex_unlock(&buffer->lock); + + sg_free_table(&a->table); + kfree(a); +} + +static struct sg_table *cma_heap_map_dma_buf(struct dma_buf_attachment *attachment, + enum dma_data_direction direction) +{ + struct dma_heap_attachment *a = attachment->priv; + struct sg_table *table = &a->table; + + if (!dma_map_sg(attachment->dev, table->sgl, table->nents, + direction)) + table = ERR_PTR(-ENOMEM); + return table; +} + +static void cma_heap_unmap_dma_buf(struct dma_buf_attachment *attachment, + struct sg_table *table, + enum dma_data_direction direction) +{ + dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction); +} + +static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, + enum dma_data_direction direction) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a; + int ret = 0; + + if (buffer->vmap_cnt) + invalidate_kernel_vmap_range(buffer->vaddr, buffer->len); + + mutex_lock(&buffer->lock); + list_for_each_entry(a, &buffer->attachments, list) { + dma_sync_sg_for_cpu(a->dev, a->table.sgl, a->table.nents, + direction); + } + mutex_unlock(&buffer->lock); + + return ret; +} + +static int cma_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf, + enum dma_data_direction direction) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct dma_heap_attachment *a; + + if (buffer->vmap_cnt) + flush_kernel_vmap_range(buffer->vaddr, buffer->len); + + mutex_lock(&buffer->lock); + list_for_each_entry(a, &buffer->attachments, list) { + dma_sync_sg_for_device(a->dev, a->table.sgl, a->table.nents, + direction); + } + mutex_unlock(&buffer->lock); + + return 0; +} + +static vm_fault_t cma_heap_vm_fault(struct vm_fault *vmf) +{ + struct vm_area_struct *vma = vmf->vma; + struct cma_heap_buffer *buffer = vma->vm_private_data; + + if (vmf->pgoff > buffer->pagecount) + return VM_FAULT_SIGBUS; + + vmf->page = buffer->pages[vmf->pgoff]; + get_page(vmf->page); + + return 0; +} + +static const struct vm_operations_struct dma_heap_vm_ops = { + .fault = cma_heap_vm_fault, +}; + +static int cma_heap_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + + if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) + return -EINVAL; + + vma->vm_ops = &dma_heap_vm_ops; + vma->vm_private_data = buffer; + + return 0; +} + +static void *cma_heap_do_vmap(struct cma_heap_buffer *buffer) +{ + void *vaddr; + + vaddr = vmap(buffer->pages, buffer->pagecount, VM_MAP, PAGE_KERNEL); + if (!vaddr) + return ERR_PTR(-ENOMEM); + + return vaddr; +} + +static void *cma_heap_vmap(struct dma_buf *dmabuf) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + void *vaddr; + + mutex_lock(&buffer->lock); + if (buffer->vmap_cnt) { + buffer->vmap_cnt++; + return buffer->vaddr; + } + + vaddr = cma_heap_do_vmap(buffer); + if (IS_ERR(vaddr)) + return vaddr; + + buffer->vaddr = vaddr; + buffer->vmap_cnt++; + mutex_unlock(&buffer->lock); + + return vaddr; +} + +static void cma_heap_vunmap(struct dma_buf *dmabuf, void *vaddr) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + + mutex_lock(&buffer->lock); + if (!--buffer->vmap_cnt) { + vunmap(buffer->vaddr); + buffer->vaddr = NULL; + } + mutex_unlock(&buffer->lock); +} + +static void cma_heap_dma_buf_release(struct dma_buf *dmabuf) +{ + struct cma_heap_buffer *buffer = dmabuf->priv; + struct cma_heap *cma_heap = buffer->heap; + + if (buffer->vmap_cnt > 0) { + WARN(1, "%s: buffer still mapped in the kernel\n", __func__); + vunmap(buffer->vaddr); + } + + cma_release(cma_heap->cma, buffer->cma_pages, buffer->pagecount); kfree(buffer); } -/* dmabuf heap CMA operations functions */ +const struct dma_buf_ops cma_heap_buf_ops = { + .attach = cma_heap_attach, + .detach = cma_heap_detatch, + .map_dma_buf = cma_heap_map_dma_buf, + .unmap_dma_buf = cma_heap_unmap_dma_buf, + .begin_cpu_access = cma_heap_dma_buf_begin_cpu_access, + .end_cpu_access = cma_heap_dma_buf_end_cpu_access, + .mmap = cma_heap_mmap, + .vmap = cma_heap_vmap, + .vunmap = cma_heap_vunmap, + .release = cma_heap_dma_buf_release, +}; + static int cma_heap_allocate(struct dma_heap *heap, - unsigned long len, - unsigned long fd_flags, - unsigned long heap_flags) + unsigned long len, + unsigned long fd_flags, + unsigned long heap_flags) { struct cma_heap *cma_heap = dma_heap_get_drvdata(heap); - struct heap_helper_buffer *helper_buffer; - struct page *cma_pages; + struct cma_heap_buffer *buffer; + DEFINE_DMA_BUF_EXPORT_INFO(exp_info); size_t size = PAGE_ALIGN(len); - unsigned long nr_pages = size >> PAGE_SHIFT; + pgoff_t pagecount = size >> PAGE_SHIFT; unsigned long align = get_order(size); + struct page *cma_pages; struct dma_buf *dmabuf; - int ret = -ENOMEM; pgoff_t pg; + int ret; - if (align > CONFIG_CMA_ALIGNMENT) - align = CONFIG_CMA_ALIGNMENT; - - helper_buffer = kzalloc(sizeof(*helper_buffer), GFP_KERNEL); - if (!helper_buffer) + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); + if (!buffer) return -ENOMEM; - init_heap_helper_buffer(helper_buffer, cma_heap_free); - helper_buffer->heap = heap; - helper_buffer->size = len; + INIT_LIST_HEAD(&buffer->attachments); + mutex_init(&buffer->lock); + buffer->len = size; - cma_pages = cma_alloc(cma_heap->cma, nr_pages, align, false); + if (align > CONFIG_CMA_ALIGNMENT) + align = CONFIG_CMA_ALIGNMENT; + + cma_pages = cma_alloc(cma_heap->cma, pagecount, align, false); if (!cma_pages) - goto free_buf; + goto free_buffer; + /* Clear the cma pages */ if (PageHighMem(cma_pages)) { - unsigned long nr_clear_pages = nr_pages; + unsigned long nr_clear_pages = pagecount; struct page *page = cma_pages; while (nr_clear_pages > 0) { @@ -85,7 +300,6 @@ static int cma_heap_allocate(struct dma_heap *heap, */ if (fatal_signal_pending(current)) goto free_cma; - page++; nr_clear_pages--; } @@ -93,28 +307,30 @@ static int cma_heap_allocate(struct dma_heap *heap, memset(page_address(cma_pages), 0, size); } - helper_buffer->pagecount = nr_pages; - helper_buffer->pages = kmalloc_array(helper_buffer->pagecount, - sizeof(*helper_buffer->pages), - GFP_KERNEL); - if (!helper_buffer->pages) { + buffer->pages = kmalloc_array(pagecount, sizeof(*buffer->pages), GFP_KERNEL); + if (!buffer->pages) { ret = -ENOMEM; goto free_cma; } - for (pg = 0; pg < helper_buffer->pagecount; pg++) - helper_buffer->pages[pg] = &cma_pages[pg]; + for (pg = 0; pg < pagecount; pg++) + buffer->pages[pg] = &cma_pages[pg]; + + buffer->cma_pages = cma_pages; + buffer->heap = cma_heap; + buffer->pagecount = pagecount; /* create the dmabuf */ - dmabuf = heap_helper_export_dmabuf(helper_buffer, fd_flags); + exp_info.ops = &cma_heap_buf_ops; + exp_info.size = buffer->len; + exp_info.flags = fd_flags; + exp_info.priv = buffer; + dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) { ret = PTR_ERR(dmabuf); goto free_pages; } - helper_buffer->dmabuf = dmabuf; - helper_buffer->priv_virt = cma_pages; - ret = dma_buf_fd(dmabuf, fd_flags); if (ret < 0) { dma_buf_put(dmabuf); @@ -125,15 +341,16 @@ static int cma_heap_allocate(struct dma_heap *heap, return ret; free_pages: - kfree(helper_buffer->pages); + kfree(buffer->pages); free_cma: - cma_release(cma_heap->cma, cma_pages, nr_pages); -free_buf: - kfree(helper_buffer); + cma_release(cma_heap->cma, cma_pages, pagecount); +free_buffer: + kfree(buffer); + return ret; } -static const struct dma_heap_ops cma_heap_ops = { +static struct dma_heap_ops cma_heap_ops = { .allocate = cma_heap_allocate, }; @@ -175,3 +392,4 @@ static int add_default_cma_heap(void) module_init(add_default_cma_heap); MODULE_DESCRIPTION("DMA-BUF CMA Heap"); MODULE_LICENSE("GPL v2"); + -- 2.17.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation 2020-09-26 4:24 ` John Stultz (?) @ 2020-09-26 10:58 ` kernel test robot -1 siblings, 0 replies; 6+ messages in thread From: kernel test robot @ 2020-09-26 10:58 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 9820 bytes --] Hi John, [FYI, it's a private test report for your RFC patch.] [auto build test WARNING on linux/master] [also build test WARNING on tegra-drm/drm/tegra/for-next linus/master v5.9-rc6 next-20200925] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/John-Stultz/dma-buf-Performance-improvements-for-system-heap/20200926-122541 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bcf876870b95592b52519ed4aafcf9d95999bc9c config: x86_64-randconfig-a001-20200925 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project a83eb048cb9a75da7a07a9d5318bbdbf54885c87) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install x86_64 cross compiling tool for clang build # apt-get install binutils-x86-64-linux-gnu # https://github.com/0day-ci/linux/commit/b5282aa5dad710f7d7f2c47d83d66f3af38dde13 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review John-Stultz/dma-buf-Performance-improvements-for-system-heap/20200926-122541 git checkout b5282aa5dad710f7d7f2c47d83d66f3af38dde13 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/dma-buf/heaps/cma_heap.c:301:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (fatal_signal_pending(current)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/dma-buf/heaps/cma_heap.c:350:9: note: uninitialized use occurs here return ret; ^~~ drivers/dma-buf/heaps/cma_heap.c:301:4: note: remove the 'if' if its condition is always false if (fatal_signal_pending(current)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/dma-buf/heaps/cma_heap.c:284:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!cma_pages) ^~~~~~~~~~ drivers/dma-buf/heaps/cma_heap.c:350:9: note: uninitialized use occurs here return ret; ^~~ drivers/dma-buf/heaps/cma_heap.c:284:2: note: remove the 'if' if its condition is always false if (!cma_pages) ^~~~~~~~~~~~~~~ drivers/dma-buf/heaps/cma_heap.c:270:9: note: initialize the variable 'ret' to silence this warning int ret; ^ = 0 2 warnings generated. vim +301 drivers/dma-buf/heaps/cma_heap.c b5282aa5dad710 John Stultz 2020-09-26 255 b61614ec318aae John Stultz 2019-12-03 256 static int cma_heap_allocate(struct dma_heap *heap, b61614ec318aae John Stultz 2019-12-03 257 unsigned long len, b61614ec318aae John Stultz 2019-12-03 258 unsigned long fd_flags, b61614ec318aae John Stultz 2019-12-03 259 unsigned long heap_flags) b61614ec318aae John Stultz 2019-12-03 260 { b61614ec318aae John Stultz 2019-12-03 261 struct cma_heap *cma_heap = dma_heap_get_drvdata(heap); b5282aa5dad710 John Stultz 2020-09-26 262 struct cma_heap_buffer *buffer; b5282aa5dad710 John Stultz 2020-09-26 263 DEFINE_DMA_BUF_EXPORT_INFO(exp_info); b61614ec318aae John Stultz 2019-12-03 264 size_t size = PAGE_ALIGN(len); b5282aa5dad710 John Stultz 2020-09-26 265 pgoff_t pagecount = size >> PAGE_SHIFT; b61614ec318aae John Stultz 2019-12-03 266 unsigned long align = get_order(size); b5282aa5dad710 John Stultz 2020-09-26 267 struct page *cma_pages; b61614ec318aae John Stultz 2019-12-03 268 struct dma_buf *dmabuf; b61614ec318aae John Stultz 2019-12-03 269 pgoff_t pg; b5282aa5dad710 John Stultz 2020-09-26 270 int ret; b61614ec318aae John Stultz 2019-12-03 271 b5282aa5dad710 John Stultz 2020-09-26 272 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); b5282aa5dad710 John Stultz 2020-09-26 273 if (!buffer) b61614ec318aae John Stultz 2019-12-03 274 return -ENOMEM; b61614ec318aae John Stultz 2019-12-03 275 b5282aa5dad710 John Stultz 2020-09-26 276 INIT_LIST_HEAD(&buffer->attachments); b5282aa5dad710 John Stultz 2020-09-26 277 mutex_init(&buffer->lock); b5282aa5dad710 John Stultz 2020-09-26 278 buffer->len = size; b61614ec318aae John Stultz 2019-12-03 279 b5282aa5dad710 John Stultz 2020-09-26 280 if (align > CONFIG_CMA_ALIGNMENT) b5282aa5dad710 John Stultz 2020-09-26 281 align = CONFIG_CMA_ALIGNMENT; b5282aa5dad710 John Stultz 2020-09-26 282 b5282aa5dad710 John Stultz 2020-09-26 283 cma_pages = cma_alloc(cma_heap->cma, pagecount, align, false); b61614ec318aae John Stultz 2019-12-03 284 if (!cma_pages) b5282aa5dad710 John Stultz 2020-09-26 285 goto free_buffer; b61614ec318aae John Stultz 2019-12-03 286 b5282aa5dad710 John Stultz 2020-09-26 287 /* Clear the cma pages */ b61614ec318aae John Stultz 2019-12-03 288 if (PageHighMem(cma_pages)) { b5282aa5dad710 John Stultz 2020-09-26 289 unsigned long nr_clear_pages = pagecount; b61614ec318aae John Stultz 2019-12-03 290 struct page *page = cma_pages; b61614ec318aae John Stultz 2019-12-03 291 b61614ec318aae John Stultz 2019-12-03 292 while (nr_clear_pages > 0) { b61614ec318aae John Stultz 2019-12-03 293 void *vaddr = kmap_atomic(page); b61614ec318aae John Stultz 2019-12-03 294 b61614ec318aae John Stultz 2019-12-03 295 memset(vaddr, 0, PAGE_SIZE); b61614ec318aae John Stultz 2019-12-03 296 kunmap_atomic(vaddr); b61614ec318aae John Stultz 2019-12-03 297 /* b61614ec318aae John Stultz 2019-12-03 298 * Avoid wasting time zeroing memory if the process b61614ec318aae John Stultz 2019-12-03 299 * has been killed by by SIGKILL b61614ec318aae John Stultz 2019-12-03 300 */ b61614ec318aae John Stultz 2019-12-03 @301 if (fatal_signal_pending(current)) b61614ec318aae John Stultz 2019-12-03 302 goto free_cma; b61614ec318aae John Stultz 2019-12-03 303 page++; b61614ec318aae John Stultz 2019-12-03 304 nr_clear_pages--; b61614ec318aae John Stultz 2019-12-03 305 } b61614ec318aae John Stultz 2019-12-03 306 } else { b61614ec318aae John Stultz 2019-12-03 307 memset(page_address(cma_pages), 0, size); b61614ec318aae John Stultz 2019-12-03 308 } b61614ec318aae John Stultz 2019-12-03 309 b5282aa5dad710 John Stultz 2020-09-26 310 buffer->pages = kmalloc_array(pagecount, sizeof(*buffer->pages), GFP_KERNEL); b5282aa5dad710 John Stultz 2020-09-26 311 if (!buffer->pages) { b61614ec318aae John Stultz 2019-12-03 312 ret = -ENOMEM; b61614ec318aae John Stultz 2019-12-03 313 goto free_cma; b61614ec318aae John Stultz 2019-12-03 314 } b61614ec318aae John Stultz 2019-12-03 315 b5282aa5dad710 John Stultz 2020-09-26 316 for (pg = 0; pg < pagecount; pg++) b5282aa5dad710 John Stultz 2020-09-26 317 buffer->pages[pg] = &cma_pages[pg]; b5282aa5dad710 John Stultz 2020-09-26 318 b5282aa5dad710 John Stultz 2020-09-26 319 buffer->cma_pages = cma_pages; b5282aa5dad710 John Stultz 2020-09-26 320 buffer->heap = cma_heap; b5282aa5dad710 John Stultz 2020-09-26 321 buffer->pagecount = pagecount; b61614ec318aae John Stultz 2019-12-03 322 b61614ec318aae John Stultz 2019-12-03 323 /* create the dmabuf */ b5282aa5dad710 John Stultz 2020-09-26 324 exp_info.ops = &cma_heap_buf_ops; b5282aa5dad710 John Stultz 2020-09-26 325 exp_info.size = buffer->len; b5282aa5dad710 John Stultz 2020-09-26 326 exp_info.flags = fd_flags; b5282aa5dad710 John Stultz 2020-09-26 327 exp_info.priv = buffer; b5282aa5dad710 John Stultz 2020-09-26 328 dmabuf = dma_buf_export(&exp_info); b61614ec318aae John Stultz 2019-12-03 329 if (IS_ERR(dmabuf)) { b61614ec318aae John Stultz 2019-12-03 330 ret = PTR_ERR(dmabuf); b61614ec318aae John Stultz 2019-12-03 331 goto free_pages; b61614ec318aae John Stultz 2019-12-03 332 } b61614ec318aae John Stultz 2019-12-03 333 b61614ec318aae John Stultz 2019-12-03 334 ret = dma_buf_fd(dmabuf, fd_flags); b61614ec318aae John Stultz 2019-12-03 335 if (ret < 0) { b61614ec318aae John Stultz 2019-12-03 336 dma_buf_put(dmabuf); b61614ec318aae John Stultz 2019-12-03 337 /* just return, as put will call release and that will free */ b61614ec318aae John Stultz 2019-12-03 338 return ret; b61614ec318aae John Stultz 2019-12-03 339 } b61614ec318aae John Stultz 2019-12-03 340 b61614ec318aae John Stultz 2019-12-03 341 return ret; b61614ec318aae John Stultz 2019-12-03 342 b61614ec318aae John Stultz 2019-12-03 343 free_pages: b5282aa5dad710 John Stultz 2020-09-26 344 kfree(buffer->pages); b61614ec318aae John Stultz 2019-12-03 345 free_cma: b5282aa5dad710 John Stultz 2020-09-26 346 cma_release(cma_heap->cma, cma_pages, pagecount); b5282aa5dad710 John Stultz 2020-09-26 347 free_buffer: b5282aa5dad710 John Stultz 2020-09-26 348 kfree(buffer); b5282aa5dad710 John Stultz 2020-09-26 349 b61614ec318aae John Stultz 2019-12-03 350 return ret; b61614ec318aae John Stultz 2019-12-03 351 } b61614ec318aae John Stultz 2019-12-03 352 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 34742 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation 2020-09-26 4:24 ` John Stultz (?) (?) @ 2020-09-27 1:32 ` kernel test robot -1 siblings, 0 replies; 6+ messages in thread From: kernel test robot @ 2020-09-27 1:32 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 1788 bytes --] Hi John, [FYI, it's a private test report for your RFC patch.] [auto build test WARNING on linux/master] [also build test WARNING on tegra-drm/drm/tegra/for-next linus/master v5.9-rc6 next-20200925] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/John-Stultz/dma-buf-Performance-improvements-for-system-heap/20200926-122541 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bcf876870b95592b52519ed4aafcf9d95999bc9c config: x86_64-randconfig-s022-20200925 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.2-201-g24bdaac6-dirty # https://github.com/0day-ci/linux/commit/b5282aa5dad710f7d7f2c47d83d66f3af38dde13 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review John-Stultz/dma-buf-Performance-improvements-for-system-heap/20200926-122541 git checkout b5282aa5dad710f7d7f2c47d83d66f3af38dde13 # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> sparse warnings: (new ones prefixed by >>) >> drivers/dma-buf/heaps/cma_heap.c:243:26: sparse: sparse: symbol 'cma_heap_buf_ops' was not declared. Should it be static? Please review and possibly fold the followup patch. --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 31530 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-09-27 1:32 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-09-26 10:11 [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation kernel test robot 2020-09-26 10:11 ` [PATCH] dma-buf: heaps: fix returnvar.cocci warnings kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2020-09-26 4:24 [RFC][PATCH 0/6] dma-buf: Performance improvements for system heap John Stultz 2020-09-26 4:24 ` [RFC][PATCH 2/6] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation John Stultz 2020-09-26 4:24 ` John Stultz 2020-09-26 10:58 ` kernel test robot 2020-09-27 1:32 ` kernel test robot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.