From patchwork Thu Dec 6 18:44:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716629 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 E44961923 for ; Thu, 6 Dec 2018 18:40:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D56CD2F153 for ; Thu, 6 Dec 2018 18:40:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C98512F17A; Thu, 6 Dec 2018 18:40:54 +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=unavailable 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 7634B2F153 for ; Thu, 6 Dec 2018 18:40:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADE716B7B66; Thu, 6 Dec 2018 13:40:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A8C8C6B7B67; Thu, 6 Dec 2018 13:40:53 -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 92E546B7B68; Thu, 6 Dec 2018 13:40:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 5117A6B7B66 for ; Thu, 6 Dec 2018 13:40:53 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id v2so829992plg.6 for ; Thu, 06 Dec 2018 10:40:53 -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=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=R2ob4TYIUA+Ej9LgFTLZOp3q2H8pCFSOwf+lmLoSmpnu11Cddnc5leJ1kg48UDtqXz tkNaminamOow6Om1wCTOAEdXk50m7S2uoZWja9DgPqWW1AwS/XBFiyElkBKYD7iMFfl6 AiqrwxMlA7wbF5wuypEeyODt9ImmC1nJuEah4TFzTUbGJJ5KznSg04xN72RwnFW3y1cd tXb5rggvB5k+BCK2Bbwh9qqzrGWacVN9aTujHIum8ofzFREuYxoKSM3FlNATmNphjkit sy6K3eSZ9qcfeeayCm6vkYCtR8pwKDtOPtDGyMhmGZ3mzqvxBWY4tp38vNUFoYNmCOME a6vQ== X-Gm-Message-State: AA+aEWbOadbSx9NCFU2XsL60NCJ3lWFzD5rk39JgHyegwSryTuBUWiWL QLLRglK6ciZsAYYMDXaZhJ5+RBS8neL7TsXFTPa2uEMLfkEWRK3fDbQZTZdkcIVGul3n/WKnKtI 4FbBnWz6rKJtcVzn2xOMSeBrEPfudhuLb51jo/q1ouva0NqxvK8aaMelOaj19oYr7e4H+4K+LVe TXC5l1CBNRWg4bQuXsx/brzBFwZSEwKcxNxrIUm2Cuq6cyxaSFYXREH2bsgVD6xmD5fO33A92yY NAou4i/l/O3p4W4vGb18QegNo0CetzquyRUaL7a70mk4jwp4VJ+jF76o9GU4aA9O/7A2rCjkKpo Y6RYU6XP2uIaK+nGc5RAnAegVamsiUCLxL+X7coKxCh88oisJ9uHJavUYudXeGGZeeNOSjzRHAY V X-Received: by 2002:a17:902:f20b:: with SMTP id gn11mr28006917plb.274.1544121652988; Thu, 06 Dec 2018 10:40:52 -0800 (PST) X-Received: by 2002:a17:902:f20b:: with SMTP id gn11mr28006886plb.274.1544121652326; Thu, 06 Dec 2018 10:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121652; cv=none; d=google.com; s=arc-20160816; b=YsdUVdKl1d0fGXAKmKOpmM9W2ts4nWrOV+dtX+KvaiKHelRxBfI28xrg5Zgtkb1xts nFpsxWEjw2BfcuUZcCp8keUvfR4wcaIpwsBGRI1LJxOyN6iwzaC0lLZpWJUUiJOvMCo+ r8Xv0qzZyJuuElo8EqvxCkSQBcHTtwR5+LuXYAVo53Wbce0md3BGdzbndw+9NYlxYhVv tiHmgc39cLczISd7JzMqrf9noJRj2nC8NuxdBUY2kZxPdtal7EvVRPDsktQgksM8OLiK +I7fj1LDCjrGaxHNjJ9BdjtpTOtwUP4jQoNKQJCpIuISYtJC7kBvItv3hvKc8z0LiQPy v29A== 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=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=LZxv/fjnbPf6KZ0JZ1AqKKi4lUEd1VzFo1FvdKHkG/wiNYJhSzfQeHH8xw3mTb5WYi 8ik0/fiWvd7aa3ttFDq0gkORjiTvWKtUsZR91/0z2OHvSAVt6xsxTjGpXxRMUuQoSefA TMQuP452bHXvlz+12dgAB7sZR0bEqmGyZNYjT8qAGg+6xgoIvqxkcnBcN9PwqHkoOevl Rdvh6NOiO7rrF4g9xhSWsrg3phQ9aAA9zOFPNGMRhphcfeCpy2a64PaUK1pEY8xH85zi 39b4gzuhUJwTXsnbUdyZSxsVJHn0pwzwr4H0E2pjD1oomiragiHCq7INBiZqQMgj0f+L thRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="bG1t/h0G"; 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 v62sor1957614pgd.23.2018.12.06.10.40.52 for (Google Transport Security); Thu, 06 Dec 2018 10:40:52 -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="bG1t/h0G"; 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=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=bG1t/h0G7HsmA8R+Dyhl/GxN0xwqpb0yRUvCY5ZAei4St/imeZmfW5xzHWeExs79G7 3ipntKMO3eRjL4zxGs7HpMj+sgWx8f7Gkhdo19zA8gGWXe9Xe+RQ9hP5SVTQLc8v6R1R 2eiOfvElsrx4gWkx12UCqMOmn3x3x3c1FdSh0sJm+U9096poTqhv72EonZtd1mNXGjBc 7Xawu+wvgf48R9y35/7UxQRHCqNgJbERrTZJrK5N+bL5DJP0YxfYek6wFkK+PV1wVxjf 2Zc2+79sZCqXcDhJGRPyZCa08FJ3rUFPZE1tU+sKxD+Pzfaek2tNq5FLPuk6ZjWdENPM dq3w== X-Google-Smtp-Source: AFSGD/WLGphCOCPH36gfYZkaZrYNW1GtPiXDD9WUqhjHZb9vQUpQfm9+hBvkksnAYbZQwgNgM6d5hw== X-Received: by 2002:a65:6491:: with SMTP id e17mr24801379pgv.418.1544121651571; Thu, 06 Dec 2018 10:40:51 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id y6sm1602250pfd.104.2018.12.06.10.40.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:40:50 -0800 (PST) Date: Fri, 7 Dec 2018 00:14:38 +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 v3 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181206184438.GA31370@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.