From: Linus Walleij Date: Sun, 30 Nov 2025 10:54:48 +0000 (+0100) Subject: dma-buf: heaps: Clear CMA pages with clear_page() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d42d701e132905d69be3a7808f2ec86bdb4c48d8;p=thirdparty%2Fkernel%2Flinux.git dma-buf: heaps: Clear CMA pages with clear_page() clear_page() translates into memset(*p, 0, PAGE_SIZE) on some architectures, but on the major architectures it will call an optimized assembly snippet so use this instead of open coding a memset(). Signed-off-by: Linus Walleij Reviewed-by: Nirmoy Das Reviewed-by: T.J. Mercier Signed-off-by: Linus Walleij Link: https://patch.msgid.link/20251130-dma-buf-heap-clear-page-v1-1-a8dcea2a88ee@linaro.org --- diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 42f88193eab9f..49cc45fb42dd7 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -331,7 +331,7 @@ static struct dma_buf *cma_heap_allocate(struct dma_heap *heap, while (nr_clear_pages > 0) { void *vaddr = kmap_local_page(page); - memset(vaddr, 0, PAGE_SIZE); + clear_page(vaddr); kunmap_local(vaddr); /* * Avoid wasting time zeroing memory if the process