From patchwork Sun Dec 2 06:26:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707869 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 582E713AD for ; Sun, 2 Dec 2018 06:23:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480982AE91 for ; Sun, 2 Dec 2018 06:23:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF232B4FA; Sun, 2 Dec 2018 06:23:12 +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 ADF852B4F9 for ; Sun, 2 Dec 2018 06:23:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD5646B6200; Sun, 2 Dec 2018 01:23:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A83836B6201; Sun, 2 Dec 2018 01:23:09 -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 99ADA6B6202; Sun, 2 Dec 2018 01:23:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 578246B6200 for ; Sun, 2 Dec 2018 01:23:09 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id f69so8344946pff.5 for ; Sat, 01 Dec 2018 22:23:09 -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=lqCezG0BHCBZ6xOsfX6h53FlagMpfJR0PQM/KC5oLA/lSP9aa9Au9PR/p5OvYhmfEC rRd5LZcuHsMoxYgJEvs4D6AKcn6VnBUsQ2ybmpRkdFCvJgchERytUVQyEhnaEK8YBir1 NlRwRR9yFoCfK5EPiDVY9Pp416TSai1vrz3IKad2h7hdQAOmDe1tHF2sG3eZOSykLxAH vrac4PjiiG+UfNzu8sVrKW2Xc3hwSDnk+UJag0eE5cbzqxdhkJ4KA+rqrF4CmLXJbvJ1 PhukC+xwR7e9/JWhil2Dpb8kOlHbp9eSE41N9NdXonJTK76cXN47CY9dzByeuU7AGkXB 5D7w== X-Gm-Message-State: AA+aEWZdYk7bI6Y02oe8iy7vm/fsAEd9klWTjD4BVrS2pP1AZqls2KRm znn8QhimPPLwdjKLyb3sdggeUEmHsL3H5zBMvU4QeluPhSqoA4ZuzENqKMOEeBbbH3tL70OcnVV xQvQX7oEtJz0//57PJcQAuj0II5HXTiOjFwqTuDwq0IWzFsQvE0P5+Yy75Hu67t/h0i8Tl9dUbM LsHVRhbWzOi1sjh1NqGVDqiCv5ChaBhWHwfos3rNr+NtsLA/nMv4IdE1sSmzgefriWlukb3p0NE JX4n7kigs/m84UHaIwkBwaez/WPvLCutxgI4xWctBOl7iXmAJc3NTJAyVBqDF2rpY2y583If5Lo E8slXFtJprkBfupG0yIpVtvIomiAutrPmW8o/DSnujtmZwKJmSbMeYjBIa7vSFUL5qmLY80EA4P 9 X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr11361567plp.36.1543731789042; Sat, 01 Dec 2018 22:23:09 -0800 (PST) X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr11361552plp.36.1543731788436; Sat, 01 Dec 2018 22:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731788; cv=none; d=google.com; s=arc-20160816; b=E5+mBspeWZhqEAq7B3az+HtDwqeArDo4ZhQ+ZVXGYXnlDRyAu9OVKp457ThQHUqAt2 vTh7KntUXTPzGk6G2I11OD+1Ngn4/OpABrTSUcGhRCXXMDtYgf7MB2wrWd1n2RULIDYK iRBOEAYFCKnEI9ms1do0EEyuSdTFstDVBLjkkpOdvyOJiU+yjq3lfUdfSGdSXutO48J4 sC7PkUYES8aFJlcORZCHrYQ+obeVIIEWcOh0+vm9VQnAvA8DEggG4j/O2EQ/Dlk6rzx+ 3paludYaUQFaPEQUqQCoe7Aiz5dEMXMW2F7pPJVv0d0cSO9zacB4OuiyqqDK9BaR7U9P eBRw== 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=hpfqJGxdsJfCvOEkiflv+6pfaftIpLnF4bQpLfRl+WQUqBZYOnZS7E9Ua4WGTm0VZD 6NLkFV9vghsdefarMVWGshGrbXFEYhov9m1j5B+Xt18Xkd5vJuVaBHINVaGbASgOjNl6 0kRLnn2GC07Epdu2lQr0A7BMFuXCv9UvywSOtpnvWpykXDjeATi66b8EFp35RxGUo9EA kecE76GPdZttmzYi8DQeGsrrFE9VtMLytA+RtALkmhyNvInus5DPmaIxGKql1OJjeRcg RHgS59eQoQcEwIkTHwLymqC4NwoWQzpcGY0FWDnUIKECC/EKd5wf5mB/DQUHeicPqfEz 4+0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hPiK5Zwo; 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 c128sor14089835pfg.37.2018.12.01.22.23.08 for (Google Transport Security); Sat, 01 Dec 2018 22:23:08 -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=hPiK5Zwo; 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=hPiK5ZwoLAoXcrDlPOaaw510DQZbubdxWxzvpQbUMc9IouraIxDN/hT4ozgrDVtvcy fDm7cVPxj+FgIrWQL0TM58NxHbX+Y6FneUIc8DmkmH4y5jOCv/z1ConA6wJZ8D5P8xY5 kpAWzRwXvWRCFIvMMY0RaGewZcbCCvcvHkY/QWYZmRJ6ump9I4s9surJR/mZClKxlW8Q A9bDo9qufPb5j7rpKRBlv9x6G2qY8EVtHjqlYbuJPCtzJT/ixeGVVTClxqIS60vRFeLK v9+DhMQYGj6xoCTmD7prS7Lwsnuh3GX0gmpoNVskL+LyDjAfpH4pb5jr3biQuJyAQ4Z+ kxow== X-Google-Smtp-Source: AFSGD/UVytr1ebhaz8huA/7jJoF2k67t/aK5DcMLAnNhxvR8OqiWPdb4h2JlZP3fcvU+4L9b6rRnvg== X-Received: by 2002:a62:d0c1:: with SMTP id p184mr11350123pfg.245.1543731787667; Sat, 01 Dec 2018 22:23:07 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id n68sm15355295pfb.62.2018.12.01.22.23.06 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:23:06 -0800 (PST) Date: Sun, 2 Dec 2018 11:56:52 +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 v2 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181202062651.GA3225@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 --- 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.