From: Linus Walleij Date: Tue, 10 Mar 2026 08:53:11 +0000 (+0100) Subject: dma-buf: heaps: Clear CMA pages with clear_pages() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e669d2f601919aedc6cadca673109684aa499326;p=thirdparty%2Fkernel%2Flinux.git dma-buf: heaps: Clear CMA pages with clear_pages() As of commit 62a9f5a85b98 "mm: introduce clear_pages() and clear_user_pages()" we can clear a range of pages with a potentially assembly-optimized call. Instead of using a memset, use this helper to clear the whole range of pages from the CMA allocation. Reviewed-by: T.J. Mercier Reviewed-by: Maxime Ripard Signed-off-by: Linus Walleij Link: https://patch.msgid.link/20260310-cma-heap-clear-pages-v2-1-ecbbed3d7e6d@kernel.org --- diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index bd3370b9a3f6d..f0bacf25ed9dd 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -343,7 +343,7 @@ static struct dma_buf *cma_heap_allocate(struct dma_heap *heap, nr_clear_pages--; } } else { - memset(page_address(cma_pages), 0, size); + clear_pages(page_address(cma_pages), pagecount); } buffer->pages = kmalloc_objs(*buffer->pages, pagecount);