From patchwork Sun Dec 2 06:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707833 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 9C04413AD for ; Sun, 2 Dec 2018 06:13:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72BB02B11D for ; Sun, 2 Dec 2018 06:13:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 602712B12A; Sun, 2 Dec 2018 06:13:29 +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 E29162B11D for ; Sun, 2 Dec 2018 06:13:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07C9C6B61F3; Sun, 2 Dec 2018 01:13:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 02AD26B61F6; Sun, 2 Dec 2018 01:13:27 -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 E841D6B61F7; Sun, 2 Dec 2018 01:13:27 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id A29AE6B61F3 for ; Sun, 2 Dec 2018 01:13:27 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id ay11so7490900plb.20 for ; Sat, 01 Dec 2018 22:13:27 -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=QkWGefk1uOV7uhsAtF573lEHHJSsrTRZEoJ/EEqbupA=; b=F93HnBSccyPJxgJLzc9s2lNcLkwEnBwDFMDaSg/uzyPfu3rQd/2T/L5ivuvFJFD5Bx yLNmSY0yt3mR+Ktt2fdQn3w84ZSyfyjeROmCNnhoXcjwHsDMgQECEINig7mc7LalIhd1 FB7m/i+IP6OFp3FEjgehWZyaZK12/0dUf4zvD7Q6MKCD6SAzBM87pkfO5S4Q+WIEk4aN tYR55BCiFSD8EHvca14T8EzZcb27DqZnkJUHuNZ7UGsobDvNscDdJlDpFDJxOo+6scs6 eyG5zWU/pOVcUnjYdP33DkZJRTkwXLAf+CmWoFaSJFDChZFH2ru69fBjYEjgIuGfHpVo raUA== X-Gm-Message-State: AA+aEWbVTm+W9Qm5UCIBmtzYVwxw0IAUKaVxlLt+EPLTeJswQ2eX/w+M JgMwzs4fdaVW+hJhvOkdC8fZ3y5oboEm2OldE81wS0kVX52XE4KNDcNABXA6V7F6wbDMXMrXmGs Ug/8InpGCP4ZP13Ej6PsbNA8GP7rcGo+SfJNqI2QJ10jBGtqRRgF3G33IOaoFhrFihk0yoJ3I7z 1L3pzL66GXS9AMIbXIbuwCqF7aKukPU7CLgx5d0vG1RePVneV6sy0DVo8cuaIeekF9nTdMFsqqO 2vlFus3xntJZDPMQpeXPtEgbfjbOda5ANat3xbuSzFijkg5BAwduY41ACLcvV/V2s6BgbyVtkr3 uLDOmRdWNOrqeBiPMzgJYq5V+4dVXblCVboE3gdXwVWbPyBui1D5mSacbF8rrFxgV+MdxAh5WiG b X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr11695882plb.182.1543731207243; Sat, 01 Dec 2018 22:13:27 -0800 (PST) X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr11695844plb.182.1543731205509; Sat, 01 Dec 2018 22:13:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731205; cv=none; d=google.com; s=arc-20160816; b=ojgH5L3frA+72UjMnN6Sp/Q5VRdEInLI5r3uggyKazOw3CjkCaS25a8aeOSpsUY99P yYI+32uFAksarX4O6z9+MsUQ0n/hdeXn9zeNIWmcTZUD/AwUZ2xsUr283TDbXW8hu/rs eey+5fGkS0ZjQGxiOMH9AMdqY/VJG6mvVym193IZfUJJ6ZOXMtqdBYnTKXAHHxA8EDCA ofhWzPGS/vJwy21hX5l5u4MXt8gqd0KjhnqZdmkOv8+ph3RrV5r1lEX1evl4tl5uQ98r X5j4SlkeE6dQHCbQWsA7O0creAcddJ6QeHAHgLNb7cjjjww8hFxuS0BrSB6W76y9R/jv AKCw== 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=QkWGefk1uOV7uhsAtF573lEHHJSsrTRZEoJ/EEqbupA=; b=ePXkVbJpU0sbrr/xXIcR+QRTg3VFHWfgj1JMS8yDgFvMsJYaJUHCo1duCSNl/Evwsh WzYP+xTcPSurFzj0KDqE4vRa8UMvhIOPlof+5FsLuYVSFSzfEDJy93DFnE7DSWk4Y2cE zCg3UPd45BH/+GSvd/zuI6/RF4BrShB+lVN5gi/kmFi+LAm/iYZJ30/DTNKPSD1MmP4e L8hhCnWNMJQHZUEfM0kuTTk76nmHBSKiFiAiYgWT0QxmXJyVBqFWkyFt66jjb6i7jpBR jHxECCZf2i8M8Z5ax6fcny2uFuaEwEVlHLfAGUXKwOfcI2viENlGUGfDaP+NumcIqTRI Sa4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="M/tndmL+"; 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 p2sor12651339pgn.83.2018.12.01.22.13.25 for (Google Transport Security); Sat, 01 Dec 2018 22:13:25 -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="M/tndmL+"; 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=QkWGefk1uOV7uhsAtF573lEHHJSsrTRZEoJ/EEqbupA=; b=M/tndmL+7unpD7Cz+MMnYUMmmLKKNQl2BcHQL30JGC2EvipOkXmc7nP92Ecrfl8h+j nPudgrN4aT+LEP6HoeYYSZr/o7m3KVuiIv8x7vDJqnzHd9shZNkfBUeDVPPBncdU8F/p oTA9DYBsya674xroQ9+qG49yr/zZ/k5vxL/QJUwE7Bg0XVW53OCRmpTLPny662uFmuic 8B4+FQF4OlxnAVuwkhb96Sm25HTS1UsMqufynVfnoz24ZZvhF/ROhv5TxeaNYetXD+sF zK/2UojyJVWVHGae0s8Qclnm/vtcbyXp2swTYWdf9EdnUZCyyxpn44GxcU7K3iQD6Uwl 6paw== X-Google-Smtp-Source: AFSGD/VadVkIzzhs3ZrvwCPB7PLdPaDENychA8ssT0abv5PurP9XiiGYd+5YwEv4HTNWB3Yc/RO8mQ== X-Received: by 2002:a62:b9a:: with SMTP id 26mr11586637pfl.196.1543731204982; Sat, 01 Dec 2018 22:13:24 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id d80sm33964454pfm.146.2018.12.01.22.13.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:13:23 -0800 (PST) Date: Sun, 2 Dec 2018 11:47:07 +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 v2 0/9] Use vm_insert_range Message-ID: <20181202061707.GA3070@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(). 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 | 20 ++---------- 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_types.h | 3 ++ mm/memory.c | 38 +++++++++++++++++++++++ mm/nommu.c | 7 +++++ 11 files changed, 81 insertions(+), 98 deletions(-)