From patchwork Thu Dec 6 18:39:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716601 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 69E8D109C for ; Thu, 6 Dec 2018 18:36:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 576D52F0D6 for ; Thu, 6 Dec 2018 18:36:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A85C2F157; Thu, 6 Dec 2018 18:36:04 +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 8B28E2F0D6 for ; Thu, 6 Dec 2018 18:36:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9CF1C6B7B61; Thu, 6 Dec 2018 13:36:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 97EC76B7B62; Thu, 6 Dec 2018 13:36:02 -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 86F806B7B63; Thu, 6 Dec 2018 13:36:02 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 43DEE6B7B61 for ; Thu, 6 Dec 2018 13:36:02 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id q63so987396pfi.19 for ; Thu, 06 Dec 2018 10:36:02 -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=Oa/SZo4NTYsdsBTx0P4ctAF7OtbSigl9buobaWrjyts=; b=M5E7NDgG8U4dMC0AyTK0yXGc9lzl5l/sww2bsUwILmzrMadv2Hh4O2E9dqb1ZnYiLL U26mFndWojS1pEi7E2Oj9QVGTSQUnfpyvE7gnNdk2rNZB3gtnrX7X5BfRpg49FfcFv0a FVDVV4bFQHofPAsayPktLKPirW10c+BdDXTfZtI4M5D3v5jFfb6pJrUEdA6drU95Gfic 7vWIeAD5bbo9mKblnu/t7lvHw/pjduc4xoGgaic8K1fhITiwiRsmDL8kS7FwWsgBhKQc MKFWTJaJWWZbQg+3ehK57VR7OFjss9rah7t/nrzdVckLzxirHNNwVqUw/MN8kCGZT+0Z apCQ== X-Gm-Message-State: AA+aEWZ2l0VymXuz+nZRh12RN2dY0ca3p6A5aF7KMfVwl9YYOa/BJ30T EOenBzxu3gCwFgh7akx7/W9U2jdqEPt9n7x9gxQccubTl4taWAZRlxaIrix/Z9sSupJcPgJNZuy ldBh8sj7iIDq+eKwDTVlmPqiOfPBBuNEfLO+1bWxJoUJTcy6XWra0vUcgEnbTc0jOOBG6SVapMW K+TE0oxpJ+ZCBHUBu4FTWlCF3X8TTBinID9f4mD/x62tWVntVxlHoZtYYNu1rFJfw7B91h1/55+ m8vxJ2kJ7ykjEyv7Ssz/aU/Xf66B4zg0MXLfyulM1bGUYImFLCOwcU9vdcneFL3+EYvy+i/qWjk 0plQJEhfA2sEZ7xzj6gC7dHEk1Rh9GAvCJFVrtm9fMqbWwsJULRDZK9GJIqQaGTPKrm+aSMrCvH S X-Received: by 2002:a62:fc86:: with SMTP id e128mr235418pfh.54.1544121361792; Thu, 06 Dec 2018 10:36:01 -0800 (PST) X-Received: by 2002:a62:fc86:: with SMTP id e128mr235370pfh.54.1544121360773; Thu, 06 Dec 2018 10:36:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121360; cv=none; d=google.com; s=arc-20160816; b=JJWJccrDmeYnojlip+3XnV7k348SoBaHGzgyWNegxWlUqpLJVtiZRkZcfXWCylxOU3 qwREJNhKL3ZQVkjS70jvLMhwK6dbamWSEiymNCRFSUrMsyYZ4GBP1YZ3BfD/hx9DGGqD 2FyOAcGYQZ1/8sWEAJw+yA9TjIOi0d1bS4+ibgfelTOwxmtX/FsAGDuA21R5Wegj02BV Rt75usNNGwQVAqKLgGn4Kzy+g+lM3M8jLuuHJ9+zhZjoaCpKYjDgjHLW/1IvBtBeHvib ZOXD/Bsl+Wvuuij4UahttrvxhOvLK+3FFj5eUimXFvGGclMxsti9rk1JU5q9FyQZhT03 5piw== 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=Oa/SZo4NTYsdsBTx0P4ctAF7OtbSigl9buobaWrjyts=; b=ZWE7iGDccBKIig44KAjK2u0/HhWCiIIaqyg0Nlx96HOKeYc1VIdY7E5FAyrTcw6NUu MKiqbfRyhJ8cbc1CdspngQJUzu95v+5xdGKah1wRa9FTMLLt5s0UiLpldRzg+1fTDVuv KN85w+EiVRqeKte/0yAui+Oz2b+gIydP+NlMKczcKAw77/Js/gbhWYRE5q4EdBT5vSBt V0DqDTV2bCy2aRl2xap5IxKtMoE42VdTWP2yRCQ30Sk+xbggOno//HIOaiMW/q2E3PSL wO9lhhGyMvXaNwBO5kIwrFeuy6lY9GTL9DaG9mUTmHe9wosV4YBRuHgBDqh/e3ZKsZIX Vd/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BS5vm9k9; 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 q77sor2122398pfi.33.2018.12.06.10.36.00 for (Google Transport Security); Thu, 06 Dec 2018 10:36:00 -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=BS5vm9k9; 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=Oa/SZo4NTYsdsBTx0P4ctAF7OtbSigl9buobaWrjyts=; b=BS5vm9k9bGLFTl+LX0bmmM9M5C7OG8qjleVkise2mkPltptK9svVJnzqEXXf1WBbb0 ci1hZudApj6H10+lYEQQczak59IqsTKG/aJp5uqzclWSGzssJ3XjOiOHbRPFUit6aUdw awp6zYPxAzYDEiPUutQH3/PjWXgzkUVgPqHp9qZz98vIUReekHUtzxSlvagqtyAczrCS GXtspLXDM8OX0uBS37pCwnH6jSXou/OORX8gep9Ie9VRObA/sjwgoW41zGJMRAt9I8SZ mn0hCyr5xvp8Bvr9AWCf70gWDWAYR72a4erJSB4QEx6QQg9n+sxzLaqCscuzTD0RhN8l 9s0Q== X-Google-Smtp-Source: AFSGD/WuBSuNZ0j2eI+y3vMK44Xcj2c9zc75ftpku5KoTRQQsbR2V1G34l5r5WGKdNdcPvf31x0YxA== X-Received: by 2002:a62:6ec8:: with SMTP id j191mr29584141pfc.198.1544121360370; Thu, 06 Dec 2018 10:36:00 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id d129sm1525051pfc.31.2018.12.06.10.35.56 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:35:59 -0800 (PST) Date: Fri, 7 Dec 2018 00:09:45 +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 v3 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181206183945.GA20932@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 Tested-by: Heiko Stuebner Reviewed-by: Mauro Carvalho Chehab --- include/linux/mm.h | 2 ++ mm/memory.c | 38 ++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 47 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..84ea46c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1478,6 +1478,44 @@ 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; + + 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 Thu Dec 6 18:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716609 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 79688109C for ; Thu, 6 Dec 2018 18:37:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 694A62EBC6 for ; Thu, 6 Dec 2018 18:37:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DB222F157; Thu, 6 Dec 2018 18:37:20 +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 025AE2F115 for ; Thu, 6 Dec 2018 18:37:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CECF6B7B63; Thu, 6 Dec 2018 13:37:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 057B06B7B64; Thu, 6 Dec 2018 13:37: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 E14206B7B65; Thu, 6 Dec 2018 13:37:18 -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 984B16B7B63 for ; Thu, 6 Dec 2018 13:37:18 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id a9so832397pla.2 for ; Thu, 06 Dec 2018 10:37: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=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=IM5JzKfavvtIsx/OR5jtgCRLbJCDUcOk/095YaK9toCYgP2iHto0eldWKm3BA7Y6Vs jyNmpOqJLqi+ZBG75s4JfpqjtFCeVAmdylvKIC7TmyVw/wOBy3i13opDCZenKwfU/JhJ b8drL2a2GPMquZMRcN3SXCxzM0O3m4h2tNaBQCQnCevy126dxqaZGMxZhg2b6eL7OQ1Y knA2aZlWSPyrBmWOZGXMvXfGF7xT6wUjSb9AeyWBFcVMkMYx4CeeOwR9JiZ6rHCxP28R M/Iv9wryee61+Cq5jy/pTUQurwSjmAK/JdfjkUFXbF9V8uymzZcXDzqR0eBJcemcVZpt 8Bkw== X-Gm-Message-State: AA+aEWZuehof25Rl7n7IGkFs0fiVMNIXoNmOiZgEkjJOdVktKcY4O4nh m8i/dqaZrKCwFnAv0/Iimv9sLoEJDEeR5/ySeb5alUEJBinQcTlpwHQOAdryfMcvpQwb1UjjbUZ +EfsP6WeIL+xefPOJ2OHQ71QN8IVRRkxZngFHsDzE9VRZPqFdwCe13vSCcJRwt7gDXYYUpisk/H 4kOP24X8ciwVCa2344e6Rn21OQ7wsDrRRWB7wPRIuqcZYo3ejGDqJVAfhaAyyYEdTAMgg3k3d4q 7EtPdjinGNugLTEzEvbTzoQBss99tw6SbrdhbqKtn3dxNSY3yzwU+t8v1SHUSSjy2GW1wCe599C IAnZzHf7m0pxqrITdLT2k6VlW1RrTqBnZqVeUK3acVyZMCtuYe2k98jqxOnxp3pMCTO/NxzmVrL Q X-Received: by 2002:a63:d157:: with SMTP id c23mr24819460pgj.170.1544121438274; Thu, 06 Dec 2018 10:37:18 -0800 (PST) X-Received: by 2002:a63:d157:: with SMTP id c23mr24819431pgj.170.1544121437569; Thu, 06 Dec 2018 10:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121437; cv=none; d=google.com; s=arc-20160816; b=lc6XzkMkrIvh/edFG8t0bfbhujiFrrDctBZUeAjkPt20yxLpFVMzudaa5B03+fppNp p2UfALz1rHjyYFc76behH/4eVbZEbAewoN56ifQh/emkk42U+5PBC80jKtrogpxWU0Nb N/o2QSkUtoDp77r3Ng3TlAQFWGtbyXsfck/oj5hkwnuswnnbNnuFXQHr6AOnlFJFQ611 BQrNDUSYlOhwJBQbEcM7i5MJ1FkWw7fDq61BrQKmrZrmPgNQc0J1KbXAn30Py32Qgv+8 TH9M3oRDeIRQLwY8CwwSYZrYGf5wK+jZ2CueAqNOPAE+9r+9GGDEyYIL6aTyTjO90ANz uKJQ== 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=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=h1+a0QT5HMcZJcl3ONQG4Gxg0dBx15XTbcRSgJeLSr57yauYf4pbbV1WvbnnAcbAIO pa0y9DGVM2uzlQWim+pMAV4bLUeq55elfHctRn8aMAB4zB+Km0L4/8zpm0YO3BZNXapg QgbdcK3p2m69bCksdJL716xfPX3YTDwnu89uSe9syq8IqbhWhgHQ6EiscC6TN5AWOF+F D4f+GEy4KbDLZDWSwmk49vNZYyY7j/Rz2oPYDs4ja0rxtIDfartHEc46Gqn2USMAuxt3 IahFAb6N6A4vS83cDwyNyX0Cs3I+SP/lIAco+mJvPPDpq7+EHdoOkymDwIsxxbwCiv0o XCOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="jQdYEmv/"; 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 u6sor1948588pgu.43.2018.12.06.10.37.17 for (Google Transport Security); Thu, 06 Dec 2018 10:37: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="jQdYEmv/"; 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=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=jQdYEmv/c31kkxNf63DO2hDppf2yyeLJmKw6Ll2SJ/lUFEj87Ru6+xfE3lKIfctczi 8ZbadMqzX3u4nD/kPuuo5FTDsAsBFI8Ica4ERuDuRDBeSZYaRW+qebFFg1LWFvnsI++k MP6iVmmy3D44dFT9yBmdq4IPLjCpp/2yOZUh93d29NzVG2QDnxm4vPTpZo0UYpNJWOgm cuJ4s1duczRJmygZdRUaSnFePvExxPYFUdNMrtwXEle4l04GSONHvunsQ2k+atUkoSOP OUpXiJJsaBLM4RVh52ZhX9s5lYy25JjRE8z2bZKooZryBibA6lnE5g5v8EhgIFTtZHBP ShLw== X-Google-Smtp-Source: AFSGD/X8vL0xWSmYdOfWCYDwSxgcM4w7QeNvIJM2oEJ88aXzCt2cszDLSX+lbehOI7LOGmWx4fpNaA== X-Received: by 2002:a63:68c4:: with SMTP id d187mr24796460pgc.11.1544121437220; Thu, 06 Dec 2018 10:37:17 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id n66sm1517646pfk.19.2018.12.06.10.37.15 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:37:16 -0800 (PST) Date: Fri, 7 Dec 2018 00:11:03 +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 v3 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181206184103.GA25872@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..4eec323 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 || page_count > nr_pages - off) 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 Thu Dec 6 18:41:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716613 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 4CBEE15A6 for ; Thu, 6 Dec 2018 18:37:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DB852EBC6 for ; Thu, 6 Dec 2018 18:37:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F8C32F157; Thu, 6 Dec 2018 18:37: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 B3FC02EBC6 for ; Thu, 6 Dec 2018 18:37:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B58186B7B64; Thu, 6 Dec 2018 13:37:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ADCC16B7B65; Thu, 6 Dec 2018 13:37: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 97F5E6B7B66; Thu, 6 Dec 2018 13:37:54 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 54B8A6B7B64 for ; Thu, 6 Dec 2018 13:37:54 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id 74so1002070pfk.12 for ; Thu, 06 Dec 2018 10:37: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=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=QLVQsApxMtZ044XtDu65Y6MRn0S7XbmMpqZvv1fBAKcU62Fx7Y1ugOSMErYGs655bA VUbmLFGfR1Oo6KKvohuPPv+LIT9+gMYvCm8WAXIzbgzNeSf9ftZg+kWy/fz8/fstQkAC hRn9ULZHTGNW5y+UX1JIiVZ63ZUsY9vmvtzSSdppGZE41ZJ9XeDGQqVoXhc0uSTVm+aQ Y0ZUOdN7R4xf4zrBogmkJ7zJiSBpYRqmn/OBUDTbbpqrK+h6UK4etS+JQxJzD7ltgtjk R+pmF3E7tfORlifjBMq6YXN1NzLYG/Qy/Oof9uXBfxv0H8TU8XdJqjFbnXS6rDbzHBJ1 IuIA== X-Gm-Message-State: AA+aEWa3UjhzdU2sx3suOK462B+uCqCPSE3L9varrRa7ci3uEp0lQBDw NBqoJflUAgSglra1FAWceDz0Tku0IUdqHWo55r8TPXzxooK6iOvysMqtgnDNlNsQGC3N9nmAeF7 PJeexoUYzx0lRlRzfDzrMR7nPUFT3XxAGdOOKjldVp6/DULlC6PDdbjcucklVglIqivkM/Pue1m cr4/2XUJn5ztXIWuymKufY8QQk6aHIu3meB7DdNg+1qpuRxR/Mi9fp+DvPdaxzPzFV7nLCRVV5a lYjIC3gYAUvIaRoFQS6gL/OHKYkruWfjcwCfw2M3SB8ZFkxUJHQPxusZjCW6AEvQZEwmiPuNGKc ZIFCTdinutO34pXOnbHjY6CXzicSKEoELVN7TdHM2+v9V99GprFJXO1rkOCCTjd33BFSbKuvhUz x X-Received: by 2002:a62:178f:: with SMTP id 137mr29374915pfx.226.1544121474016; Thu, 06 Dec 2018 10:37:54 -0800 (PST) X-Received: by 2002:a62:178f:: with SMTP id 137mr29374868pfx.226.1544121473356; Thu, 06 Dec 2018 10:37:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121473; cv=none; d=google.com; s=arc-20160816; b=KtDYzYEQynwyCv4XXDi7sfJY3xAv2fHA6beQco+YMI/OzZRjK6tf4LEN0VAGRrjM4O dMu8ADmqgcdjPraPwbJ7Y00OoGs2V5SueLgjYMZP02Q2n3ZUkjSTM+k2eSzyaRIwMrmv MNSuGmkLGddjsxTN5VPnLYhjmT2j+zF3OKQIwdgXnHTYqZaAJRGLb8vSH66bUCwmS2vK /kNPRYxwOnkroqFtwb/x2/ze22kL8ZvAZ/KEMGfOH+uKhqS6ybwivQ2NBtUcKI0+nCXz 0T68/roo+zn0l8Mt/bUtS+qtzMgEZpPG75TwFuAs1uyROf5LAfXHQ36a4Gb0KPMQzR7l PKPw== 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=aGYxceQ0NeqBTPWE2oTmYRlVeoLyL0WQrDmD7TECmJf3t83GYWd8pvW4RS8O/GAuF0 Xti6Qt8Oz7VHJMKjP+ABeZotCZAfftOZJfD+H3k7/nbEoqVYFQvdlYoLiV1ukixeI3n4 P+vrjPYhYoLb7nnEbM4PGeautT4HR/mu/WnA2NRPiBlgSZ64kI2+9Vcgt0NS/9C5o9le PIXRW7e8kS/KlBBDxRfkX3l/JkaZukGw3TO8jWOTAkj19rwDtuBWrgBzm8D/4RC4Pe49 57wf3vIs/ugZd9622sZPrtXOtcZ6jbZwDW2IdfMEnaKKt5XEroT3HqBHO5zEleSPE2vk wjRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fbLh52nP; 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 62sor1848550pla.19.2018.12.06.10.37.53 for (Google Transport Security); Thu, 06 Dec 2018 10:37: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=fbLh52nP; 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=fbLh52nPpkqcT1Z9V3ynz6uiPBZF5qfoJ7/hPEZvBCMX9CeGjmuiaMJt+rxLafnLa7 f/xYhIOsoC0o/ferMj/eZvUp5HVv4NMCx/xUGLT4rts1Z7F6Ekp43794GO6SxyUjq41C 62Wr6dgG7VRi3tjWvD2US+JF0DTPRcxDbkHYRfJ0H+SUa5FM6wr3LYGbjxxPgweg7mGO sZE9GdYGcKvIWQseAlW5idOnudxqMDkBFLSpmuI7zJ1qNdogSjACVAFOtRLMxidohXSa ScDcjF5aHzGL/JZZHC+dhbQx4sQctZ2rE77G+oqhq1rYOkSTTueCdoOBKkz4sBuPsw0/ wcxw== X-Google-Smtp-Source: AFSGD/UDqrBQcxC59f83l1Xagr3hCTLl/ORxA4W+x1FMEYcVxWh5JAcv00gbvM11R+DxMrDXnFwY2A== X-Received: by 2002:a17:902:9a41:: with SMTP id x1mr2169801plv.126.1544121473041; Thu, 06 Dec 2018 10:37:53 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id o1sm1621229pgn.63.2018.12.06.10.37.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:37:51 -0800 (PST) Date: Fri, 7 Dec 2018 00:11:39 +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 v3 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181206184139.GA27514@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 Thu Dec 6 18:42:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716617 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 5B66C109C for ; Thu, 6 Dec 2018 18:38:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4495A2DCBC for ; Thu, 6 Dec 2018 18:38:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 307D42CF39; Thu, 6 Dec 2018 18:38:43 +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 7597B2DCBC for ; Thu, 6 Dec 2018 18:38:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A42626B7B61; Thu, 6 Dec 2018 13:38:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9CB816B7B63; Thu, 6 Dec 2018 13:38:41 -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 893F26B7B66; Thu, 6 Dec 2018 13:38:41 -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 420896B7B61 for ; Thu, 6 Dec 2018 13:38:41 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id v2so827458plg.6 for ; Thu, 06 Dec 2018 10:38:41 -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=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=AjTZ5EvES2QmgeCiwY3T2NwqsCMYnDKpw2/jmlx0zrP/Hr9h43GRw/4su9RIrkNuYR RiL09AVOV9O048rTvc23e7c+VFM2QyMWDacgbUlkECtKtXfLApI4zmEeKCU6AwwrtLLe Uqob6k7Rk+JGGU8tTR+sJXTVnI9Jswu6ySAdjYezF0Xh1MMMUx0cq8wotkjUQFxr6VhT Ww7verkOyuQx9y7a61atAw6DZved3rFS8npy1ilMQGLC9KG/f57nnczyu/5mgPmb14cY Um88IlBM6u+jOk8gk/ZDp+J07L4UOLoniZcglDd0ZUDnTXCwmy1Sfs/mMoifmShR/HM/ FQ6Q== X-Gm-Message-State: AA+aEWZBPw3AiGiZ6Q0bKGrR9jeIlwJwQ99wjbOf6RnKkw6MvfGMMEWp lfSw746gSqT17VDdeLXr+5WLEJvJLF1ip62YAw+JXo2YjuD05SBKr+nWkrGCN67iRWCP03tEAE0 75WojQ/bM1DG9TsgZbKVpg7i9//zbWU5XZ/pA8sxaFzK3qTZmGHWc4TSLfKpRZVoMOI2vX7vd8u si8Ql3GfxXkrxJ2X2cyvg/nGY3dqpBWr+YD7AtrFgtg4OLPbaoufRwkhvEJuCkmSEjDcA3UKBDT ykRE+eHZOlkUcfGRYf+VF/MFYNqMPaaQX3DcHim4hf00OtT0A6d0OCz2NQvOKG/Gp7eP4fG6bM8 EeG8f5ANOCFf0dBhHzvPWp3890RnRHypgUbQgF9YhfViSS/cmw7/VK0jJQKbcgbcc/erz8r8841 p X-Received: by 2002:a62:5dd1:: with SMTP id n78mr29075821pfj.58.1544121520938; Thu, 06 Dec 2018 10:38:40 -0800 (PST) X-Received: by 2002:a62:5dd1:: with SMTP id n78mr29075783pfj.58.1544121520220; Thu, 06 Dec 2018 10:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121520; cv=none; d=google.com; s=arc-20160816; b=fueCdKNQ05sfKiYfEQFmNsb0Yy5Ve3aYag0EHbnpulzxO8D4N7SDCp2DBZBXI+8K24 rpH+bpwmBjVbzduQo34yEs1+wXxOdkTto0vP5X/vj3urcy3ZX3wG5Qfnq6nEp6BF3szS /lBZQgckvuY4d/zMCBlo9AlWOpQZ89uHU09pbP9eGCKhLB+QS5m+g7aQm47bFvuPq4cD or9cYdK/NCx+vz0v4RieoGf61pARkoYPfdze9SZ1gnOgQFvPgRo2KShXSA9uyitnRRrh 8DFe0BBcn3GLmd4kr/nFpyBEaJhe9JGOkdgWiyCGesCF6NwhJiq4Z6iozdC5xz0dnov1 4sCQ== 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=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=tkAuom9sAsR62UHMpZtlAhH+j5UtWju1zX2rqDUqAjXPBSVdOPD2R901lue5jVlixf XQQl+Iobk1RvJxONbIRzUHR8Cby3eLHlQwZiJGo5RZvsHcZE0EtGQQpp520BJ4hI9kx5 ABQyqPCDRWGExEn/Mg1bS0n5dMYR99C37MPOtr+Yww8er6U/FETSq4GliCDQFlQBoLXl JCoOVjsjyyGj5zzejbPH4cKTukiN7hIZ3rEljwrx59ZwpUHgASQPApjYjVV5B35Tq9E2 GAJxnulH57/oAZ1zqVh6e30yUKv35MFVruwTZXQXffAcdr7IFPiiOalegE40xjp19KV7 8Avg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UD31QJ6G; 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 f21sor2010097pgm.40.2018.12.06.10.38.40 for (Google Transport Security); Thu, 06 Dec 2018 10:38:40 -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=UD31QJ6G; 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=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=UD31QJ6GC66z7VnoRsNyMmQJNDtWDYhH1t1EhWvLVC35clbrhHvtCLfIDc3kuI/kjo PhE6/Q4QGJNtbeVj2PuHR6i0D2aaPFSW/lrGYQAawYaJpSZ00GcK0STbAQbASLfKcXbW KSmwt4pirPr0FbcPDgPDSPCxOIqY7CFQcfCnf1brtTusb4rK2TnWnnCiyvjOlAwhSnVj fpCFVKaKzndenoWYom9LwhhOrVfEHUY+WbndNJqxZnMyKCBPm0+weR2X++USF0iNayF4 WigpOsLRPEHu9s0S1Xs9XsH4QUV/+2uVeBmsr+h8O/0evUYqwJAesx/WQW19miTVpRjC i+ag== X-Google-Smtp-Source: AFSGD/VdfjPNYk7vJ3JQ1RT1pvFcY6rlX1YYQBpdVWgqyCdVx5xPkkuEuOXRFKVBkjSnBJ0Zx3q50w== X-Received: by 2002:a63:b81a:: with SMTP id p26mr25564117pge.433.1544121519885; Thu, 06 Dec 2018 10:38:39 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id z9sm1534389pfd.99.2018.12.06.10.38.38 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:38:39 -0800 (PST) Date: Fri, 7 Dec 2018 00:12:27 +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 v3 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181206184227.GA28656@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 | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..2cb83bb 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,10 @@ 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, + user_count); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj, From patchwork Thu Dec 6 18:43: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: 10716623 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 8562B13BF for ; Thu, 6 Dec 2018 18:39:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A9C2F115 for ; Thu, 6 Dec 2018 18:39:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AB852F11C; Thu, 6 Dec 2018 18:39:27 +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 ED1D32F115 for ; Thu, 6 Dec 2018 18:39:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CD506B7B63; Thu, 6 Dec 2018 13:39:26 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 07C366B7B64; Thu, 6 Dec 2018 13:39:26 -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 E5EBE6B7B66; Thu, 6 Dec 2018 13:39:25 -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 9D9EB6B7B63 for ; Thu, 6 Dec 2018 13:39:25 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id 89so813871ple.19 for ; Thu, 06 Dec 2018 10:39:25 -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=kAgXkxEOg5WMHF23mQEcRg8JWgntSdSZsFPBHiqY5X4yJXcgzJQNaWJdGxoSKXLiz1 1VbstDiCwHhPixGg9QFv1I4pxITzO6np7RtaOAa9YEqepCthIxlqY1XceqvHi4Axx00J avXplAd+iSLqW2kRMKSotFSYthxP3u2QRUq4zSouMe7Yb/mqT0zKC6Zjgcs82OHfO8fE C4bM+4rTnlQSyePxJGUntxE5zT/jm5eqKScXPHxtF/tfYH8q+gIl2TTfjcxzFGXnunlR 0/KF+e55o0ldDyyYtg4h2WdD/TqDn3wRt2nZvO55I55uU6BnrlBte5PE+dbRNtWJQjYX GzIw== X-Gm-Message-State: AA+aEWYiQdw2Vn4fVEoVzzZ6GxKKXE42gI6dW6+aNuLQVBiJZUNbxY97 38/h2qmUiZP1KeDeHq83BHtmQQxFghz8lpOtse+SOV4gwiT14aIdPhrAp3qf1wWVU635BxWmn8u YW5H/1WrdjuZVC4P/5sTO7FzBYhjekf4IU1HBEeha/othiKd0qprBBOaxINK8aq/VWXxfBzYF2r bTOwdkx8sC4anOxiqI7e8e93wTGaYd+DVzlTXfLlocD5RTadzEBus1svGhtw6qv4Hw5M2Byy0m3 1uNYtxL4btZAytsacDktGSqY3vRq22royLMd6BRI5EGcWTW40NJjSG6d4ivEKYMCQfN/LaaHUeH 1Ko2Qx+i6sqWx4JHmO8UsSCxuoeCEh85pXFZWzhXyHUvKBZU07gVMYkAio8pq61A351F7hNPkwZ g X-Received: by 2002:a17:902:9897:: with SMTP id s23mr27974888plp.69.1544121565319; Thu, 06 Dec 2018 10:39:25 -0800 (PST) X-Received: by 2002:a17:902:9897:: with SMTP id s23mr27974860plp.69.1544121564487; Thu, 06 Dec 2018 10:39:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121564; cv=none; d=google.com; s=arc-20160816; b=ILZoR9Nd8cOQ0hYqQvfWdCySDFp11cr67uDH6Q6AnxQs5kuQaKXPmiraceod7ufsqS TAcxwNzJs73hiojPizl7eTQZarMlu6+C2iBjTvlvk5cA9i5OEsPSRYH1O6Y1SBwNbNGY oBUSatEdIj1OqYSgqIcfNq7QpZ5Nc8wHGUcPpajVRKIgkzNfVSFgPlh3N9pRIeBR83Ew By2761j6+dthG9ZcN5vZ+PWJbhXy29o5vjumpF+b7cwO6gSTPDNgVpRhvAaFvKyCIC0F rrnofs+SwQfCGkFX+aSTj41FQuLb64Dfr6lQhacLdf97+rAzu2wPbThYTch+WdXBQvA3 Rg7w== 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=iXgx3OSeke1w1kC5V9EPePMzaWa1vDqgX1m6TP3u6S+9XY2CMjA9uhgt/AHIa+ffmJ 2FRwPvywidb7cv60BA8UHc0mcPr7z1FXNUjbJucI4zgSaYldAXitWZvC7Rt0l1O/GWyR XgC9+oawat+/PZlt5K+GIZtq/fASKVSbPgOcum8eOlY+9V7X3nyoiG5VgJHSmVVvsC/+ nmFvqRlKMBErCVYtUCmVV57XZp1pEzDjcaCu3J49Bf6kc9gCX/0GTVjl4Ez3u6GfeQfY ayCEck6wKdIokcsh1uBF9kNVEcIO39Kpc9Th3zQMHTlhqODhGqrgiHALxxJTlEbp4EFJ 0UBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gt35VdLO; 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 h191sor1940358pge.48.2018.12.06.10.39.24 for (Google Transport Security); Thu, 06 Dec 2018 10:39:24 -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=gt35VdLO; 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=gt35VdLOJLkkwu6HM2z/QMOGYwYxQY75TZOeYdRPNnTaNn34UV2lOUy11lpMiKEIfl pJUTYq87JeZixJZt6DZ2BEh2ecwXtuaUNMY4mqSOb/ww0qlIfkmmuqzotryN5D9+6oQi 9xhmmpXQscZwqEWbKQ208V/yDxrw52NwRgJ141Brcflo/mxEtx/n6YjZDnoXQO/6v7R5 NuiN1qnkxp/ZrYifd/oDMRri6z2c+QGns5ibd0289c2wHJf8F6j730XXRwGlnIw4sp8a L+bo4aqgKCsZYoPJZPAGP8JM7G+Rsh8zuj4x+O4mxtV2I8OIYHnpyGahS2dJCHTOy092 pWOg== X-Google-Smtp-Source: AFSGD/UfFSt2nT8PksMeYnwOlOFwT/wi4bvRW16Y0LYOo7p9wxEoYqUr+4/gwU/InzrrQl8sQGE8eQ== X-Received: by 2002:a63:2849:: with SMTP id o70mr23387850pgo.155.1544121564152; Thu, 06 Dec 2018 10:39:24 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id p11sm2259233pgn.60.2018.12.06.10.39.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:39:23 -0800 (PST) Date: Fri, 7 Dec 2018 00:13:11 +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 v3 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range Message-ID: <20181206184311.GA29651@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 Thu Dec 6 18:43:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716625 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 974E317DB for ; Thu, 6 Dec 2018 18:40:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 842162F11C for ; Thu, 6 Dec 2018 18:40:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7221C2F129; Thu, 6 Dec 2018 18:40: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 1288A2F11C for ; Thu, 6 Dec 2018 18:40:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44D816B7B61; Thu, 6 Dec 2018 13:39:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3FD4B6B7B64; Thu, 6 Dec 2018 13:39:59 -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 2A1A36B7B66; Thu, 6 Dec 2018 13:39:59 -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 DC36E6B7B61 for ; Thu, 6 Dec 2018 13:39:58 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id u20so1027605pfa.1 for ; Thu, 06 Dec 2018 10:39: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=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=X7KqhAZTHCYzf/A35VbHiadxsqpmi/tUjRwcOyErj2XmS5T/qeZIb0Hg34/WtZF4xs Sh7jjf0qcxKSXAOEw+VMW2bBPh8lDio8XIhccCIWqhcRu/+MZiymGbS8suejEOyikRGh IEIDZxaJha+l/PckIc4CJc7YUKlhxklTJHGK969gd8v5DuyPyUUUfZJeCXy2w7MJIQxt PCPMj/gZQ6/jAEQC7NtgBgRPwCR+AzXDORqeqBciR4RuaakIvCtpVOuPesvFzeXZdJWa YH2wHaBs1I/eNaDbQVRAm+7cb+jYxIEHhIEKLRhYlIp9dWl/KPyggk40DiO59yZ8/CR5 +NbA== X-Gm-Message-State: AA+aEWb8VTwARwyOrD3u0orqUsc4MXa8k/BxeJ0CcaVJHvFV3qrLLCro OSwb8j8a2B9hXvoRvDNeZfsTAC3I72sFPLB/+mMd4++CngYJMh7TgLNo7Dz3p6v2dkhNdZDbLY1 vTsLjVbf4xaLIe3YqJvaf3kUKi7nB/2+71My0cMJd6Hho4zvdWK5kRR9OX9tAoYh1rcwIAb6Smk n0v0Djo5UUKDuquR2wGIVTCrJO/sOHssRhd1h1dc4rdIdhxxd2YEJU/cYVQeD6lXfLUqCZYtr1w JJ0FgnA/PtG33wFI04b6FS+yTBaGxDuUeGOSV+nfIzDreGo/HJHYJQnFzM5y6eKlxQd0MT03pBc A+g3G6vP/b3np/NmLK/0qILIqAxkVqQN5/WVT4rsaC9Ole5it2z5FebmfDNa5X7LrOoXYOKugdJ f X-Received: by 2002:a63:6205:: with SMTP id w5mr24992189pgb.53.1544121598537; Thu, 06 Dec 2018 10:39:58 -0800 (PST) X-Received: by 2002:a63:6205:: with SMTP id w5mr24992130pgb.53.1544121597277; Thu, 06 Dec 2018 10:39:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121597; cv=none; d=google.com; s=arc-20160816; b=xPudNoH3EfNwgn5JmJjtGe6ovjJeMsxMPB10kklawIUHGKwRLtJR4z5d1MxUCoBBKX ZaG6T8CpVWr/+IRfpLXko0kf8jHXsUW7nYQJvMcELwQSJm26TdrckZyxm1uzpwL0DlSb 00ufhIm+yjIteoyisvVdYSuCM/fMn2K7+9PjNN/K7/oyeASqD9nW02dD/9XIZ5haC+4j BGvsPNWO1avVD8b9xbzFkvCTrKiXVwNm4ZLHnuN4xMa01pOxJX6v2R3hvmbq+aItaLXJ M9z6HG1bZOzjJB1Ocb4Wtr1DTB821mrvGaZWn0LeXri784bR0npG4knAC6y6fy5aeFHq M0pA== 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=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=cc0fmiTWTyTWfE8rtMcADknkWo+BdxDE0og4JJmUVIcv/+FoTeXKym60JyjcARasDD eYZ/34zNkG/1+Wwt9vAGKe9/qSKfAz3CWu2MgbefpTnyMam/haVSRrAV6K3vgRFRrHyI E+CyPObFV48QpVfndY7ytIf8fmNzUkBtEt/hcQGPqtPYBnc4+bPvIcWn+sEKUvu7i7AO 0I78AgTja1dZvtf9uUadFro6twM79bLl+tjt0A9YiYysn4/auXVtYcuZOVxnad2MvhgB FgKN6sqzFBAAi1n8j5pPfBgK8uqk9xEcYcIOY884RNYluUCp2Rpd9l9GlseTWXrcbJzL oz0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XJVbo1mV; 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 y21sor1842876plp.22.2018.12.06.10.39.57 for (Google Transport Security); Thu, 06 Dec 2018 10:39: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=XJVbo1mV; 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=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=XJVbo1mVNUPsRUa49x9iPWHWzpgb6rsqCpilpKc5Erku9gr23F/8jGJclplfZqouIu 9W2iKcRBb+uYGakLbYF26F0BYeTb0IZw6x1uOISBC4U34diG7gWmvVXPxYEYd4ehI42R sPavmw6/0rbWcUBjbdDwcAtBRyw67HR9rhg7saq9lfh9GWMOQwbTD8w9JB5e/ynwaCfp /1gI0Vlri11+t5gHus826QWCn4A/XQPpqrjX/cDcakpAVOcdMg53iKxcbyMiF5Sn+nO1 U9r7/tfyqR0qNIOw1/H2SB2ZTMP/8OHu1FrDQjrGvr6bgHN06ozJo7a9GQ81GrHSsQkK Cbow== X-Google-Smtp-Source: AFSGD/VNnI3Z5UaH7h9TyFGXwiDnq2+6sodXbwQm7ri9n8PQRYJ402gtVTtYmhUEYvPgUZVzoKVTsQ== X-Received: by 2002:a17:902:2dc3:: with SMTP id p61mr28602536plb.166.1544121596529; Thu, 06 Dec 2018 10:39:56 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id 4sm3051359pfq.10.2018.12.06.10.39.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:39:55 -0800 (PST) Date: Fri, 7 Dec 2018 00:13:43 +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 v3 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181206184343.GA30569@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..a2c65e2 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); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, From patchwork Thu Dec 6 18:44:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716629 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 E44961923 for ; Thu, 6 Dec 2018 18:40:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D56CD2F153 for ; Thu, 6 Dec 2018 18:40:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C98512F17A; Thu, 6 Dec 2018 18:40:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7634B2F153 for ; Thu, 6 Dec 2018 18:40:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADE716B7B66; Thu, 6 Dec 2018 13:40:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A8C8C6B7B67; Thu, 6 Dec 2018 13:40: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 92E546B7B68; Thu, 6 Dec 2018 13:40: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 5117A6B7B66 for ; Thu, 6 Dec 2018 13:40:53 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id v2so829992plg.6 for ; Thu, 06 Dec 2018 10:40: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=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=R2ob4TYIUA+Ej9LgFTLZOp3q2H8pCFSOwf+lmLoSmpnu11Cddnc5leJ1kg48UDtqXz tkNaminamOow6Om1wCTOAEdXk50m7S2uoZWja9DgPqWW1AwS/XBFiyElkBKYD7iMFfl6 AiqrwxMlA7wbF5wuypEeyODt9ImmC1nJuEah4TFzTUbGJJ5KznSg04xN72RwnFW3y1cd tXb5rggvB5k+BCK2Bbwh9qqzrGWacVN9aTujHIum8ofzFREuYxoKSM3FlNATmNphjkit sy6K3eSZ9qcfeeayCm6vkYCtR8pwKDtOPtDGyMhmGZ3mzqvxBWY4tp38vNUFoYNmCOME a6vQ== X-Gm-Message-State: AA+aEWbOadbSx9NCFU2XsL60NCJ3lWFzD5rk39JgHyegwSryTuBUWiWL QLLRglK6ciZsAYYMDXaZhJ5+RBS8neL7TsXFTPa2uEMLfkEWRK3fDbQZTZdkcIVGul3n/WKnKtI 4FbBnWz6rKJtcVzn2xOMSeBrEPfudhuLb51jo/q1ouva0NqxvK8aaMelOaj19oYr7e4H+4K+LVe TXC5l1CBNRWg4bQuXsx/brzBFwZSEwKcxNxrIUm2Cuq6cyxaSFYXREH2bsgVD6xmD5fO33A92yY NAou4i/l/O3p4W4vGb18QegNo0CetzquyRUaL7a70mk4jwp4VJ+jF76o9GU4aA9O/7A2rCjkKpo Y6RYU6XP2uIaK+nGc5RAnAegVamsiUCLxL+X7coKxCh88oisJ9uHJavUYudXeGGZeeNOSjzRHAY V X-Received: by 2002:a17:902:f20b:: with SMTP id gn11mr28006917plb.274.1544121652988; Thu, 06 Dec 2018 10:40:52 -0800 (PST) X-Received: by 2002:a17:902:f20b:: with SMTP id gn11mr28006886plb.274.1544121652326; Thu, 06 Dec 2018 10:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121652; cv=none; d=google.com; s=arc-20160816; b=YsdUVdKl1d0fGXAKmKOpmM9W2ts4nWrOV+dtX+KvaiKHelRxBfI28xrg5Zgtkb1xts nFpsxWEjw2BfcuUZcCp8keUvfR4wcaIpwsBGRI1LJxOyN6iwzaC0lLZpWJUUiJOvMCo+ r8Xv0qzZyJuuElo8EqvxCkSQBcHTtwR5+LuXYAVo53Wbce0md3BGdzbndw+9NYlxYhVv tiHmgc39cLczISd7JzMqrf9noJRj2nC8NuxdBUY2kZxPdtal7EvVRPDsktQgksM8OLiK +I7fj1LDCjrGaxHNjJ9BdjtpTOtwUP4jQoNKQJCpIuISYtJC7kBvItv3hvKc8z0LiQPy v29A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=LZxv/fjnbPf6KZ0JZ1AqKKi4lUEd1VzFo1FvdKHkG/wiNYJhSzfQeHH8xw3mTb5WYi 8ik0/fiWvd7aa3ttFDq0gkORjiTvWKtUsZR91/0z2OHvSAVt6xsxTjGpXxRMUuQoSefA TMQuP452bHXvlz+12dgAB7sZR0bEqmGyZNYjT8qAGg+6xgoIvqxkcnBcN9PwqHkoOevl Rdvh6NOiO7rrF4g9xhSWsrg3phQ9aAA9zOFPNGMRhphcfeCpy2a64PaUK1pEY8xH85zi 39b4gzuhUJwTXsnbUdyZSxsVJHn0pwzwr4H0E2pjD1oomiragiHCq7INBiZqQMgj0f+L thRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="bG1t/h0G"; 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 v62sor1957614pgd.23.2018.12.06.10.40.52 for (Google Transport Security); Thu, 06 Dec 2018 10:40:52 -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="bG1t/h0G"; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=HbjeRliO+vM5aLRxbYChK+9NDy/qsrTu+jTUTd4ZwgM=; b=bG1t/h0G7HsmA8R+Dyhl/GxN0xwqpb0yRUvCY5ZAei4St/imeZmfW5xzHWeExs79G7 3ipntKMO3eRjL4zxGs7HpMj+sgWx8f7Gkhdo19zA8gGWXe9Xe+RQ9hP5SVTQLc8v6R1R 2eiOfvElsrx4gWkx12UCqMOmn3x3x3c1FdSh0sJm+U9096poTqhv72EonZtd1mNXGjBc 7Xawu+wvgf48R9y35/7UxQRHCqNgJbERrTZJrK5N+bL5DJP0YxfYek6wFkK+PV1wVxjf 2Zc2+79sZCqXcDhJGRPyZCa08FJ3rUFPZE1tU+sKxD+Pzfaek2tNq5FLPuk6ZjWdENPM dq3w== X-Google-Smtp-Source: AFSGD/WLGphCOCPH36gfYZkaZrYNW1GtPiXDD9WUqhjHZb9vQUpQfm9+hBvkksnAYbZQwgNgM6d5hw== X-Received: by 2002:a65:6491:: with SMTP id e17mr24801379pgv.418.1544121651571; Thu, 06 Dec 2018 10:40:51 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id y6sm1602250pfd.104.2018.12.06.10.40.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:40:50 -0800 (PST) Date: Fri, 7 Dec 2018 00:14:38 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181206184438.GA31370@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 Thu Dec 6 18:45:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716631 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 826E818B8 for ; Thu, 6 Dec 2018 18:42:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7284A2F15C for ; Thu, 6 Dec 2018 18:42:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 634CB2F17A; Thu, 6 Dec 2018 18:42:02 +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 EFD2B2F15C for ; Thu, 6 Dec 2018 18:42:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 313156B7B61; Thu, 6 Dec 2018 13:42:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3376B7B68; Thu, 6 Dec 2018 13:42:01 -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 18C716B7B69; Thu, 6 Dec 2018 13:42:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id C715B6B7B61 for ; Thu, 6 Dec 2018 13:42:00 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id i3so1027217pfj.4 for ; Thu, 06 Dec 2018 10:42:00 -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=QkAoEj0L9qsuE5G4ssoKQbBfw8UWUhYAoif7GyqYqTE=; b=T35X4nSjdOX03Zu6fmiki7uKyy1mCVbmJ0ZX7x162GOb7oYuQ4pnG2vkDnVAYiMdlT /RGgqc5+r3N6of3hBkflZwEFawGOeXEC1IRWN+bkZv+tU6SIewC618dPuOASQJkcq7ks jh8Ohkp6Cc827v59EjGzkqcQOor+XL9S6GuFp9H1S4Pm7sFIf6TSHoxd94fIpmbIt/WX Flj4Wm+PCSPtrlpFEIC9PmUfgR5ZF330kxGcgiY6LUfO0tl0dyiGUDlO5+c3qlOCUIYa jvyZGEeU4np87XLL5JTpqtIyTC7RoMS0OMcxaQzpZoYSjrey1dZWKgJivGClfkebUXD7 J+wA== X-Gm-Message-State: AA+aEWb3dS3uFlhCvaf075uim26DcyYld3X44R58epRS02pY10BmaYDT z7oufYMf+wAL25GZFzPXlaQfs9KNBbtdjmRPS76e9OvUAhrDQlUGJGU9IlJA6VhYeBRMAy6yCJo NEMAVJxnKAhBrGNCskmee2zFlddLYi9uslQopRNaIVLANRm2AgB2ujjy/yIv2py08h04XVFWUyQ 3INyW+uytEd3LR6af4euroQsp4CWVYPmXHGNv4EaTMfSlXQ885s263hArMyNZTKIyQmFEfUCON8 MTGKM+BdD0019rsB5PCOBhoyMtO2BikvrsRVjC3pHgRzdcsYS1trgpmiyO4X4PNE8Z2z/OQLkXH tUIGztQNPu1XzByItk+i8Z5HS4xyF3YojmyPud9cAW87FvUl3Lw4k+7HZUM6dDuSRGLDHV/P/cH R X-Received: by 2002:a62:d448:: with SMTP id u8mr21079444pfl.105.1544121720480; Thu, 06 Dec 2018 10:42:00 -0800 (PST) X-Received: by 2002:a62:d448:: with SMTP id u8mr21079424pfl.105.1544121719797; Thu, 06 Dec 2018 10:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121719; cv=none; d=google.com; s=arc-20160816; b=NDTIyxVnkvw7Ie9nwxf7Sc9hfIfzSucn6Mjy5fYhzYoU6mF4Mej/yoqvPmXiOFuDK9 gykm66QR1kbTmE+A4rW8G7HhW/PlIDnmb8QIOONgAZcU/C2t+Hr4cIp7evZ+fPfk5kU/ lofR22LS9CQYWyrFRVljLIomMJfW/pp5QXs9XZBdlulBN5+h0ERQaQZw6LvaldHiYxmd r63rurm33JBZRQYQA6rCUJsmpdFIxm5zHH7XVBljrWVQp2dLkZpnvD0U00pMCM4y7tm8 9l2EpUnzHUeVKYoHaM06YP0I9oWaocrxxkpd4JajU/Q9XvOeLZ4dZm2JhgFkGfd05EQ5 j0QQ== 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=QkAoEj0L9qsuE5G4ssoKQbBfw8UWUhYAoif7GyqYqTE=; b=F7ICcmU2HatxJfs3eVfvxazYOWTfBD4Rq9TNeunEzgCC65nGQyT403MEIoaFjHKc9q 66tU2sOy/JK0doP4z/BjmwsmkrSBkUjgQA+fsFp0IjFjrPWnhjEdjk2pUvp7nwW2pv2Y Bgb/pIZJFo6QIcMxrWCt4UI9nCBHvaElIPcA954KXXC0KHOLex1G/XU/m/ayUcLTwAWa q/IypyI486esllyC/2Y6ttlCTkr/J5i6f54Mh/5JsDe2PlwacWo3oeuAEp1PXot/BQ7/ Gll1iFF6ay/de7auSDUAsFJz6N1Hd7wucZ7cIHWf0geTTO9kEyABCF5oOuCgIAQrUjG4 rMfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gidEjeZS; 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 y17sor1811434pll.68.2018.12.06.10.41.59 for (Google Transport Security); Thu, 06 Dec 2018 10:41:59 -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=gidEjeZS; 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=QkAoEj0L9qsuE5G4ssoKQbBfw8UWUhYAoif7GyqYqTE=; b=gidEjeZSbgItFGgWuJFdFe/ifliMLckszZaKhuDF0zT/ioQ/oR6cL7ETSduh8Iu7Ik nS1fUixG86BlJLDTz1MwqqLTuw9w3Ln38dTpDkXEWmtIOCQex1iam9lHoAbBENd9Bj4N DB4oeLz+ZVvBocvnc+0Iff/c+zSLTVwDJQ7NTOSjuFH1bbVlk82jqaugJMfPoMbGvfTj gqJG68rpZMa6/x5sl++Db1yULJskHuJuSMOhe656RDv6HOhIt5hgIMwL+ZSAQfMvR9U0 U7FElxxBVFgtH/SYb7JK+Qwm/bqeDstaOWXtmI1Rw1ueeRLaDLZBGqHc8VtU4GDS3vRI RSzQ== X-Google-Smtp-Source: AFSGD/WPPXRIO+khmBGTNbV0MDnldPRG23ivTHyBZ4IX8eX79jqs4heYiOhzo6Y54/NC8l3kR3/n+w== X-Received: by 2002:a17:902:1105:: with SMTP id d5mr28133182pla.47.1544121719014; Thu, 06 Dec 2018 10:41:59 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id 184sm1407299pfe.106.2018.12.06.10.41.57 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:41:58 -0800 (PST) Date: Fri, 7 Dec 2018 00:15:45 +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 v3 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range Message-ID: <20181206184545.GA847@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..8d8255b 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);