From patchwork Mon Dec 17 20:21:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734247 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 F1F46924 for ; Mon, 17 Dec 2018 20:17:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE3B72A2DB for ; Mon, 17 Dec 2018 20:17:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD32F2A2E5; Mon, 17 Dec 2018 20:17:32 +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 1D92A2A2DB for ; Mon, 17 Dec 2018 20:17:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FD1B8E004D; Mon, 17 Dec 2018 15:17:31 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3AB9A8E0033; Mon, 17 Dec 2018 15:17:31 -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 29B0F8E004D; Mon, 17 Dec 2018 15:17:31 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id DDC328E0033 for ; Mon, 17 Dec 2018 15:17:30 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id p4so11538503pgj.21 for ; Mon, 17 Dec 2018 12:17:30 -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=LP5lsofdni2cSLjgAraOzOMBqzsN96J57RYIndiS9eY=; b=A8XB96OcKUwJc8dooFOdUCdlRtFfC31Xo8RaB7z8bosE440TXOd6zQVtdpnoEirNoX W+Wa0hlhJT5flvrsqbyC6c+ug3/GhKgHWy4jlk6ilcuS86vVmVvC/oVDjwo8BdIwqtso enH/z2/e2aoH5qNHOoUh5ntP+XkG61Xw8LSBBnG01BQiuvcewTJn0L6umbU1r+mkDRIX tEFx0/K7F1oIBYdbXipt6o/ZPOqJteM/na9+IO19bqaCrwW2g2u3W1EdQG26M+53suZA /vDc1cCHD2oY2e5lmkjVtw++vO0tTGhD+PhYye7xnOTXivlKNwQs/z56jZSf1cOe8lJ7 WUug== X-Gm-Message-State: AA+aEWZWcjL4N6gjRlyOF4t++R5btB91JNP6e9i4NSFPbw8DOmBHQqOf SdsBpMhe/ZLwVX3nftlOIi6PSoV+THVO+PqbXoJU1+PrYCDizazFpSSWPA6506uxF7t8+Xd8fE3 3rpnz11dAFXWE5LcR7Ilkb1B2vtFUyCyPNPsknJAlzrHruwnLDzcjb6qcYg12jH9MJdtTvfqAiJ Ix04+qI4mGGrknKR8Oc3e2OTx8tJA1XU5fUh6Q8pL+bTwgtf2J3eaTnT5oiD8wF9mdB4r7dx+n7 zvCw6yq796Ak6NNvayfEUhnd3hAveKRU6br6SKTldkJjHbyBinV81z5U7QjDelFShFO9pY2dyGm zUYbHNEVQvbKCzq/vGCec50LSYWdX0BtTKBqx9gWmM6mMtkfBSHCDRbjOX9HEWwyDD2ehN7AkJ4 k X-Received: by 2002:a17:902:8641:: with SMTP id y1mr13820246plt.159.1545077850480; Mon, 17 Dec 2018 12:17:30 -0800 (PST) X-Received: by 2002:a17:902:8641:: with SMTP id y1mr13820217plt.159.1545077849722; Mon, 17 Dec 2018 12:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545077849; cv=none; d=google.com; s=arc-20160816; b=crI3OIOTUHD+wbio1tnBL7XgmxZQQobwnKSmxfeRlNd7Q6uxqpU3ee1DBrsxZtrJlO /IVdsiO4pgvR/WIESkB5/ceXBVBVSlmfiS1eqCKTH12nkL3P5yWSuyBElfck1gLfrPSV 9uta8cBlFGEqhh/em+IXn0IB2WvGePzABcG0ykuisOnmCo/DpAMsGC+fBn7iNbIiZ7Sm dWwfvZiDLG6mUmYQQ8oUuNJq2lt/Lbh0o/GuedDioXRh4I4zK4/ckUqVfSz+CmXgXyHR VM5JnzItfFOX2f+c72WoBjvDPUq9Z5hCZlVKPbFYczCjNjr7uLcqrXRVwEnZqMgYpFmZ McUw== 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=LP5lsofdni2cSLjgAraOzOMBqzsN96J57RYIndiS9eY=; b=c94FVvRjoU+0qRylyFJEBNmnTiQkeBuI9yUfBfz1wrET813iLRo/fYAqMPVXbU+mUk 1lCfYl7zlU1lKkAiFJrAow4t/+DqnkJ+xnnhd6M6alb+Gcn8o8BSktVkkZBpHI2B8x4h njsMRol0xa4JBma5nmUT5RfF9NOM1azGcGgF+yF3/wFT8fRUi9co+lB7AtlX225w6MKX 6/NbZXyOceYtDfkwGtRFN9ESwnltlfzuaE1z/kPETUkw4v/+dDwHh/hx6IjJPoDWs8gU Nx2zmDQSIMzIbvWnVpsdqHx9OA3/KtHKW0/0Q0SqRHBdRBlrX46pisBcnN50Y3Eo39k4 HYdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="p/e9LBg0"; 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 n11sor22331768pfk.44.2018.12.17.12.17.29 for (Google Transport Security); Mon, 17 Dec 2018 12:17:29 -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="p/e9LBg0"; 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=LP5lsofdni2cSLjgAraOzOMBqzsN96J57RYIndiS9eY=; b=p/e9LBg09urJWLaio2BVun4A6kGUQCG7HWz9LLsvx7iRIBvbaKonR5S0UKsIOc35I7 SSVLxSCuJqmJlEbu5QtUruzWvMTPabWv1I6cmgAzPKZ+UoKGTtflhdKlyvEmf9RpxgjJ jgZlhJTMJQ8243EIkKtQ6gL1JidxGUbiNWT4LYKMyzoJouaLP3bUfsgcbYxIQkBi+g7L 73YRfXK3iBDh/kpNWD7HgQ1vG55H+CgsVYjWo0In+Jx/SeF7VmnhMlECM2b7QHQ0chbv +xri/+GSpBZqI9ExlEHam5pX5MDN3BwJ1Gb9xJmzHrzKGNoTgpVbEglFsGdjNrLD9aeH t2VQ== X-Google-Smtp-Source: AFSGD/X4Uak/TI8ZYtxtZsFEKfKGnP+/T22Np31XBV/bP6gFwwiKErESpa4F78Q5JQiA2M4ia/MNlw== X-Received: by 2002:a62:33c1:: with SMTP id z184mr13951345pfz.104.1545077849354; Mon, 17 Dec 2018 12:17:29 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id h129sm18659195pfb.110.2018.12.17.12.17.27 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:17:28 -0800 (PST) Date: Tue, 18 Dec 2018 01:51:21 +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 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181217202121.GA4335@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. This API is tested by Heiko for Rockchip drm driver, on rk3188, rk3288, rk3328 and rk3399 with graphics. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Reviewed-by: Mike Rapoport Reviewed-by: Mauro Carvalho Chehab Tested-by: Heiko Stuebner --- include/linux/mm.h | 2 ++ mm/memory.c | 41 +++++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 50 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index fcf9cc9..2bc399f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2506,6 +2506,8 @@ unsigned long change_prot_numa(struct vm_area_struct *vma, int remap_pfn_range(struct vm_area_struct *, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t); int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count); vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/memory.c b/mm/memory.c index 15c417e..d44d4a8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1478,6 +1478,47 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, } /** + * vm_insert_range - insert range of kernel pages into user vma + * @vma: user vma to map to + * @addr: target user address of this page + * @pages: pointer to array of source kernel pages + * @page_count: number of pages need to insert into user vma + * + * This allows drivers to insert range of kernel pages they've allocated + * into a user vma. This is a generic function which drivers can use + * rather than using their own way of mapping range of kernel pages into + * user vma. + * + * If we fail to insert any page into the vma, the function will return + * immediately leaving any previously-inserted pages present. Callers + * from the mmap handler may immediately return the error as their caller + * will destroy the vma, removing any successfully-inserted pages. Other + * callers should make their own arrangements for calling unmap_region(). + * + * Context: Process context. Called by mmap handlers. + * Return: 0 on success and error code otherwise + */ +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + unsigned long uaddr = addr; + int ret = 0, i; + + if (page_count > vma_pages(vma)) + return -ENXIO; + + for (i = 0; i < page_count; i++) { + ret = vm_insert_page(vma, uaddr, pages[i]); + if (ret < 0) + return ret; + uaddr += PAGE_SIZE; + } + + return ret; +} +EXPORT_SYMBOL(vm_insert_range); + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page diff --git a/mm/nommu.c b/mm/nommu.c index 749276b..d6ef5c7 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + return -EINVAL; +} +EXPORT_SYMBOL(vm_insert_range); + /* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty From patchwork Mon Dec 17 20:22:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734255 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 73ACF14DE for ; Mon, 17 Dec 2018 20:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 625172A2DF for ; Mon, 17 Dec 2018 20:18:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 538012A2E8; Mon, 17 Dec 2018 20:18:21 +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 3B9882A2DF for ; Mon, 17 Dec 2018 20:18:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55B9A8E004E; Mon, 17 Dec 2018 15:18:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 50ACE8E0033; Mon, 17 Dec 2018 15:18:19 -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 424858E004E; Mon, 17 Dec 2018 15:18:19 -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 0245D8E0033 for ; Mon, 17 Dec 2018 15:18:19 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id v11so10007178ply.4 for ; Mon, 17 Dec 2018 12:18:18 -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=sUyJE5XZI7PFTFAoMHl2QCf6i1YL7AfLuhA9/P6Ludc=; b=nKHKsMA6sSFluURG9gIqD+xRVHyNRRndGBBbc0hx+klkRUIF2nfEr336OnJp+Wt4uo 784kVn8fB8RD1wlEdzNdskZB8WTMxrZck3p2TD3lRagBsdDxsIckjspvVEfTM9X5gWGt NiJj+2YAgUWXavKwnGR6grlWbYtUkLKPPzTLa9kQKrC8i6/P5sB/c5Nn6tKQdUyEZCel upo0AM26siMeE0Z0OfILv23nOih3hoXulYXw8zHuTA9sudcdS9BZDeViXdAyZ1GtC6UQ fodNpiggiL3vZC4va6TOUO3pmJ5aeTP61FaD18a3v6wR+gWGvLWJha6O4doel4okrKbw zUQw== X-Gm-Message-State: AA+aEWZNewwIsAlbySUGq0WuHYp+0VDK8XG+gy3UQ8+85bxkEroB+Cvj fhA/NrrADnslnTJLS2zl5JRO+ehN4oIfwiVloO2CyvFkxrv3TrfJy4xS3nAN5sMl0YnZ5TU1l9F H773tAmjbdGix+8CsDTYR+Ql97nx3Oq9xKzlLZFxyApL6uPmoGVE0GVpXn/lKXnUlzmTCM5jbdp uYKpQ3sCezPmnaSn7B3Q4aR8CAn7eGOOieKxvXAjQl+rM5tsbZubKx1uBY77iz9u9OQi4dHhwOm jAdzZqf//MgvQcYwK1MM+xpKRu8PFiNuhAdPMSTiyMkdJOg7nfWRTVMXoSBcnpCeBHN/6ZMXd8J NbvHGolc5v+uXE2aIX/yTdcte/fhxVW8N8r1LuCGPWxQpr+CaYQagV+5Yp2f80M+39FoGxaj1Mw r X-Received: by 2002:a63:3602:: with SMTP id d2mr12975737pga.404.1545077898689; Mon, 17 Dec 2018 12:18:18 -0800 (PST) X-Received: by 2002:a63:3602:: with SMTP id d2mr12975700pga.404.1545077898007; Mon, 17 Dec 2018 12:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545077897; cv=none; d=google.com; s=arc-20160816; b=j8uWo9a0Vr8Mmr80eT7M4wQl5M9C3eOHoirOpnqWfpB3U9iUoB/mBN5ajH7BG5kafM 0nID76tP0J0QtyiJbz7kBNxhof4Mb1MlNYWxIwutPqdK+Wyre2WezQF0cctUmWPxMLz3 mx8QM7qloEH0CX/3/RL1UIylyI2put+5/j58Sr6LWNP/j/Amlk9QMXj1zVVvJOLMjBZN GyZ3RYoA3acDq5psRb+njtz5vr0maW/TnV+KEk8MWEqZ7QuljNmI7146tVh427kPwNb8 rwIcgAoEgfjgjXLflpbbadbjhXImMPlLbF6ljSzrqUF3oqBGmtmFMFa+QFQMVmqH95eh pwxw== 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=sUyJE5XZI7PFTFAoMHl2QCf6i1YL7AfLuhA9/P6Ludc=; b=jcj8zUaBfI1ZAWYmnXwsMks6A29iluvf3hhi95w8txcXOtWV77wiAobiUpadedHBxh h4e3ZIJd1fKgSx4Dr46N21siD/NHn0VjWC/wCLQbNbGMMPlo57teiD9AqxCjCbxpMkjO vRs4sQHClP2O6D8OUPaMTnGhNdiGFzFaaYQ0IcXfQ+ZFIgS2cXHLHET/Q8jbhDiMyBgX 5HUNzr9J0bD+Mv+yHZ2sdRcqZAWozzga4XDRDanleTOQNatc73//KewUxmARvKlizG4R LdfjeVvTWNCn8adBmeHrLWIwvYpzZ0KlkcM42C4Kru8lUclyNlCd6PnM2k3t0XP5CImR xkhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oDI8mY+6; 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 7sor20289582pll.40.2018.12.17.12.18.17 for (Google Transport Security); Mon, 17 Dec 2018 12:18:17 -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=oDI8mY+6; 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=sUyJE5XZI7PFTFAoMHl2QCf6i1YL7AfLuhA9/P6Ludc=; b=oDI8mY+6/0wwXEtDv6zcp3R2be1Zb57Xo3+v9BgCECtnF3xZe4e8/tCJOt9WNsnuNx dqVRMZuoCSfpN+GFfo5EpPACd5VV2asAKw/G+JnlkZozp2FqwUiuz2MyMTA/bpiNA8FP /uhScwqU9of7msQcUs0RSLMfAcjhdw226Pxn8s0V8n4CjppbpLxwAuvntwSiFxpLjbA2 pcmRRP643OFxHfwdNeVffdCCBG6XaRBWXxcCjvuidnKsuqLa7j9RmI8ohICniP6TJhDI FERVM7BvY/lViYwRv5CDf8ZBTyVQPoRRuNdXThd00kyj137d+EIDPGbH7zTF1fUS1n7B 6yfw== X-Google-Smtp-Source: AFSGD/XTMTjOndtTsiXcrd9fAIUCns/BphtM6xp91sNWu1YXSRoFffBVluebJhG/DoyPebkudZUydA== X-Received: by 2002:a17:902:a70b:: with SMTP id w11mr13818009plq.84.1545077897631; Mon, 17 Dec 2018 12:18:17 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id m19sm35920803pgn.35.2018.12.17.12.18.16 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:18:16 -0800 (PST) Date: Tue, 18 Dec 2018 01:52:09 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181217202209.GA8859@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 --- arch/arm/mm/dma-mapping.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 661fe48..7cbcde5 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,31 +1582,24 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma void *cpu_addr, dma_addr_t dma_addr, size_t size, unsigned long attrs) { - unsigned long uaddr = vma->vm_start; - unsigned long usize = vma->vm_end - vma->vm_start; + unsigned long page_count = vma_pages(vma); struct page **pages = __iommu_get_pages(cpu_addr, attrs); unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; unsigned long off = vma->vm_pgoff; + int err; if (!pages) return -ENXIO; - if (off >= nr_pages || (usize >> PAGE_SHIFT) > nr_pages - off) + if (off >= nr_pages) return -ENXIO; pages += off; + err = vm_insert_range(vma, vma->vm_start, pages, page_count); + if (err) + pr_err("Remapping memory failed: %d\n", err); - do { - int ret = vm_insert_page(vma, uaddr, *pages++); - if (ret) { - pr_err("Remapping memory failed: %d\n", ret); - return ret; - } - uaddr += PAGE_SIZE; - usize -= PAGE_SIZE; - } while (usize > 0); - - return 0; + return err; } static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, From patchwork Mon Dec 17 20:22:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734259 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 36416924 for ; Mon, 17 Dec 2018 20:18:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24671296A4 for ; Mon, 17 Dec 2018 20:18:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12497296C2; Mon, 17 Dec 2018 20:18:57 +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 9AE4C296A4 for ; Mon, 17 Dec 2018 20:18:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EFBD8E004F; Mon, 17 Dec 2018 15:18:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 99EAE8E0033; Mon, 17 Dec 2018 15:18:55 -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 8B46B8E004F; Mon, 17 Dec 2018 15:18:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 4BC788E0033 for ; Mon, 17 Dec 2018 15:18:55 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id q62so11576038pgq.9 for ; Mon, 17 Dec 2018 12:18:55 -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=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=Ch62F2QY8urwW75lHMlnLvHqu2uDXYW0Yqs+qczWCl/DWkz5wDyjL1gA6gYASfXpZR 9jjYS2AxisW1cBBfL4dDJhjf1Lu9zKKJwTYvcuffpmvR1DqPCK6c1Lt20r5oDZKOXsmH Qb+U14sy6/1W427wMOtWBC0k2nAo/nuMyIizn/dRT0rAvjabRrRL27kD+s3VYcxSeyvs vQGegvcPYCagu227fmHOReEtBBWfZX25m/f3WCVNfMTNQOGxZ1C7nwTKk3Qxk0yBL1qr 8gCfUd3nZw/8EKm44PvRVJksyEJuLPemxwfb9n0XKZPCkh3RupKJ/KBfhwbOelt40Fsd nNqg== X-Gm-Message-State: AA+aEWarlRPXNejFl0QGmlE4nJ7svfIdL79QVAyDq/Ne99tLhbvkVwQN 0fyp2oJcWR6ut7ZixnK6fSAjhsfSQIOVkaGaJVyjHYVdyFapcXWsx1w2mxDl8kyRavO7SPcLieB 5qpO8qEaThnOgJsP8J0Jsz1r7d4i1VKKIiA7vLi81zSYQP2gCi4iICX6SbYRAMCkjpZyZjpfEr4 TTA/g+MnSY7um8X9as4k4MOYpVv6NBbg5SBtF28XNTQqb3fXhxWnxzMgWb9KPRNEggjhsW5EPUV xnWH0ucXwt67gOFpeIr/HstC0EljI8KsJDBPY1S2u0aqJ4dOn4zdQsum9RKLG9mVo4xP8OrKVKZ bSpcCqPDn5cvbQMyx3FmK9TnhVntYFSdkc2i7s2WR2EG5fTHpPsWSv/GlGHa2TuxH6rq6TzKBsq Q X-Received: by 2002:a62:2c4d:: with SMTP id s74mr13905619pfs.6.1545077935000; Mon, 17 Dec 2018 12:18:55 -0800 (PST) X-Received: by 2002:a62:2c4d:: with SMTP id s74mr13905583pfs.6.1545077934348; Mon, 17 Dec 2018 12:18:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545077934; cv=none; d=google.com; s=arc-20160816; b=C9xzISRjHMYpQItMDvNeVjaFAcqC3IpOiYc2Z4KfLQ5dFnI7vKnMpBy3ToDkI2iHls /ujCHBz++/fULZ2h5CNNHljKZfmOyJiR7nQj4x+MpYTESgjjCVc/9fsEbavx34NsRudH FXIqovTPGjv4Pz4VMmnSiebMgJMJNRdqePhtT4SX2Vuo+qOxI+7yZD5azjXFOsTvzaU4 8KIovHeo7z16Q1DfGj44nMBkrPT7P+pXm9rurtZPQTj7qsJ+J+rzlss3Aj5rVmdKedbI pvz4IIdYTn+zJQ5locRBa0Bsc9kHv97r6ril1O+DfTwMA2n/KjOGgdpM9KxI8SkXPmF4 kpJw== 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=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=YAS1fdxmQh8l04i6bB4lOaySAh7IwDYgALcapJTiKywqNUBjhYTim1CjLPIvh7D2kp WHoGfomAb+8PerYjv7OrWgQmOWsV0NpGrwbo2nEpOslc129G2Hp7rTOTULgA8BheYxWs 4IqJxZl8A8+3hVw4++w9kbLggHhW0YlSP2gSDqEUHt/M09OpuWRaCuzaacbSOGV+OhOE gE1noGKlv05WbXbW9vf0rC15zYjXohdwNN/IheGOb5nF6EPjMFD2tobos/V4tVgK+X4h i/RUsf5e9Qykv17kq9yKRaxVUBXAAKt79YVEDfg6FJB+eOCFzK9s/F4hvm60JTy/0rEV qTWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UN3LRotB; 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 m78sor22976973pfi.28.2018.12.17.12.18.54 for (Google Transport Security); Mon, 17 Dec 2018 12:18:54 -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=UN3LRotB; 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=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=UN3LRotBmLU7g4NYrRKgWGuyzje0zXTtKnRBRlwk5Lu8DyWMsl6VlJf+28+6Wu8jUv 3dt9zpCCKdA9JZTazgv5TcRWxgSUlsSdzevpGdqJpv8WVOO3IRZnrSkvKb6ubnohoV8m WBQRSZHxdT7S6ZEvQ/j1SuVSrVP7sby5mirPqSgW8uKaLKcjTIMx1gE8n8BCn7uBbM6E qNvm3sByxZ+GjVVz9M+zYJANQIHyzWVDgrbqWLHcnolk6INBvFGBnZnm5I3oFH71QBCO ra+TEojmKZjUaj3uSfaUG0YtsVnRJmnJwN0YlCBULNR12n8Uynxq3FKnsXpN7gHm1RBp 29tA== X-Google-Smtp-Source: AFSGD/VZpPr1vEyhblYwvkUoYGzeXCeGHGsoaWXD+5TdUu/r2E6BL4B7uDKXBU7K9UAg8FWdanGGog== X-Received: by 2002:a62:8949:: with SMTP id v70mr13708541pfd.85.1545077934004; Mon, 17 Dec 2018 12:18:54 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id f67sm18955733pfc.141.2018.12.17.12.18.52 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:18:53 -0800 (PST) Date: Tue, 18 Dec 2018 01:52:46 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, stefanr@s5r6.in-berlin.de Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net Subject: [PATCH v4 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181217202246.GA10500@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 --- drivers/firewire/core-iso.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index 35e784c..7bf28bb 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -107,19 +107,8 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) { - unsigned long uaddr; - int i, err; - - uaddr = vma->vm_start; - for (i = 0; i < buffer->page_count; i++) { - err = vm_insert_page(vma, uaddr, buffer->pages[i]); - if (err) - return err; - - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, buffer->pages, + buffer->page_count); } void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, From patchwork Mon Dec 17 20:23:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734263 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 4AEE6924 for ; Mon, 17 Dec 2018 20:19:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C4F12989C for ; Mon, 17 Dec 2018 20:19:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3034729F53; Mon, 17 Dec 2018 20:19:45 +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 C89F82989C for ; Mon, 17 Dec 2018 20:19:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D48288E0050; Mon, 17 Dec 2018 15:19:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CF8A18E0033; Mon, 17 Dec 2018 15:19:43 -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 BE9428E0050; Mon, 17 Dec 2018 15:19:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 7E59F8E0033 for ; Mon, 17 Dec 2018 15:19:43 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id s27so11595468pgm.4 for ; Mon, 17 Dec 2018 12:19:43 -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=vHtNG5YY7oqAEcnnEFXV1qkzWXHTgkZmEB/ZXAxtcsE=; b=pV9N214nfBTzvBn0GrnBIi1XSTsIt/u4UicRTrF8XEMjXTS8W5QFcXlzTEIAimKca4 uBtJTFnm9zWkDPkBP3RvrIrS4EN9mLCZgFQ1wj/WrFN6vEyeTNdQVC2tRtdYb7ffdzFd WHQ5UI2fKm3a9uuF+UyyJz4csSCstC3H8FlM0QSVW9QO8jBz+L6D7XgGaRpIgOnPwuTK zDzWHmvdLPwa69EM0y1S1Swd6VvrfeItuwT6r62/keHjfqs39rhi70bh7HXsZ0fYIB8p Tgp0Mo1OO7QIDwlj7sFOnDgORrjyVNx1CDxbnvIFVdlpChtnpouwreojiUkoHrPUAZUQ y0eg== X-Gm-Message-State: AA+aEWYb6jez9yFAwe/sZuPpVtx7uCm1kHTIL+q6OndvgrDRVzcNnzIV xhDFgSJzcBKtRKbJlJ+U3B/jGaThcmzFMxUjfUbUWOR2VqR7JSK1cJsrlrG1ZZbPujrsuzdBWtu xpcK0Avkh8GIaJy6T9rpAfU9vdxZtnRkrbxxtWpn1myZsXizpamdAffBj4D7VxFVDf3rFzp2fUr 6v2Y991ffqweKGomE83L5Ru00wWQCZpLzwzaEVnMMS7o2WQ3xlPfoAfxxqyjJNOYXEbU3O0MvvI XEsuKZ4eJtUCE+VHmknA1p49gyIc3H6LswgW11+EJUyz+N1TvIYKriBe35acCKAGZTMxdVO5sHx Hj6feenJv3suH5qaOU8y3SzAUBJSwtfyokSUy6DnRd6tMgpjdepmMTDSnmsfrT76XVjifGwrJMp A X-Received: by 2002:a63:7306:: with SMTP id o6mr13066306pgc.343.1545077982931; Mon, 17 Dec 2018 12:19:42 -0800 (PST) X-Received: by 2002:a63:7306:: with SMTP id o6mr13066279pgc.343.1545077982328; Mon, 17 Dec 2018 12:19:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545077982; cv=none; d=google.com; s=arc-20160816; b=XJbmhHo1Pup/BfO4vPFRZCUMwrMknqzcucDFYVbYPFsOdRmHnKwNuQugcdKad3wpyk ybAVOVeO7dmImYOU3FS1dgeldsZUY1bCl/pyoTfP1NS8jXj3DpI+RD2MYMv1dTpJVeVB IDbjE1jPNDod1KbYex5DhdP2kjHxZ1KJmGlW+JxhMR4A+hYTznpyEe6LUFnWunkT9Vdb c8w5uD9D7LTh0w7Blq8S7opBsvI2uELPogEiiT3s9TDV9UTIHfMHpzS9F5OeGYTEJUdk fYPOJc4V76l8tte2z8bghKtgyRnER8XreJnWLSi1fnD4P6ENmBvPf3aQXUSNCEQ5/y/X Z36Q== 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=vHtNG5YY7oqAEcnnEFXV1qkzWXHTgkZmEB/ZXAxtcsE=; b=oiwPgNxpOEHLS6KvBP+T0KcXcGz3/8SzZ8XD1cE+0lVLo9fcf2vE80L+vnmcZMIycd DnEBPzyLYhKEsETOYwbXu3a47+CXUrgbm8/OO4NhrCB4bMXmDv9V82Fwj3P1GNl7D2oY t7NqZDqb2VwhAe912/rJE+sHmoSzpJfP4moIu4ktNksfZ1JIMvZzKiqee7ZIJoDAe9nd QChmwIGGnfyN/nYjKbEG5nAUF396kW8XnzPfytI9CWP2MPjWwofxtEiaYnf2uoVbpt+L 9z20ZqYqadZL5Q+9Sju7Z0QHfnQstKK2jIOFvEjbChBzjj5i08CpjZD+OMlgU+lLv+MH 5Dbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HDTJCfgn; 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 f91sor20271522plf.59.2018.12.17.12.19.42 for (Google Transport Security); Mon, 17 Dec 2018 12:19:42 -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=HDTJCfgn; 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=vHtNG5YY7oqAEcnnEFXV1qkzWXHTgkZmEB/ZXAxtcsE=; b=HDTJCfgnh+j0eG6OnfEpzoBfilcO9b+44SSH+rczBsLIYMzVoHJCuW+pyMCFqzu1V/ Zy29YyLtOwX2UDdP/SXCBW97juLvRF2DVYMvTzi4i7gL6TPz9Limk1pxhoJF2ZR2gdCa 7tJqkTGxerJpUQ4Okn3XGjeaWWgwbzll56yffTbkYAxyfBuv/nGBVByby04RrCEOGLBh iw4KiWfDMyasNKW7SRmZWh7oGNwhOdjF9l+eHcRuO4ZmQmXbT2DzCdawrCDVnJ6qPfsO 1gQeUUbdnGeiVu6w6a6Y+0opTR0MRZS8NcET2Nm32kXGicA27G+cCt8iUbI/NAzK56ww TNPA== X-Google-Smtp-Source: AFSGD/VztJFrJiCc5TxrvjdoAMM5foV3+t6D91QTlRMzDwrlUkxArWBo7WpY83vLc2dZ2XXJU04Cxw== X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr14060709plo.50.1545077982019; Mon, 17 Dec 2018 12:19:42 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id u87sm31872783pfi.2.2018.12.17.12.19.40 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:19:41 -0800 (PST) Date: Tue, 18 Dec 2018 01:53:34 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org Subject: [PATCH v4 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181217202334.GA11758@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 Tested-by: Heiko Stuebner Acked-by: Heiko Stuebner --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..8279084 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,11 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, struct vm_area_struct *vma) { struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); - unsigned int i, count = obj->size >> PAGE_SHIFT; unsigned long user_count = vma_pages(vma); - unsigned long uaddr = vma->vm_start; unsigned long offset = vma->vm_pgoff; - unsigned long end = user_count + offset; - int ret; - - if (user_count == 0) - return -ENXIO; - if (end > count) - return -ENXIO; - for (i = offset; i < end; i++) { - ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]); - if (ret) - return ret; - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, rk_obj->pages + offset, + user_count - offset); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj, From patchwork Mon Dec 17 20:24:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734269 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 C1965924 for ; Mon, 17 Dec 2018 20:20:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B27A02989C for ; Mon, 17 Dec 2018 20:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A52672A24F; Mon, 17 Dec 2018 20:20:26 +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 38B872989C for ; Mon, 17 Dec 2018 20:20:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AC548E0051; Mon, 17 Dec 2018 15:20:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 334ED8E0033; Mon, 17 Dec 2018 15:20:25 -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 1D5D28E0051; Mon, 17 Dec 2018 15:20:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id CBCB88E0033 for ; Mon, 17 Dec 2018 15:20:24 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id p15so12857334pfk.7 for ; Mon, 17 Dec 2018 12:20:24 -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=YwqNkUNPLYdK07Ra2/mSQ+jZoA95B8gqjnUO/EioucE=; b=hI+wecKM2hMDv4EVr+P+m6qAcyYMoOOs5RsEAXbLlqUhpVohece5L8YYXKUOrKgGbB 30AV7fQtiQAgH/Pmf2SeFconm/GZMEmRHDAWPiDoGLkB2+YVjN9wg8ltjQCNyIj/DVJo OPjdgOWvZN9qVQO2k8uBK85PqJkUG3NFv5e1YtmaXnodlz1Tzw67qwPxuIoaEOoZrlmI zZ3KRb0mmYdVHBqMpe0WFEXM1AadimPB5oFMMV07c0k2Rs+Uo0NAm2gPEmi55vcweMgi yxtgQQ/AXfdswtE9ImQbGGgLq6AQCM4wlc9Fj+k6ad9chwe5BDs9wFL3tgSoi9DVa4EH J4uQ== X-Gm-Message-State: AA+aEWY/omG/T/9GWsNEn16PqfWurlh7HVTcUkhO6q0xT0WKa3lz8Ahj /wykHma4d7gqn6Re2r2rViy2hb6IueuYQ6KmZ0BQXSVeiNo2+BZjJjBR2riNVrxYErIzT+76FEk 2jviduv1EcvMJlLjZXaDlWimvBRMjvY5h1dUKgH34KudRFIR2vlK8I959v/1ZjyR+0EO4KTKtXe izFn4h2bTg0dCfMiLLwLcfypPdtA52SfH4aVUIWc7c794JaSItg4p6EIfN9Upw1blduGxH665ep ZcooCQissZRLMPcMj56S6SOxhWGIUPtAYibwI+Xj1ZZUFKb0VweIxAALa9gDAYnD6IpM3a9YoTY wp3blZ/Z3tQKrIsiMO+kQPE9HS9eXCUSHvAL6TEPq81eEgltSLyZBvf0drmjkehP1v7BmUPCoqu w X-Received: by 2002:a17:902:28aa:: with SMTP id f39mr14017559plb.297.1545078024469; Mon, 17 Dec 2018 12:20:24 -0800 (PST) X-Received: by 2002:a17:902:28aa:: with SMTP id f39mr14017521plb.297.1545078023651; Mon, 17 Dec 2018 12:20:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078023; cv=none; d=google.com; s=arc-20160816; b=cty73IGkFTfN/pl6OoO2gnu3PwWkn9MlT9TEXA3U+swtl1eDQ1kVzE9XoMqmkRnipO UHN56LXrI+mqxZ3mgXRs3zkO+AubObEHrRk2//A/+FYRlhBK5FGRrXrMsaun//xglMJo XM5db4lN42zbmFzP3M472nFr9I50jKxBc7cp26rWXosrxbqquwHcpRwuOvZeykW1SbFX 0qawqXJYS8I3Qh7Xqn74Vlx09U2bwnf5vqjpr47VnEunfhfNF6AJnoCQj2yj2yvhw3FH gWv0Xw1OGPXZo0JXPWJpL3ruA5z4WMuG+svzjD8i0B+Tte3pMy86Mr+KU+sMWjvHMeT3 e5fg== 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=YwqNkUNPLYdK07Ra2/mSQ+jZoA95B8gqjnUO/EioucE=; b=kLsak9UsbXUBf4EPYNMawJhnIX/uQG4INf8znhscN2Zc6AKLqQiGMafBbQosHJhYGx CFyMtR+FBj7X+RDOh6clNds0jbp9/2a3YVjf1wKy/UkyQMcK0a5/7fiMvTKBdBAdQEn3 B/nLvRxmFmttnIEiJ/wJ0jB0ihW0prrbrAiHxbu/H4xIQTHYovgeDicbvE5g7KPa0VqV /ANNk/RX9cQ0XQAJn7hb5WgHxoaL0S8M0nwU3evk/zvrW838AMlFx8N/VaF5G6DGcrwg QSlNU0x+eTnYUbqUsKtXXPeEpT5GD9032rJptRHe6YfNR7LoTT0yDUDxj4m430Hhe/CP 6MRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fws+fhY7; 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 1sor20810548pls.72.2018.12.17.12.20.23 for (Google Transport Security); Mon, 17 Dec 2018 12:20:23 -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=Fws+fhY7; 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=YwqNkUNPLYdK07Ra2/mSQ+jZoA95B8gqjnUO/EioucE=; b=Fws+fhY7OGBeBQzZIt7AfmMfEWU0cNhX2vqMdb1yNiRZXNX1tRQHb4vYuxPcpPKNJ1 Hb+0nVDcrQsOZM5YJYZg8lWXylPHNMhFUab14v+d1rI1iTEXaGbE72ZNINF4xAYqtmK3 u2xSL5jg5k0XWrMMwKSdNHYiXIl056gtmnrnU1K5z6xmkCg6maIGr61iUzFsdp7m6p5b AhXfHeEceYCaMXLYAJn7+/rBRGa4IegyZWt9JvH1ABBLNl4zbVOYWPDUsGAgsSpwRlQY uB6uGb/aH0cnaw3DCa8lUxnntiluqFAER78NHS2Fl50o3leVq1m7/6gqtSGA2sxohSyS L2xw== X-Google-Smtp-Source: AFSGD/XGXG9KVSKHfEOg6j87CYwUtc/H11tveEpFu3OIi9T52naHMGkf12FyOB+zZiJiH4z/gZspFg== X-Received: by 2002:a17:902:9305:: with SMTP id bc5mr13746784plb.86.1545078023341; Mon, 17 Dec 2018 12:20:23 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id 202sm25834765pfy.87.2018.12.17.12.20.21 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:20:22 -0800 (PST) Date: Tue, 18 Dec 2018 01:54:14 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, oleksandr_andrushchenko@epam.com, airlied@linux.ie Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xen.org Subject: [PATCH v4 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range Message-ID: <20181217202414.GA13431@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 Reviewed-by: Oleksandr Andrushchenko --- drivers/gpu/drm/xen/xen_drm_front_gem.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index 47ff019..c21e5d1 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -225,8 +225,7 @@ struct drm_gem_object * static int gem_mmap_obj(struct xen_gem_object *xen_obj, struct vm_area_struct *vma) { - unsigned long addr = vma->vm_start; - int i; + int ret; /* * clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the @@ -247,18 +246,11 @@ static int gem_mmap_obj(struct xen_gem_object *xen_obj, * FIXME: as we insert all the pages now then no .fault handler must * be called, so don't provide one */ - for (i = 0; i < xen_obj->num_pages; i++) { - int ret; - - ret = vm_insert_page(vma, addr, xen_obj->pages[i]); - if (ret < 0) { - DRM_ERROR("Failed to insert pages into vma: %d\n", ret); - return ret; - } - - addr += PAGE_SIZE; - } - return 0; + ret = vm_insert_range(vma, vma->vm_start, xen_obj->pages, + xen_obj->num_pages); + if (ret < 0) + DRM_ERROR("Failed to insert pages into vma: %d\n", ret); + return ret; } int xen_drm_front_gem_mmap(struct file *filp, struct vm_area_struct *vma) From patchwork Mon Dec 17 20:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734271 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 3DD431399 for ; Mon, 17 Dec 2018 20:21:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 301F72A28B for ; Mon, 17 Dec 2018 20:21:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23FD72A2DB; Mon, 17 Dec 2018 20:21:00 +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 BAB9F2A28B for ; Mon, 17 Dec 2018 20:20:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 953038E0052; Mon, 17 Dec 2018 15:20:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D9D28E0033; Mon, 17 Dec 2018 15:20:58 -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 77D928E0052; Mon, 17 Dec 2018 15:20:58 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 2FED88E0033 for ; Mon, 17 Dec 2018 15:20:58 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id 68so12868062pfr.6 for ; Mon, 17 Dec 2018 12:20:58 -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=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=pLK+CYjl7Q6ODP1SrWESJiuBaBkELT5YcmP+Z16Bjhx9XNGPKg9F2KYr4FfVxmCxzP qa6+/W4lVMwzZgpKfxCj775CjmBdxoc46uFqkrHaS2f+p0tWl1AhCOG//1hMfTL4IASG IiOhTD+sckKETHw7yY16xitH7DK8gyGjJ4RPf31tHJ+nFb9yPZNa5z2pZX7V4HU5yI0h dUIim50x+iaWUzgLxZVO/CyrgYXnKvtbi7A7KN3TbJGkICJdKkVpNJ/i+Pq+v9fiP1tu 7Q2UsVTLfL40J0bBJBXQtu5DS+dqQj3fLhA+BrzzPkev4czuS4ozQbjx3gXoeeduPBs4 G/bg== X-Gm-Message-State: AA+aEWY3EXWgcU7I/Q5yg0TaOj8EbsYNkzQJk1d0Xy4QjRt30GXk5yM8 VUzjFz49b+4GczXgWTVO9zehAYttqLcLNbyOQyvbayGb2ikzA8SYoj4EKSDSN+U+YO6/EVcZZcY wwcZj3xS52pZLiLduqHeL143lfLqTkadcfCrQp9BUPISEWIz8bNamMA857h578aSitI+3oyCtQ8 PWBby+r4YOaT6n3GLZ1c8ikyDYEsIrJlgT3NVmtA0Q6xY1hMtocNiRIGaLY3gzbFLeqCcW2BM1Z jHV2i1OFs1fAK5y3uz0Pko8lVeras8d5bUSad48hu909jwXxxbTvda9FJIGpy6o7AN7dNCEvNck 524dcozKKrMZZd4jjyEKWsL0sJoxh2vc2jzEK96Yb15uMjf2qmWJpatgc/YmXIDct3KyiPJrUHh O X-Received: by 2002:a63:b105:: with SMTP id r5mr13383978pgf.442.1545078057886; Mon, 17 Dec 2018 12:20:57 -0800 (PST) X-Received: by 2002:a63:b105:: with SMTP id r5mr13383951pgf.442.1545078057279; Mon, 17 Dec 2018 12:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078057; cv=none; d=google.com; s=arc-20160816; b=e3kBAZinEZ/EStUqgXaazaL84iFtmEUtOeDfShKY28uviJiCOx+gN0S+xJqBsJ+UzC 0a/QO7cu6lLI81Hc5rkTRhW8q5LgUTWahfURET12sqMMqRtddis+/jYALQBrQ5KyKbdK cdD0y05Oqhx6g5evdAtBR9vjTEdFTw9y+MyPcOcFmV0lhl4Rj0xKoi/toDfLLMP61pJU 4I1FCQfaZ5KEJX0YeLceeBS2IsMFtfto+mAk+WR70ISuLjDba12Fukx+/LgEQiJMFdsh LkR4TCRqpPD6g61kimpapbaJhySoZ1iii1PKDS+HhQ3DSXYJhXpmpXvcOl8cXYJrrGV/ WkhA== 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=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=O9aFXaXFdwvqFwI6/TPVL2hZm4gZxTSKlnLvb7gUr7srBQcubGq2w46ngh7Tah4WFR z3+L0YrOGP2AFd4E6gedd3j+sxI9+vW2uvPe2C4z2allR+A7QMfoNMYa00f1AmPsIrKB 2W6vALGPQM+DjWq5+XaKnuqZW0CX8LxSPmCsvN+8uQIojJI6uzsUHaebKwn2mXJ/knJc /4ZeagkmrtYXO5EPWVJR/5Gj+I/GJo3xA5bZAGjDkqT9rUCMtmPkExi8NdUD/3Owc6h4 FttmbM0oEg5XuUk0IPs471V+XMfLJDjWQnyQOhMAUs5d3B3HdFTe/DARIZiXkYpdUo5w UncA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ke/LiHKS"; 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 o19sor20237442pll.44.2018.12.17.12.20.57 for (Google Transport Security); Mon, 17 Dec 2018 12:20:57 -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="Ke/LiHKS"; 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=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=Ke/LiHKSlBGRPCDmViUv3ZjVQC7ToSk3WGpxYAQvNSOoiFY64ZvLfofYbDmlTtMW8N VrhFC+VAqb99DqoAqfPLnVh5Igr3jSmBuSkHuT3Y+FIP9LRFRKFFbZ3g/mOJlHgcn3Ef hoFG+9clCHNChY22xwtjS65BxsUZUurd6TtAJcOxCnZ91scNKXhDUncwGPzurwPgfIUs oVUMPh5ahPSsoR9ZMilGLyGH9/9sGQaG5pSQgYrJsBLTeGALcntN0PhoCdLOhqR0nOpj 2XuHj6tHM8RkjMS5+iNlCqgjWZp3elAOQEJJF7S38QFA5cuAfU49Tmezda2UVJwXTxrx XVdQ== X-Google-Smtp-Source: AFSGD/UAm7C/DlwQy7KNbcTedSMmgshhnQHT7Gj8ZcYhxLhzLnMONLAKeJaEynXEJ23NmOWnQU4npg== X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr13227751plp.19.1545078056566; Mon, 17 Dec 2018 12:20:56 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id z9sm31408044pfd.99.2018.12.17.12.20.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:20:55 -0800 (PST) Date: Tue, 18 Dec 2018 01:54:48 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, joro@8bytes.org Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181217202448.GA14918@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 --- drivers/iommu/dma-iommu.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d1b0475..de7ffd8 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -622,17 +622,10 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, int iommu_dma_mmap(struct page **pages, size_t size, struct vm_area_struct *vma) { - unsigned long uaddr = vma->vm_start; - unsigned int i, count = PAGE_ALIGN(size) >> PAGE_SHIFT; - int ret = -ENXIO; + unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; - for (i = vma->vm_pgoff; i < count && uaddr < vma->vm_end; i++) { - ret = vm_insert_page(vma, uaddr, pages[i]); - if (ret) - break; - uaddr += PAGE_SIZE; - } - return ret; + return vm_insert_range(vma, vma->vm_start, pages + vma->vm_pgoff, + count - vma->vm_pgoff); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, From patchwork Mon Dec 17 20:25:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734273 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 ACF7214DE for ; Mon, 17 Dec 2018 20:21:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E3A62A2A9 for ; Mon, 17 Dec 2018 20:21:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9249A2A2DF; Mon, 17 Dec 2018 20:21:44 +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 F0B8F2A2A9 for ; Mon, 17 Dec 2018 20:21:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E80258E0053; Mon, 17 Dec 2018 15:21:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E09708E0033; Mon, 17 Dec 2018 15:21:42 -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 CACD38E0053; Mon, 17 Dec 2018 15:21:42 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 865598E0033 for ; Mon, 17 Dec 2018 15:21:42 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id s71so12823615pfi.22 for ; Mon, 17 Dec 2018 12:21:42 -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=7Lxrxd/hSsekQvS5TNwgf4HJhjrgrc3uztzkOk3jJZI=; b=GZ289+f/KoTfccNoVnL4kQzBMtTxp0pTWgU9I52RK+Rjuwv+WjISw+X7w8kVgD/DHY tjMisfmPhqyxTWj5TYalg4UfisZ75b17cnPlbAfPpEERFCRmiGZ0fbcrD8kbMBfm3o1r FcZ/J9M8U8o7ogpjC3Tk8aVVReP6+QQ69Vwcru8CoLPBqvmnKTqqnUlU2RGv2+1w7PdZ VzXSgFDQIlecdnyNsVhIc5oOXSz0YZVv/F5Igqow5iFHiPKhH61TXths4JV4TvMkfIQH /Mpa1VjqH5E4c5ysJXtu2RWc5IYdfOFjcbMMBYKZI6n3gFSbTgirqD0gTcr/Hw0CtruN p7tA== X-Gm-Message-State: AA+aEWYEZJOToiaSxDtrwLWA05sAf5yZZCUhgRg8W3lak49BEaM58660 jYa8b9sYHJMXvFXhuxQ2ub6GOnKxQF3o2LjnpaN94f6fo/10MkAHfSuVfg+oteH1IydmB5roNzK HDS1Aaz1kGYupMjVUYNVLbIhM5/FOl6L+cLgJIrE2h4rxtete3LTC351Bu891m15fRppdFsFvBD 4eyuaYlQKrqut0h4QLPJmEMvaYuFRluL3tzBq9TnuWX0D5D0fRhHrY3rL4h5ieUIQI+9D9NLayy eqXIAP4bn6nrCqYOUy9/oFRkubEdrnLVGwHO2dUouYYaI+dJmnx5ezJHpUKuKv3ad27fcJtynts gL0r33/1w8F7GSTQqb7ZAdmQnHFDJMWjkCvQ6zON2n3hJ+mj6a2ArTAjrHEzBDeAgWJ2iiX9P8b c X-Received: by 2002:a63:5c22:: with SMTP id q34mr13200436pgb.417.1545078102219; Mon, 17 Dec 2018 12:21:42 -0800 (PST) X-Received: by 2002:a63:5c22:: with SMTP id q34mr13200409pgb.417.1545078101607; Mon, 17 Dec 2018 12:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078101; cv=none; d=google.com; s=arc-20160816; b=IC9RKD3tzOA3UfxqNniR1TYNP0ExeozSKSJlBwHtaQKv5dRCntbYqQVsvF7S2HAKJ2 gne8fYSeuG8GaFWMOtvGzq6OswMGzicojjdf/aKLs1zI5hl5AiuRgZG68auB23Elt8CF LIjHER8p30UUA3QdUTR+r0Z6HAd2h6gJlDNRggr17kxw+1XHdPz3V0c1o70a9LEMIe5b +ztrTOypBCK3ko71vtjgzeUq1Gi/T1ZbUhzrt5bTmis2oJPIil9/UDE7/Ijigz3+H9Ul 0F5u+N3zlSFwSXd90V1I6p6sY1bWbo/F8pgN/KU3y7kfVLFEbNGndF/cTw5o8KI8Cf+H MtdQ== 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=7Lxrxd/hSsekQvS5TNwgf4HJhjrgrc3uztzkOk3jJZI=; b=0SjVKbPnBtJNNqfynu++xttnHIGnlOCIMw+jrEF3Ukw/G3nzlRySpAnjUDqndK1iyG 325zCYRuhErJtSv+cpXLyMb+EV53Wx1QQwAWy6c8G87NnfOYf+1Zw8rreYb+IDXTTWCu /AJdzRtrO8V6uY2jlmATff9eaKyCjeysgyW2mvVcm/D1sEb+hyTZZLkThzp/WXPiLGhY iXAWCmYtgKRnvu5yAKeNfFUs73R88FRq90rl6XsGmBbDydxhZkcB1AHj5KHc94lswWLh dyYme0gl0u9W9MNQ6bvvaRDzNj6QeOed2H9bP86cWgaSVt3qx3vP7a11X3yKk1I4Yh+Y B15w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fS++sl+t; 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 bc12sor20842382plb.37.2018.12.17.12.21.41 for (Google Transport Security); Mon, 17 Dec 2018 12:21:41 -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=fS++sl+t; 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=7Lxrxd/hSsekQvS5TNwgf4HJhjrgrc3uztzkOk3jJZI=; b=fS++sl+twua6rKfaqnifxpd414nSQn99YleFwG5ROoUgd4fYh8Gmfgnu5BfX+RGaXQ W9G3f2kmTXon3rFlZopX1f9SUhlISoKyouj9dqGZXzclbN7QgFLO8yz0spFId1MRH3O5 dGA4VWecIWUpsE/4lHE5tobsIZ8xLbEqIhVGe/tL0rrjK2CyWS7ZWFSx+xa8g7xLlthx wZs43S1vMMZKIXGIlh0lDrppYZtrUiPm7z4IHL71pM/rBdWYIVldpxLF2JHDfKcVKJO5 wQsiKO1oXc2bh3EO8jiOZ2RjNYhyAoO4biwb3t7UFifUoPLKwKkPvbQjI/EIHMCS7gST uHEw== X-Google-Smtp-Source: AFSGD/V108bv8qZyoC/yKMg096p+d0DPNRePsdoNXHX5jjToTByi5PogOU3Xk9s+Qh/1UrG/nUuFKA== X-Received: by 2002:a17:902:d202:: with SMTP id t2mr14094133ply.193.1545078100797; Mon, 17 Dec 2018 12:21:40 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id i62sm14879081pge.44.2018.12.17.12.21.39 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:21:40 -0800 (PST) Date: Tue, 18 Dec 2018 01:55:33 +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 v4 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181217202533.GA16294@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. From patchwork Mon Dec 17 20:26:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734277 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 D495F1399 for ; Mon, 17 Dec 2018 20:22:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C77882A2DB for ; Mon, 17 Dec 2018 20:22:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB91F2A2E3; Mon, 17 Dec 2018 20:22:22 +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 60FA12A2DB for ; Mon, 17 Dec 2018 20:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E13F8E0054; Mon, 17 Dec 2018 15:22:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 68ED78E0033; Mon, 17 Dec 2018 15:22:21 -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 558798E0054; Mon, 17 Dec 2018 15:22:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 148CF8E0033 for ; Mon, 17 Dec 2018 15:22:21 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id 12so9960899plb.18 for ; Mon, 17 Dec 2018 12:22:21 -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=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=tExc3HPBzaZWIfeouIiYijFXaHEb+/lE+iXk8SFzw+Tb4BmiUYCqxEtwxqiHeNrVPu m0d6N8iiaEEEOwGcNQkDJ00H0jywhXOFeBQhqdQ+4MS3TIPMT8siBwaW0iTHn8/3Ukdt 7k6FBkgIBuO+ypd7bOg0dxynmDcrvGGYqTQgOF80jxe4Z3JiFjKyWvMlRhU00ZB/HB08 CxkMt6L4plOhZOQ3sGGrHUnNkzb7eyR1dp1PNZtrTiWHI5yacxObivuz1XIofE8hwY35 G5DeSsOiNZG/mZWZPiJ46DgTV2iu0RdwBclKkjnU7pD4/GD6dtrVJIBdyAxzbZ1V5Eh0 TZJw== X-Gm-Message-State: AA+aEWYdJT8av0UGEUlSJWq+q8QvD5O0u3tQKDvHoDHA7gbLTvIUbLiz cdDvLf0SXdd9ejT51g4Z/b1j6cYp1mnrAXe1GAP6UlP8KcjBGd7d9yTB97JxpkqEObBUeiv4bJZ dksxXxEwcJAaeM2NFbTEZCrgNS2qqxT3wbCDv74y5bqAt4wJ3o1lbjjhABeIkecXtAyUG65WuwE Z3/yeSg5Egt20iMcsd0jIWXrsmJytV891v/HQ3diJekLHrWsOZDcryI84kll3jKkoQ4HjFeVBQP QTu3PZdb116gVkJnr8PjvhwZy0sAgB3pbrbS6uK0W96utcDqe1/RWvdlrBqsbRBZkIUOi7b2WXp bsF0LIr6URKoQMyAvOAORDRAtZvt3Q9tgu9GNX/4Xp7TSpUPurQlxHTvM2fWn+TELFz9+PsyJwE / X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr13685825ply.4.1545078140762; Mon, 17 Dec 2018 12:22:20 -0800 (PST) X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr13685795ply.4.1545078140074; Mon, 17 Dec 2018 12:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078140; cv=none; d=google.com; s=arc-20160816; b=Io+JiGjJXeaLutGh6vTmglODhJZ0Gk5ptu92pOWtxoRtWt693sCBa610D32BSd+yau F0voQ8KJxKbTHDs4yla19o6jCPORAE9NqWJSBgVEzF5n058Hqg0+KAhnRw2jbyvhQaJD ZIedxhONKp+CkNMiPIFvncTrq8Jm+AscUsoBhKhIklpQ6CWAwYD+YZeXEVk2NGefDz2c k/fniUjrg93Y8nCRiWhUiOp8kt+jSrCzlJsHr4FTZrg9QYzmU+nB1BXNeAP9B0Ni4CQS iWbCUoLe4GkkOCF9k49Yhfzn/8F/EgVz1rve6OptrQJJ3P7x/zMaqlMCiWQveqGkh7Zo ANrA== 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=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=JaOb7iQaleCYHDzNyoycbNr95sItL23jfJ+W3cnXrDXoMpszKDcZPjQa2BWHdCeXaD elHHDXPNaVDreQNXegTZb//nKL4mFRgdPAHHUOSFK+qwU41WP3KpIywbL+oC1dXeUbaP TRjaxuhgVAaXjxbPeo1TEs1r1BugndtNAFSM2cS74sVqnrxXV8v7GE3NBYAFRNOSgqJo 4ZO/BSJJciVXpRC4Q6Ix2EYcupBF6iRIekwvicEfeYhLPVIhFekIBMY4SUKEt5VviqEF hS7e+4qXKAu44IdJU024turQCy4U+TN/X3duFBO9EypgWRo4YqlyPRS6R7+lFueYCqeQ 50yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YSZkZtXB; 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 j6sor21681597pgq.46.2018.12.17.12.22.19 for (Google Transport Security); Mon, 17 Dec 2018 12:22:20 -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=YSZkZtXB; 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=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=YSZkZtXBTHutf0Vc6xE9hpWLdTQiV0LBpPh7E+tGHV4rn+ag0zPdwRG7EhkmCvu5/6 yTflbIXQRwtDKRjaheKdvZczHREL9dDm0/E0PPXryDAWVQ1dDjNVkODJXONGFs+RsHmZ 9HNE6lVp8ggq9J6oHg936hoELYz6z8wtqRf81Vvy/bMDI8ExoKDF7l1o68npz7cPk2Sy YC9Ch92Pwljml8KoQEwsMqimggKvRDSIjrVepRbxWARIW1NHzU1UMUrU/n5ktuoTHkdV BQryqdLvLjclBgcR19werYAe9q9hfgE3vV0axOgnsZFNEWZaRjI5QsFda/Y7dZWG1030 9uvA== X-Google-Smtp-Source: AFSGD/X+TrNR9f9V81XBDJgY79N2l38Sd7IjU/SS/fpnE4vfFVwlgbpFPPLma7Xyy+Ak6jm6z2ZBzw== X-Received: by 2002:a63:62c4:: with SMTP id w187mr9217308pgb.230.1545078139265; Mon, 17 Dec 2018 12:22:19 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id h79sm24507341pfj.186.2018.12.17.12.22.17 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:22:18 -0800 (PST) Date: Tue, 18 Dec 2018 01:56:11 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 8/9] xen/gntdev.c: Convert to use vm_insert_range Message-ID: <20181217202611.GA18060@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 Reviewed-by: Boris Ostrovsky --- drivers/xen/gntdev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index b0b02a5..430d4cb 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1084,7 +1084,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) int index = vma->vm_pgoff; int count = vma_pages(vma); struct gntdev_grant_map *map; - int i, err = -EINVAL; + int err = -EINVAL; if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED)) return -EINVAL; @@ -1145,12 +1145,9 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) goto out_put_map; if (!use_ptemod) { - for (i = 0; i < count; i++) { - err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE, - map->pages[i]); - if (err) - goto out_put_map; - } + err = vm_insert_range(vma, vma->vm_start, map->pages, count); + if (err) + goto out_put_map; } else { #ifdef CONFIG_X86 /* From patchwork Mon Dec 17 20:26:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734279 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 5EF2F14DE for ; Mon, 17 Dec 2018 20:22:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5193F2A2DB for ; Mon, 17 Dec 2018 20:22:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45A962A2E3; Mon, 17 Dec 2018 20:22:56 +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 DE52C2A2DB for ; Mon, 17 Dec 2018 20:22:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6F358E0055; Mon, 17 Dec 2018 15:22:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D44CC8E0033; Mon, 17 Dec 2018 15:22:54 -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 C0D418E0055; Mon, 17 Dec 2018 15:22:54 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 7A96E8E0033 for ; Mon, 17 Dec 2018 15:22:54 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id o17so11580874pgi.14 for ; Mon, 17 Dec 2018 12:22:54 -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=5oYSW/GvpO5Jr2lAVUEKxgPmdiaC90t9yQ4KohCOQbY=; b=l8k6dXf4uZsgSCCntbLmqeN+s8+IXKrZ/Af/SmyYfU8Fo0k5qc4B+gXc82J5/JrnLs GEPmIn3elq2R7aEr8Bt+dntO8JqG+A/tmGwN63lzdTNemaUcaZuGqm66+zVFg9ydI3wW 0562XS0b10uHTo0x4pSSwwNTatHqgVPHusifgFYfd7VNRigRSqZGYK73wfzclpsed2gp 229zuJ6hM7EB9F4/KQ/+E56+6OBQRtuHjWBmkiNRpFXLA6xWKLH70jnlFUtcgVWhsBUz nj2sN6v+nQYS4XQd+v7vHgPeCWD6vvWyRnJNv6Q093G6Q08VvV5xL98RFDBA7qZJ19Hx YX+w== X-Gm-Message-State: AA+aEWa2Deje5k9rlQuWA28Z/Zf9CtXXUgjEc2T2zdRV21wLrBwpN0DM jUu2orMe0QUSV1k3MwSCQq2AIcAvugkp4a4S76wp0Cjl9/UGOf5CR1rpFbxg+ec+VK3Pmgq11KB jx1iWI8XKg8mB8GBqDQrGU2LwVMqArrODUxxrvkaBmLcu8VBxrV3IzWtf78zmY+Mm5Vt6uNXcHL EfBBylJziXvUBwRAWtVpwuiZ8M/0Pygc1US4KDjk4X0niLxiMHOyOOaS+c280yDFrak4zD3krAG v1vnvR+aJQEKwgkHtr8+x1As18rQ1b578kpBcRr0AHvIEF9ZZAcZMkZ0OqIdnrKoe8eomb6jM0B 2BGYrmNO3JFlR/IXCsqjm1Gfl42Kbc76sH9c9cSOqEVJ8kdppRdy9E2H8D5BKGObV3FZ0UARKfo f X-Received: by 2002:a62:8096:: with SMTP id j144mr14316684pfd.140.1545078174186; Mon, 17 Dec 2018 12:22:54 -0800 (PST) X-Received: by 2002:a62:8096:: with SMTP id j144mr14316655pfd.140.1545078173617; Mon, 17 Dec 2018 12:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078173; cv=none; d=google.com; s=arc-20160816; b=tS6qdCe43saa7s+18dX6GqV3HiThj3dkcmWGWBxI2i/uA6oV+cPRRWXhlPtLJoFdPd TFHrio3xGr65xE0IvXcM6EMzMeXZNo3PkqtZkfxUsq95FAOhet9muDVpyRURTAkW7bJo tyKQboQmmjZ7c0xk+nVcP0WZNNCebJbrJGWrPyYxJEUvuv/77H+WeKisQYs1xG5vlqOf VmquOZz+cYI3VMT4SdwZONFVZeaM5z6SwS0H/B2Br4fX6Ney1NLvP/GnTgOR4ELBip2d yMr5OV6ELl9GEIxFX1nGS4T21W2Emoof25G8oYqW7HvAc2hXTaSDbCieAgRlxp6Uk98S ebOg== 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=5oYSW/GvpO5Jr2lAVUEKxgPmdiaC90t9yQ4KohCOQbY=; b=yfh0IzIQ4o8rKS1Ek3dk9e/uFdiYeVobthjWSpFQSlY/j0OAmk1K1zAO8Ys10hCCPg 2wtUcvXDCakb6dwNHdUMezBVJ0Ovm30oDxGP+XT3F7RpxAAIWIxseidD6B4CSgTFLneU lT/ui2SShfXUx6Hcdtauas4G8/bgoHFkvxiiWDEJCHhuCvJgGUlRrwR5NASHoCbkNXv6 HloDHAn7aX0KNXwoNh05kAy1Z16tjpOl9a5WB74AknCh5HPP+9mzYxH3FxkWwmchihB2 w9mb/ymI8Dcw7yCF6arAX/jRqRZlM5M9CW3GtwE7OQBGu3+yG6PCkp2mBpIadxA0it0H 7ehQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uUpc9hwq; 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 t62sor22947298pfa.72.2018.12.17.12.22.53 for (Google Transport Security); Mon, 17 Dec 2018 12:22:53 -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=uUpc9hwq; 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=5oYSW/GvpO5Jr2lAVUEKxgPmdiaC90t9yQ4KohCOQbY=; b=uUpc9hwqBACC1ZZmRW2aJsERMSJYQSVWUZFU0pgyeaJfu045oCUzYU8kMbaQ6ZcswG cFnF7lbG8tboEYSgWHBixo5XTCn6nKmuO3d8msyYCleyVTR2qX22tayUeQ1wmuMoVRwJ VrbmiaIaYzoTlf4ZGENyW19EFsqEHXYXe9bvt3o4HL03lfBc/25uinXGuzEpMxuGiNNb vP/QGj4O7JdWYnb4pQ4Sp++kzTjEym3CCaLCMzy2ECrFxoW1FDGtTK/6IYn2AuBSNMJr bJ9VX56znbPJzTEv4tUW1S/bmY7fT2QSIaDklkp7DHN7svgrhsUTgRGVzN5ZtM0wLrV0 GX7g== X-Google-Smtp-Source: AFSGD/UQwbbHHDgaOIDkqKpoGY4JfB62/5kRzA0kZTM7mwQtu/OWvxDxGYC44oQHanjoZ9eudkvANg== X-Received: by 2002:a62:5f07:: with SMTP id t7mr6183800pfb.108.1545078172823; Mon, 17 Dec 2018 12:22:52 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id b68sm21581385pfg.160.2018.12.17.12.22.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:22:51 -0800 (PST) Date: Tue, 18 Dec 2018 01:56:44 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range Message-ID: <20181217202644.GA19376@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 Reviewed-by: Boris Ostrovsky --- drivers/xen/privcmd-buf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c index df1ed37..d31b837 100644 --- a/drivers/xen/privcmd-buf.c +++ b/drivers/xen/privcmd-buf.c @@ -180,12 +180,8 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma) if (vma_priv->n_pages != count) ret = -ENOMEM; else - for (i = 0; i < vma_priv->n_pages; i++) { - ret = vm_insert_page(vma, vma->vm_start + i * PAGE_SIZE, - vma_priv->pages[i]); - if (ret) - break; - } + ret = vm_insert_range(vma, vma->vm_start, vma_priv->pages, + vma_priv->n_pages); if (ret) privcmd_buf_vmapriv_free(vma_priv);