From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2800CEDEBF7 for ; Wed, 4 Mar 2026 00:25:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8306E10E8FA; Wed, 4 Mar 2026 00:25:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="oaeP7KnT"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A86110E8FA for ; Wed, 4 Mar 2026 00:25:10 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 03B9E403E4; Wed, 4 Mar 2026 00:25:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 056CDC116C6; Wed, 4 Mar 2026 00:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772583909; bh=HeaohDIlgya71qEyi4Ax5lfXmfxcDbpMvfs/QKVJz1A=; h=From:Date:Subject:To:Cc:From; b=oaeP7KnTXcb8bhjfsex4+qPuAx+uX8yt3/u3rqEsDjTZNM8jWPKmjPxV6ihXBnBlz gvKSYnpbKJowxWM/2Y6l8YptsLXCsrxiiOScVJeOIhMpIVumwOl4xjX6Ikrlu2QnGO fbkwuroENvTFHY4lMGvd3HQONo+v0/mmkzaGrT95vb7Bg/CaCkYZRVblazc1zFjXxQ YbeRSF8D28zsPmtS+9KdCtCjcsgcLCY6fwOihXqMIVr66EBhI6d+bhoqw/3EwH7Q2D +AY4qpGsXQ5NrsHGe/bZbFZxIZ+6F/WF2/XtdP6JP4kAt9heEIvBNtSMVeqQ/0NpPu yX87OwUL10kPQ== From: Linus Walleij Date: Wed, 04 Mar 2026 01:25:05 +0100 Subject: [PATCH] dma-buf: heaps: Clear CMA pages with clear_pages() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260304-cma-heap-clear-pages-v1-1-6ff59da716d3@kernel.org> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3MywqAIBBA0V+JWTdg2YP6lWgx2JgDPUQhAvHfk 5ZncW+CyEE4wlwlCPxIlPsqaOoKjKNrZ5StGFrVDkorjeYkdEwezcEU0NPOEftOWU1msqPuoKQ +sJX33y5rzh8T92GNZgAAAA== X-Change-ID: 20260303-cma-heap-clear-pages-540f3ac9f734 To: Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?utf-8?q?Christian_K=C3=B6nig?= Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Linus Walleij X-Mailer: b4 0.14.3 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Signed-off-by: Linus Walleij --- drivers/dma-buf/heaps/cma_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index bd3370b9a3f6..f0bacf25ed9d 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); --- base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f change-id: 20260303-cma-heap-clear-pages-540f3ac9f734 Best regards, -- Linus Walleij