From patchwork Sun Nov 20 23:44:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 13050199 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CFCAC4332F for ; Sun, 20 Nov 2022 23:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbiKTXpE (ORCPT ); Sun, 20 Nov 2022 18:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiKTXpC (ORCPT ); Sun, 20 Nov 2022 18:45:02 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93F1E167FE for ; Sun, 20 Nov 2022 15:45:01 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1owtzf-0008Fq-LL; Mon, 21 Nov 2022 00:44:59 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1owtza-005XyP-Pm; Mon, 21 Nov 2022 00:44:55 +0100 Received: from mgr by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1owtzb-002Kfj-1Y; Mon, 21 Nov 2022 00:44:55 +0100 From: Michael Grzeschik To: linux-media@vger.kernel.org Cc: tfiga@chromium.org, m.szyprowski@samsung.com, kernel@pengutronix.de Subject: [PATCH] media: videobuf2-dma-sg: use v{un,}map instead of vm_{un,}map_ram Date: Mon, 21 Nov 2022 00:44:41 +0100 Message-Id: <20221120234441.550908-1-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The comments before the vm_map_ram function state that it should be used for up to 256 KB only, and video buffers are definitely much larger. It recommends using vmap in that case. Signed-off-by: Michael Grzeschik Acked-by: Tomasz Figa --- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c index dcb8de5ab3e84a..e86621fba350f3 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -188,7 +188,7 @@ static void vb2_dma_sg_put(void *buf_priv) dma_unmap_sgtable(buf->dev, sgt, buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC); if (buf->vaddr) - vm_unmap_ram(buf->vaddr, buf->num_pages); + vunmap(buf->vaddr); sg_free_table(buf->dma_sgt); while (--i >= 0) __free_page(buf->pages[i]); @@ -289,7 +289,7 @@ static void vb2_dma_sg_put_userptr(void *buf_priv) __func__, buf->num_pages); dma_unmap_sgtable(buf->dev, sgt, buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC); if (buf->vaddr) - vm_unmap_ram(buf->vaddr, buf->num_pages); + vunmap(buf->vaddr); sg_free_table(buf->dma_sgt); if (buf->dma_dir == DMA_FROM_DEVICE || buf->dma_dir == DMA_BIDIRECTIONAL) @@ -312,7 +312,8 @@ static void *vb2_dma_sg_vaddr(struct vb2_buffer *vb, void *buf_priv) ret = dma_buf_vmap(buf->db_attach->dmabuf, &map); buf->vaddr = ret ? NULL : map.vaddr; } else { - buf->vaddr = vm_map_ram(buf->pages, buf->num_pages, -1); + buf->vaddr = vmap(buf->pages, buf->num_pages, VM_MAP, + PAGE_KERNEL); } }