Re: [PATCH v8 4/5] dma-buf: system_heap: Add drm pagepool support to system heap
Hi John, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.12-rc1 next-20210304] [cannot apply to linux/master drm-intel/for-linux-next drm-tip/drm-tip] [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/Generic-page-pool-deferred-freeing-for-system-dmabuf-heap/20210305-072137 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3cb60ee6323968b694208c4cbd56a7176396e931 config: ia64-randconfig-c003-20210305 (attached as .config) compiler: ia64-linux-gcc (GCC) 9.3.0 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 # https://github.com/0day-ci/linux/commit/6a9bf19a9ed9e5058a11a3e3217530fdf2675e0c git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review John-Stultz/Generic-page-pool-deferred-freeing-for-system-dmabuf-heap/20210305-072137 git checkout 6a9bf19a9ed9e5058a11a3e3217530fdf2675e0c # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): ia64-linux-ld: drivers/dma-buf/heaps/system_heap.o: in function `system_heap_create': system_heap.c:(.text+0x1b2): undefined reference to `drm_page_pool_init' ia64-linux-ld: system_heap.c:(.text+0x1e2): undefined reference to `drm_page_pool_init' ia64-linux-ld: system_heap.c:(.text+0x212): undefined reference to `drm_page_pool_init' ia64-linux-ld: drivers/dma-buf/heaps/system_heap.o: in function `system_heap_dma_buf_release': system_heap.c:(.text+0x1312): undefined reference to `drm_page_pool_add' >> ia64-linux-ld: system_heap.c:(.text+0x1432): undefined reference to >> `drm_page_pool_add' ia64-linux-ld: drivers/dma-buf/heaps/system_heap.o: in function `system_heap_allocate': system_heap.c:(.text+0x16e2): undefined reference to `drm_page_pool_remove' Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for DRM_PAGE_POOL Depends on HAS_IOMEM && DRM Selected by - DMABUF_HEAPS_SYSTEM && DMABUF_HEAPS --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH v8 4/5] dma-buf: system_heap: Add drm pagepool support to system heap
Hi John, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.12-rc1] [cannot apply to linux/master drm-intel/for-linux-next drm-tip/drm-tip] [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/Generic-page-pool-deferred-freeing-for-system-dmabuf-heap/20210305-072137 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3cb60ee6323968b694208c4cbd56a7176396e931 config: openrisc-randconfig-p001-20210304 (attached as .config) compiler: or1k-linux-gcc (GCC) 9.3.0 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 # https://github.com/0day-ci/linux/commit/6a9bf19a9ed9e5058a11a3e3217530fdf2675e0c git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review John-Stultz/Generic-page-pool-deferred-freeing-for-system-dmabuf-heap/20210305-072137 git checkout 6a9bf19a9ed9e5058a11a3e3217530fdf2675e0c # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=openrisc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): or1k-linux-ld: arch/openrisc/kernel/entry.o: in function `_external_irq_handler': (.text+0x804): undefined reference to `printk' (.text+0x804): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `printk' or1k-linux-ld: drivers/dma-buf/heaps/system_heap.o: in function `system_heap_create': >> system_heap.c:(.text+0x15c): undefined reference to `drm_page_pool_init' system_heap.c:(.text+0x15c): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `drm_page_pool_init' >> or1k-linux-ld: system_heap.c:(.text+0x16c): undefined reference to >> `drm_page_pool_init' system_heap.c:(.text+0x16c): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `drm_page_pool_init' or1k-linux-ld: system_heap.c:(.text+0x17c): undefined reference to `drm_page_pool_init' system_heap.c:(.text+0x17c): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `drm_page_pool_init' or1k-linux-ld: drivers/dma-buf/heaps/system_heap.o: in function `system_heap_dma_buf_release': >> system_heap.c:(.text+0xf78): undefined reference to `drm_page_pool_add' system_heap.c:(.text+0xf78): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `drm_page_pool_add' or1k-linux-ld: drivers/dma-buf/heaps/system_heap.o: in function `system_heap_allocate': >> system_heap.c:(.text+0x11f8): undefined reference to `drm_page_pool_remove' system_heap.c:(.text+0x11f8): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `drm_page_pool_remove' Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for DRM_PAGE_POOL Depends on HAS_IOMEM && DRM Selected by - DMABUF_HEAPS_SYSTEM && DMABUF_HEAPS "cppcheck warnings: (new ones prefixed by >>)" >> drivers/dma-buf/heaps/system_heap.c:290:2: warning: int result is returned >> as long value. If the return value is long to avoid loss of information, >> then you have loss of information. [truncLongCastReturn] return 1 << pool->order; ^ --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
[PATCH v8 4/5] dma-buf: system_heap: Add drm pagepool support to system heap
Utilize the drm pagepool code to speed up allocation performance. This is similar to the ION pagepool usage, but tries to utilize generic code instead of a custom implementation. Cc: Daniel Vetter Cc: Christian Koenig Cc: Sumit Semwal Cc: Liam Mark Cc: Chris Goldsworthy Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: Ørjan Eide Cc: Robin Murphy Cc: Ezequiel Garcia Cc: Simon Ser Cc: James Jones Cc: linux-me...@vger.kernel.org Cc: dri-de...@lists.freedesktop.org Signed-off-by: John Stultz --- v2: * Fix build issue caused by selecting PAGE_POOL w/o NET as Reported-by: kernel test robot v3: * Simplify the page zeroing logic a bit by using kmap_atomic instead of vmap as suggested by Daniel Mentz v5: * Shift away from networking page pool completely to dmabuf page pool implementation v6: * Switch again to using the drm_page_pool code shared w/ ttm_pool v7: * Slight rework for drm_page_pool changes v8: * Rework to use the rewritten drm_page_pool logic * Drop explicit buffer zeroing, as the drm_page_pool handles that --- drivers/dma-buf/heaps/Kconfig | 1 + drivers/dma-buf/heaps/system_heap.c | 27 --- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/heaps/Kconfig b/drivers/dma-buf/heaps/Kconfig index f7aef8bc7119..7e28934e0def 100644 --- a/drivers/dma-buf/heaps/Kconfig +++ b/drivers/dma-buf/heaps/Kconfig @@ -4,6 +4,7 @@ config DMABUF_HEAPS_DEFERRED_FREE config DMABUF_HEAPS_SYSTEM bool "DMA-BUF System Heap" depends on DMABUF_HEAPS + select DRM_PAGE_POOL help Choose this option to enable the system dmabuf heap. The system heap is backed by pages from the buddy allocator. If in doubt, say Y. diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 29e49ac17251..006271881d85 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -21,6 +21,8 @@ #include #include +#include + static struct dma_heap *sys_heap; struct system_heap_buffer { @@ -53,6 +55,7 @@ static gfp_t order_flags[] = {HIGH_ORDER_GFP, LOW_ORDER_GFP, LOW_ORDER_GFP}; */ static const unsigned int orders[] = {8, 4, 0}; #define NUM_ORDERS ARRAY_SIZE(orders) +struct drm_page_pool pools[NUM_ORDERS]; static struct sg_table *dup_sg_table(struct sg_table *table) { @@ -281,18 +284,28 @@ static void system_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map) dma_buf_map_clear(map); } +static unsigned long system_heap_free_pages(struct drm_page_pool *pool, struct page *p) +{ + __free_pages(p, pool->order); + return 1 << pool->order; +} + static void system_heap_dma_buf_release(struct dma_buf *dmabuf) { struct system_heap_buffer *buffer = dmabuf->priv; struct sg_table *table; struct scatterlist *sg; - int i; + int i, j; table = >sg_table; for_each_sg(table->sgl, sg, table->nents, i) { struct page *page = sg_page(sg); - __free_pages(page, compound_order(page)); + for (j = 0; j < NUM_ORDERS; j++) { + if (compound_order(page) == orders[j]) + break; + } + drm_page_pool_add([j], page); } sg_free_table(table); kfree(buffer); @@ -323,7 +336,9 @@ static struct page *alloc_largest_available(unsigned long size, if (max_order < orders[i]) continue; - page = alloc_pages(order_flags[i], orders[i]); + page = drm_page_pool_remove([i]); + if (!page) + page = alloc_pages(order_flags[i], orders[i]); if (!page) continue; return page; @@ -423,6 +438,12 @@ static const struct dma_heap_ops system_heap_ops = { static int system_heap_create(void) { struct dma_heap_export_info exp_info; + int i; + + for (i = 0; i < NUM_ORDERS; i++) { + drm_page_pool_init([i], orders[i], + system_heap_free_pages); + } exp_info.name = "system"; exp_info.ops = _heap_ops; -- 2.25.1