From patchwork Mon Dec 17 20:19:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734239 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 B6338924 for ; Mon, 17 Dec 2018 20:15:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A70682A2DB for ; Mon, 17 Dec 2018 20:15:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AD262A2E5; Mon, 17 Dec 2018 20:15:55 +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 6C4B62A2DB for ; Mon, 17 Dec 2018 20:15:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F64C8E004C; Mon, 17 Dec 2018 15:15:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7A5598E0033; Mon, 17 Dec 2018 15:15: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 694328E004C; Mon, 17 Dec 2018 15:15: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 2364A8E0033 for ; Mon, 17 Dec 2018 15:15:53 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id l9so9957524plt.7 for ; Mon, 17 Dec 2018 12:15: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=3vyqNF2AY3a98If6IXFQYuTsTHWXYSwI0xNLA0HcJhQ=; b=dKObaHrQkj4caVgyjB4YqNzqLM8W/SVg9rCG7nhjfZX0x5VEohi88akzIToRB5rlZO bxZxKHZ4WBYUkV1CSJV7DS3u1fsZqcY5p+JQCa0F1ItIhjMEQVk/09crwGvzpvHKnOe2 Ra474uYxb8NTzByCe1qfLflz1MKqXUSGJrd85NIqJANZvUGxx8KhMw426cTZ9uvJx7XP SiWobp3ipI/R/4pcK42VkoSPX8DvQfGPN1RUblm052doYVF97Bb7NMfAge/jBgKwCIn0 JtwA/UZCH/hVsQoKm3iINnlVKie2N8fIXuuG5D18mjp8lh83LTYUGqGYs53RvoiBXLkB kmRQ== X-Gm-Message-State: AA+aEWZmvV4QOCt09D4zhxnb9RYhgH6IOaBsPANkzG3gb/fQn1ELtfQj pnnreZ/3aLiTyNeTEp8vd8SVNPI3AeCpUjJiRt/9hEPREcFpaHiCDfEwbezvmPklfAMsZCk4yeu RAUdPuGUpNFteB9gMlqAZ8iwF3w0ZbwgmswUH1pdyuItp/paFtm7nsEJ6JJz5lZIcx8lwutimfl o21y3Nm/qqYWJxa1SF+XJ/new9QEbcJDkoj40U4h647lLMToq4U8nKqDSQNam7A/eqUwTGCJFBU +moo4V+z2LZI9cw9DM9j1FeMyX0wmuMjG0uielKuIhh8YOo+gouU9PlPEaath3j1Xj41eFGxTfd TSTCHWUOuyJrdpe/xzN7AgOkBdoCvUk2i0tF0rOQkd9UZrcf0LJpm43TVM+AYRIW15JflPEIPM7 N X-Received: by 2002:a63:4611:: with SMTP id t17mr13195014pga.119.1545077752701; Mon, 17 Dec 2018 12:15:52 -0800 (PST) X-Received: by 2002:a63:4611:: with SMTP id t17mr13194966pga.119.1545077751909; Mon, 17 Dec 2018 12:15:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545077751; cv=none; d=google.com; s=arc-20160816; b=q7OD/7Vx/BYSe0mhBCx2NuQ015Cnd9P8QU/an6SiWsJNlJwFzpPhKhKJJIJLbZSZO7 pGxLcbI/CyhTC7EfF3NUQtYXX27yTyIDpph2m9ygH4ceYatEuD7FP3UsWzZtacwD3MDO 1ZfH0Ht58MW716jI4JUrCfG9RKT2uvNeFx6DNqD2tnMPqLR2lNPIXT4Ba/94AjXjqcOb 8WE6rFcuh7sMrqDgVxEHj7/2QI7wNppRPsuIi7q2vLkjGaU0K1kC25Nf6a7Pag6uyguo oh556FD8hbGLJmaaiocsMz9n2CNVf0+w0spgo1XG5+6WABzKlu3r7uDWwRtfmnPrCl/L g8yQ== 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=3vyqNF2AY3a98If6IXFQYuTsTHWXYSwI0xNLA0HcJhQ=; b=D8w9qSnio8iEl3BNwoowgw2/ZWktsVU+1HuEsZpp/hm92PuVGVqzOx9qBU0mgwKzml C6xc9XI3m6Kuqmt7uoRORVWtoIn4M2Efd1UVks34IlnIwDlOHr5tKiSX69BYMY2VJT2h urPCOdnMvHQztZJcZF5w6eR/wTjzgU+vu3WB+NpXe/MnuoTt3T2/8GfkV8RmIa0M5jEE VESBk53may/eOcn/ty61anqieIRMZPCdHXF040rbQMxCZWB90qCYgVe6mCO0d8/u8wYN Szeaftl0L0NY8km9Nh1Mrl6z65WnCRNJ1gUevrcPnGjZI/gDMQLO//44h84+xIJGJg50 ldew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fGyPRsWD; 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 q2sor20301506plh.10.2018.12.17.12.15.51 for (Google Transport Security); Mon, 17 Dec 2018 12:15:51 -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=fGyPRsWD; 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=3vyqNF2AY3a98If6IXFQYuTsTHWXYSwI0xNLA0HcJhQ=; b=fGyPRsWDJn6Kj0Fg0NK2CHb8lm2wpyJMPu69HAivJuYK13NTR/Fm7RG4BGWJRgANwN gqRaCCrlzg1HzxTnTO+mVE35R6zDT9HfArCP2PgcSIIpHCoVIQXu08QiSoaPOq4Kr/1H S4zhEkJ18wFGfdMipkVsQB9Q0iqB+paWWQ3FAQqCuZF4g9XpwJqNutc5OkaNi/21rzn7 Z9h7IMPC7m2mUXOUlD5FxSEBkCRbYJfkPWwLwC7KVn+bOEBPWF47xpQVjstuw1u3EbnK 4lUBPSqwiu4dYr91tYfWcSXSsKiowwIsgen2M8nfGYTCk8AN+KF9diFAXrSa0zOu7MON BkEw== X-Google-Smtp-Source: AFSGD/UwgNW1q7B1Tl/WOz2n048Sng10rkAssfluJ7vJAib6KbxfmhOWdEj5Pb0Em8FBTBItR70xVw== X-Received: by 2002:a17:902:bd86:: with SMTP id q6mr13486898pls.16.1545077751326; Mon, 17 Dec 2018 12:15:51 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id b68sm21569889pfg.160.2018.12.17.12.15.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:15:50 -0800 (PST) Date: Tue, 18 Dec 2018 01:49:42 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, kirill.shutemov@linux.intel.com, vbabka@suse.cz, riel@surriel.com, sfr@canb.auug.org.au, rppt@linux.vnet.ibm.com, peterz@infradead.org, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com, stefanr@s5r6.in-berlin.de, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie, oleksandr_andrushchenko@epam.com, joro@8bytes.org, pawel@osciak.com, kyungmin.park@samsung.com, mchehab@kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, xen-devel@lists.xen.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org Subject: [PATCH v4 0/9] Use vm_insert_range Message-ID: <20181217201942.GA31335@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 Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop. As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers. vm_insert_range is the new API which will be used to map a range of kernel memory/pages to user vma. All the applicable places are converted to use new vm_insert_range in this patch series. v1 -> v2: Address review comment on mm/memory.c. Add EXPORT_SYMBOL for vm_insert_range and corrected the documentation part for this API. In drivers/gpu/drm/xen/xen_drm_front_gem.c, replace err with ret as suggested. In drivers/iommu/dma-iommu.c, handle the scenario of partial mmap() of large buffer by passing *pages + vma->vm_pgoff* to vm_insert_range(). v2 -> v3: Declaration of vm_insert_range() moved to include/linux/mm.h v3 -> v4: Address review comments. In mm/memory.c. Added error check. In arch/arm/mm/dma-mapping.c, remove part of error check as the similar is checked inside vm_insert_range. In rockchip/rockchip_drm_gem.c, vma->vm_pgoff is respected as this might be passed as non zero value considering partial mapping of large buffer. In iommu/dma-iommu.c, count is modifed as (count - vma->vm_pgoff) to handle partial mapping scenario in v2. Souptick Joarder (9): mm: Introduce new vm_insert_range API arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range drivers/firewire/core-iso.c: Convert to use vm_insert_range drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range iommu/dma-iommu.c: Convert to use vm_insert_range videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range xen/gntdev.c: Convert to use vm_insert_range xen/privcmd-buf.c: Convert to use vm_insert_range arch/arm/mm/dma-mapping.c | 21 ++++-------- drivers/firewire/core-iso.c | 15 ++------- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 19 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 20 ++++------- drivers/iommu/dma-iommu.c | 13 ++----- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 23 ++++--------- drivers/xen/gntdev.c | 11 +++--- drivers/xen/privcmd-buf.c | 8 ++--- include/linux/mm.h | 2 ++ mm/memory.c | 41 +++++++++++++++++++++++ mm/nommu.c | 7 ++++ 11 files changed, 83 insertions(+), 97 deletions(-)