]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dma-buf: heaps: Clear CMA pages with clear_pages()
authorLinus Walleij <linusw@kernel.org>
Tue, 10 Mar 2026 08:53:11 +0000 (09:53 +0100)
committerLinus Walleij <linusw@kernel.org>
Wed, 11 Mar 2026 09:06:13 +0000 (10:06 +0100)
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 <tjmercier@google.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260310-cma-heap-clear-pages-v2-1-ecbbed3d7e6d@kernel.org
drivers/dma-buf/heaps/cma_heap.c

index bd3370b9a3f6d4e18885a1d0e8ba3f659b85ef47..f0bacf25ed9dd87e6550c6ae282f20d98e667487 100644 (file)
@@ -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);