From patchwork Mon Dec 17 20:25:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACF7214DE for ; Mon, 17 Dec 2018 20:21:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E3A62A2A9 for ; Mon, 17 Dec 2018 20:21:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9249A2A2DF; Mon, 17 Dec 2018 20:21:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0B8F2A2A9 for ; Mon, 17 Dec 2018 20:21:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E80258E0053; Mon, 17 Dec 2018 15:21:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E09708E0033; Mon, 17 Dec 2018 15:21:42 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CACD38E0053; Mon, 17 Dec 2018 15:21:42 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 865598E0033 for ; Mon, 17 Dec 2018 15:21:42 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id s71so12823615pfi.22 for ; Mon, 17 Dec 2018 12:21:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=7Lxrxd/hSsekQvS5TNwgf4HJhjrgrc3uztzkOk3jJZI=; b=GZ289+f/KoTfccNoVnL4kQzBMtTxp0pTWgU9I52RK+Rjuwv+WjISw+X7w8kVgD/DHY tjMisfmPhqyxTWj5TYalg4UfisZ75b17cnPlbAfPpEERFCRmiGZ0fbcrD8kbMBfm3o1r FcZ/J9M8U8o7ogpjC3Tk8aVVReP6+QQ69Vwcru8CoLPBqvmnKTqqnUlU2RGv2+1w7PdZ VzXSgFDQIlecdnyNsVhIc5oOXSz0YZVv/F5Igqow5iFHiPKhH61TXths4JV4TvMkfIQH /Mpa1VjqH5E4c5ysJXtu2RWc5IYdfOFjcbMMBYKZI6n3gFSbTgirqD0gTcr/Hw0CtruN p7tA== X-Gm-Message-State: AA+aEWYEZJOToiaSxDtrwLWA05sAf5yZZCUhgRg8W3lak49BEaM58660 jYa8b9sYHJMXvFXhuxQ2ub6GOnKxQF3o2LjnpaN94f6fo/10MkAHfSuVfg+oteH1IydmB5roNzK HDS1Aaz1kGYupMjVUYNVLbIhM5/FOl6L+cLgJIrE2h4rxtete3LTC351Bu891m15fRppdFsFvBD 4eyuaYlQKrqut0h4QLPJmEMvaYuFRluL3tzBq9TnuWX0D5D0fRhHrY3rL4h5ieUIQI+9D9NLayy eqXIAP4bn6nrCqYOUy9/oFRkubEdrnLVGwHO2dUouYYaI+dJmnx5ezJHpUKuKv3ad27fcJtynts gL0r33/1w8F7GSTQqb7ZAdmQnHFDJMWjkCvQ6zON2n3hJ+mj6a2ArTAjrHEzBDeAgWJ2iiX9P8b c X-Received: by 2002:a63:5c22:: with SMTP id q34mr13200436pgb.417.1545078102219; Mon, 17 Dec 2018 12:21:42 -0800 (PST) X-Received: by 2002:a63:5c22:: with SMTP id q34mr13200409pgb.417.1545078101607; Mon, 17 Dec 2018 12:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078101; cv=none; d=google.com; s=arc-20160816; b=IC9RKD3tzOA3UfxqNniR1TYNP0ExeozSKSJlBwHtaQKv5dRCntbYqQVsvF7S2HAKJ2 gne8fYSeuG8GaFWMOtvGzq6OswMGzicojjdf/aKLs1zI5hl5AiuRgZG68auB23Elt8CF LIjHER8p30UUA3QdUTR+r0Z6HAd2h6gJlDNRggr17kxw+1XHdPz3V0c1o70a9LEMIe5b +ztrTOypBCK3ko71vtjgzeUq1Gi/T1ZbUhzrt5bTmis2oJPIil9/UDE7/Ijigz3+H9Ul 0F5u+N3zlSFwSXd90V1I6p6sY1bWbo/F8pgN/KU3y7kfVLFEbNGndF/cTw5o8KI8Cf+H MtdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=7Lxrxd/hSsekQvS5TNwgf4HJhjrgrc3uztzkOk3jJZI=; b=0SjVKbPnBtJNNqfynu++xttnHIGnlOCIMw+jrEF3Ukw/G3nzlRySpAnjUDqndK1iyG 325zCYRuhErJtSv+cpXLyMb+EV53Wx1QQwAWy6c8G87NnfOYf+1Zw8rreYb+IDXTTWCu /AJdzRtrO8V6uY2jlmATff9eaKyCjeysgyW2mvVcm/D1sEb+hyTZZLkThzp/WXPiLGhY iXAWCmYtgKRnvu5yAKeNfFUs73R88FRq90rl6XsGmBbDydxhZkcB1AHj5KHc94lswWLh dyYme0gl0u9W9MNQ6bvvaRDzNj6QeOed2H9bP86cWgaSVt3qx3vP7a11X3yKk1I4Yh+Y B15w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fS++sl+t; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id bc12sor20842382plb.37.2018.12.17.12.21.41 for (Google Transport Security); Mon, 17 Dec 2018 12:21:41 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fS++sl+t; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=7Lxrxd/hSsekQvS5TNwgf4HJhjrgrc3uztzkOk3jJZI=; b=fS++sl+twua6rKfaqnifxpd414nSQn99YleFwG5ROoUgd4fYh8Gmfgnu5BfX+RGaXQ W9G3f2kmTXon3rFlZopX1f9SUhlISoKyouj9dqGZXzclbN7QgFLO8yz0spFId1MRH3O5 dGA4VWecIWUpsE/4lHE5tobsIZ8xLbEqIhVGe/tL0rrjK2CyWS7ZWFSx+xa8g7xLlthx wZs43S1vMMZKIXGIlh0lDrppYZtrUiPm7z4IHL71pM/rBdWYIVldpxLF2JHDfKcVKJO5 wQsiKO1oXc2bh3EO8jiOZ2RjNYhyAoO4biwb3t7UFifUoPLKwKkPvbQjI/EIHMCS7gST uHEw== X-Google-Smtp-Source: AFSGD/V108bv8qZyoC/yKMg096p+d0DPNRePsdoNXHX5jjToTByi5PogOU3Xk9s+Qh/1UrG/nUuFKA== X-Received: by 2002:a17:902:d202:: with SMTP id t2mr14094133ply.193.1545078100797; Mon, 17 Dec 2018 12:21:40 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id i62sm14879081pge.44.2018.12.17.12.21.39 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:21:40 -0800 (PST) Date: Tue, 18 Dec 2018 01:55:33 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181217202533.GA16294@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Acked-by: Marek Szyprowski Acked-by: Mauro Carvalho Chehab --- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c index 015e737..898adef 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -328,28 +328,19 @@ static unsigned int vb2_dma_sg_num_users(void *buf_priv) static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma) { struct vb2_dma_sg_buf *buf = buf_priv; - unsigned long uaddr = vma->vm_start; - unsigned long usize = vma->vm_end - vma->vm_start; - int i = 0; + unsigned long page_count = vma_pages(vma); + int err; if (!buf) { printk(KERN_ERR "No memory to map\n"); return -EINVAL; } - do { - int ret; - - ret = vm_insert_page(vma, uaddr, buf->pages[i++]); - if (ret) { - printk(KERN_ERR "Remapping memory, error: %d\n", ret); - return ret; - } - - uaddr += PAGE_SIZE; - usize -= PAGE_SIZE; - } while (usize > 0); - + err = vm_insert_range(vma, vma->vm_start, buf->pages, page_count); + if (err) { + printk(KERN_ERR "Remapping memory, error: %d\n", err); + return err; + } /* * Use common vm_area operations to track buffer refcount.