From patchwork Thu Nov 15 15:50: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: 10684667 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 055AE109C for ; Thu, 15 Nov 2018 15:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E43682C330 for ; Thu, 15 Nov 2018 15:47:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4DCC2C955; Thu, 15 Nov 2018 15:47:06 +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 5EA6A2C330 for ; Thu, 15 Nov 2018 15:47:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F6926B049E; Thu, 15 Nov 2018 10:47:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A5C66B049F; Thu, 15 Nov 2018 10:47:05 -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 748A26B04A0; Thu, 15 Nov 2018 10:47:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 2C4B66B049E for ; Thu, 15 Nov 2018 10:47:05 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id g21-v6so16185344pfg.18 for ; Thu, 15 Nov 2018 07:47:05 -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=Y4j6wPLX63MzLmcWwklKXfRUptmuKvg6BDhxbcvJLX8=; b=QPDaeQlTxm99pn1COTIfcPTgdCqE5X49zyHdSt9KJRinXZ94tktquElmch2nmrfWI6 tJai9tA3NBB9wO71Qif+kPrWV5bH1+T7XOt4QPBCT3PlXDViuGlWZU2Z6ieX1Bn0lLmJ Nh751V4yTpzIAk1Ouzd4oDjx/dPNZB8QpEso3sc4XE7ONfOzWc1pTap7zrzqVDeLd1gK wUnUsuSFl6aSA6verp3OVAMuR3A0cfflZGR/2FDFRseSaDWts/VpZ+chMHul32wqvxg7 N6w05fMBlc1wIzzIaxHn2RHJzh1Iu5Rivw5HkVYJ9WtgieC6WlNgaaKX2/cbzr8i4/Ym qMBQ== X-Gm-Message-State: AGRZ1gKSH0O+ab5JdXvs9MFgRbAijKT4YBPyo80MYmME3e70b5h9RZPr SKJY5amZmxPGFojYc0AWxQ9Dp34UzGYvoZ1NxEWP6OK8iw7Z/XXKEOsUO28WYWFvWN+07vFOKX3 b0EiP5vrLKTsTmIWviXnKY33113hpttnwWOD1FAdDxNZIpn7+HcjKpHv8Hpt3uYLEJn/sSQBLkQ s639eAHJPjpkeUzWPQ0STEcU9PBrIMNv1ifY6FQaH9wpqqXXDGKICFu5XQeKQE9A43jpK3KrHHG ZukKVogP10vB+a622/CVngwh/AhiZodfbL9tl22ek8qmoY0GWcaDLDi0e7vUA2hVq9WM1LhCHun nuGzIfNeE/fl/8YwUqTj3evjlG2VXOJ82oOrMHb53wYoWx3+a0Z+DimcxyFII6R2jYY2P3JmtK5 q X-Received: by 2002:a62:7d10:: with SMTP id y16-v6mr6860755pfc.245.1542296824846; Thu, 15 Nov 2018 07:47:04 -0800 (PST) X-Received: by 2002:a62:7d10:: with SMTP id y16-v6mr6860685pfc.245.1542296823790; Thu, 15 Nov 2018 07:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296823; cv=none; d=google.com; s=arc-20160816; b=gGhR1RcZPgoqmQwyHxwIYO7itrO91Lg9tN4GV/khRQ7n0YO1H1TvLtgvCWa8pt9mXu 1rsdrC1eRsbcylWo7csvzHAQprJQy0GGqPKejIBLjJBJE28c72SPYyExkYWw+sStrRUt Hddmo/W3exhbi6bhNzIsqbQxbCVN2qMhUZqouNX21FSIkulzmq3wcRPDAZ4Nh+8wFGZ5 gnvwc2Vb6RZJctFo/EawfpNwXz+hy4c3UWGYA/0r+4z1abYchoWOoFh99ffqHRZwt4tV mF8YrV8ust7cf31YWgBwCrHvg5a3HA5Wvb70VDsmq1glZvzulcUmS9LPc5Askp3hQ82N oeJA== 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=Y4j6wPLX63MzLmcWwklKXfRUptmuKvg6BDhxbcvJLX8=; b=QAjG24XAowSK9C9W2dnr+NA0SBZn5OTkpaSl69K4dDZBs0KB0BeZ1mav414OInHiHQ fTRYQb2L4Mk7o4AzIRK/+CqpA6F7uEm+hr5jhO9isdV2/LfFZ33G3Of+YqhrQT3qR9Kd +R+P92VqbOZ1mstuwAmSgyedWK92kX4KD0Lwas+nyjUYWq8pe+VDjj//H1mCzXGodwSp ySul75/EYTVn1lvcgcjkReGF09ADCLUk+jPPxRxaj6rrM5BYXdJBO6y5AN/KSKDRNwbc I3W7b+WgxXD+OFSHBjZkk7Aiw52wQ0IW83ucWov+3llfcVCCU/mBywqmO4UjBxb5DEWG LCXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EYIpEo6I; 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 i5sor16122465pgq.34.2018.11.15.07.47.03 for (Google Transport Security); Thu, 15 Nov 2018 07:47:03 -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=EYIpEo6I; 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=Y4j6wPLX63MzLmcWwklKXfRUptmuKvg6BDhxbcvJLX8=; b=EYIpEo6I3fyTu/nA00GV24mLYL1fuyuGTfdcuVne5cPVJTlBojkjhL2OR9kMr1l6cn Scq7Xxv5VO8kmlGpTZK8sToz3x2SA8R2VUHT14wnAGRw97Fvv5Vqye1EyoXfC4hFsSRv CJPVbdMq6d7Zcx34sbWJLXEiOab4y8TidiIMUeAwXtXDI+n1ulichB4QJqC/gUokWoln hH6K/9J9Doub4q0HmhCejsxJoGlHkavlcqgMGD6pG06VxU/WW/pYmLIt6ns2RxPRzngf WULQgfNQRcnx+Sazxjc7zDpqv+SjhYgzIv6Rw51NzfPr07yFExwKQWZCiZybCes1Rk/2 69GQ== X-Google-Smtp-Source: AJdET5fKxAlomurtsT3Waf4QItnpyQmbkiTazNR0OLF+vbiHaETb9N5BF1yWp28J2QIaArlvH2Jy1Q== X-Received: by 2002:a63:fe0a:: with SMTP id p10mr6206480pgh.265.1542296822885; Thu, 15 Nov 2018 07:47:02 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id j187-v6sm31083356pfc.43.2018.11.15.07.47.01 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:47:01 -0800 (PST) Date: Thu, 15 Nov 2018 21:20: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 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181115155037.GA28004@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.