From patchwork Mon Dec 24 13:20:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742251 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 C920513BF for ; Mon, 24 Dec 2018 13:16:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B375728AD4 for ; Mon, 24 Dec 2018 13:16:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A64B928AF8; Mon, 24 Dec 2018 13:16:39 +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 869AE28AD4 for ; Mon, 24 Dec 2018 13:16:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 859768E0003; Mon, 24 Dec 2018 08:16:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7EE6F8E0001; Mon, 24 Dec 2018 08:16:37 -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 6CFAA8E0003; Mon, 24 Dec 2018 08:16:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 2B9E18E0001 for ; Mon, 24 Dec 2018 08:16:37 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id 89so9892853ple.19 for ; Mon, 24 Dec 2018 05:16:37 -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=OI7AC1OB4mJtuvTM2odPIGkLM/Rzox1MQFTxVOwIQxzbsJ+8pzjzKOzw38kuqDGS9H Yc1Uazb61alQAOCvVzCJ3jy8aRT+uoRAl0lO/armTCJybgdbCrfeI5ARvtM08oEB8hU2 vw9Z+P+z1uW3XyCciU8wNbHXG10ewfyz4DacInY3rHQ8awBLdTfFNGghdRRBrK6zJsk9 B6qHMXRl4NxaSX+DicW0ALeZCcXJLhGuW608KBwAajiaKVM/R+r1vGIzoqhsyPilz1lB 8oTY5lmdyGwSW7GUOZMbnnnbi+ubQflma/0GJzTv+VmDip/LQZqOSmWj6Jjz3fof2fL/ Qpng== X-Gm-Message-State: AA+aEWYW0p2a4oTxCKBs83uX7/pT/YY+Pbd6j+vR00PopdLTgy5jcN4C Df4+64Uq6B7NwfxiLTMsJTo0gUWh6uqODsjZkZhswc2TZsA0m/JR6cB8PzvczmVCnVNr1cde/6P M13lTQQEYaIdcaC96Bb/dz9iqrf8A3+ESuwt4d+6kHhOwfcejoOsarOrwM/8las0STSOnjgC6yH 3yLt9lgudQ1IQuIFrU2zDj9TLcVuPF30HwMR+NL9OkkUGO1RZGesTZacPIehbmthnpiMsKYxzON 5dkMcKpxu2W2rB5oPobLQO3NLSGje05opJdJCqVh5C0mNjx2LvKF++9O3u7TyHqpEWson9GmP8g mtwehLexUO1520Sk9QK2HqMnvsBDUYgJnpd610hYYJGM/5axdv+jqIpdFODMosbm9QGZAF6DyoI u X-Received: by 2002:a62:7086:: with SMTP id l128mr13049120pfc.68.1545657396765; Mon, 24 Dec 2018 05:16:36 -0800 (PST) X-Received: by 2002:a62:7086:: with SMTP id l128mr13049064pfc.68.1545657395892; Mon, 24 Dec 2018 05:16:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657395; cv=none; d=google.com; s=arc-20160816; b=z/XXZxpPuTEnbzp9ediOWO+KWenjRNGmUpGyzUgYF7kVBVhdUHNsuhCg5zka7xLRZu mvuV0SVzW1OL4JZnT5VLFYtNJmeldE4UwLSV1kLYGcfGghcobkDzxvmsYDBxNqxzuyNd g5TOfR68+EVEr0DIeXb+HXw5RiUPqyCL5UDAtZtOgf/nf3fqCxQ+G1yiee8mTkDpesSw 8+1BklUL6em2cQk+M0Z/EZCi6731Nl1AQyEzjw3M+KgxrLEeB83Ca5vTl2UKwml8Wy7G HgFKYp0XrrzkNOzUpywZ68pvAQkfZXLOCU4yutqJFszCcMriwtYkIGriNAay03GYRwfL J9JQ== 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=vTkOrxp3m0xQhaJqP8MFtSHFmh7QpsYrcWDCL5jQiIjRc31CGVFhLblwEOAZhdSGTl 9QxjOCef05tTfagPnwZz1IqBdRR9K544BCmRy9wVZdHkhGZ+Ch873SiZD0v9LL7Rx5iT PTyFTM9SJKMfajofvHHS6R+9KoRKlZ2Tss7ESAbMaw49PPbAMcekz3KxyXCu+pVWbIbQ 9OVEHpTmqYbmoueeVZeNDiSyQzNQafVHJcNNZtKPrJxbVj01kd5FCe7aqFOPQlSrQaSW n81J0EmgL3T0H0Uqx7hrDamktlnuzrWovxoYoZDMLBrQ0Tev9QJiTNYQHZa7b4zqucfR mFgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qM6wO8wX; 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 i37sor47053576plb.45.2018.12.24.05.16.35 for (Google Transport Security); Mon, 24 Dec 2018 05:16:35 -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=qM6wO8wX; 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=qM6wO8wXOsTCCQjmN5W2bh1Yc6f8aW1WDDjGj9PbWNWc2o79ATdhag+oaoZPNPzt6K ma0RAy9eFNdLoLaz9htzWNODQWdvDKW7joEPPAdI4N9ZNw04c82tpSKjho+qWDoRBeIH N1p9vHkj4DPmaFcBQk35HegJ83jO83edL9GgOg2ErX3ZZ+XvYXqoDlEmwPT6wa3imIT0 T1nCoqL5yFy5XNreHjeoMzrX+u5MwKvIQ8ttnzIFgFzU52htaKbK9ggMZ02hlyAc4nzQ IqLSm1jXGOTu+uTZeYmteZ8VUjbr6oMUx31ohJHf9UUTLFfcMN9bGnJn5P9wRpIyKK87 nFGA== X-Google-Smtp-Source: ALg8bN7wOSrZcfXhzYNZV0rUN+/7d8bG9BYL8F6X7CbsAJiBB+mCxvpTDoGJWLYuM5s39NiTv+v4ng== X-Received: by 2002:a17:902:4025:: with SMTP id b34mr13074182pld.181.1545657395486; Mon, 24 Dec 2018 05:16:35 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id n22sm59491886pfh.166.2018.12.24.05.16.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:16:34 -0800 (PST) Date: Mon, 24 Dec 2018 18:50:31 +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 v5 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181224132031.GA22051@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 24 13:21:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742259 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 8AE5F13BF for ; Mon, 24 Dec 2018 13:17:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75B1428AAF for ; Mon, 24 Dec 2018 13:17:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66FCF28AD4; Mon, 24 Dec 2018 13:17:50 +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 3915C28AAF for ; Mon, 24 Dec 2018 13:17:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60DCE8E0004; Mon, 24 Dec 2018 08:17:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5BC938E0001; Mon, 24 Dec 2018 08:17:48 -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 4ADD18E0004; Mon, 24 Dec 2018 08:17:48 -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 081328E0001 for ; Mon, 24 Dec 2018 08:17:48 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id e89so12400253pfb.17 for ; Mon, 24 Dec 2018 05:17:48 -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=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=iVkb/jNCs6s1nqC7HoBfHu4L6SqOK+5ReEiKlQXlW2IZGNQnZsX/cuM66wa4xYJMOR 15VQRpmLo7bL/meQalKnifXLN7+e9hXqo+XD6Rsqg64FGkQ/ab1IEKxMZThwB/5DeHuE gh0R3HAngRFqW8OZXCc07aMfdOh077i3te1Nd5I2qZfJ9IoBZN6jRh53TvOLiuUkpWcI fkX3OTX7DW/CXwu9mbR8sxwHJhUkfsyC7T7PTXfUXPN7KjEt3gQchnVHlOZ7A8ftps05 5FJVzYlB2e/HUNZ1PcjGPcfEUTVjIUx4JwsJ73EzH/Z64dVd2xRA/lR28WpQKfoajmna Iqmg== X-Gm-Message-State: AJcUukfO+49A5VW5hglQRj5q2G9iyKquqCXN3lWsOwsA/yCaKBknNDy9 X2rPjgEQrLLykDKFecj57LCF8dCXDBd7PIGrxZkkF4TaG3sLSD39f52X4ImlUejAhxpD8BvzzP3 FihGIi2IvbndpJ37hZn35E1MGv4voDXNgfKmuUstrJXhzYgod/u2EyEmHTvyZHd+bs1IZytz/K9 qPWN13u6O+2KBN14ROJ61UOy8yvdS9DqhXzKHt4muSJT9LMcYB2qBiT5Qz2pRH/4lBGcSPQkWGq 938G7JDrkBYJIpY2cu5aRNSEHE5cE3psiJDxvcF8iFuUPfWgR3gZ6m2gusowOHT8RcSauoGpmBI QnC3O5xWRjxDeZkfXpg+Be8SILOutzzlvd9GVNbalGWR587yg7rUFcTzOj9kESus8ejbTt1oeGB 5 X-Received: by 2002:a63:235f:: with SMTP id u31mr12300708pgm.122.1545657467707; Mon, 24 Dec 2018 05:17:47 -0800 (PST) X-Received: by 2002:a63:235f:: with SMTP id u31mr12300667pgm.122.1545657467016; Mon, 24 Dec 2018 05:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657466; cv=none; d=google.com; s=arc-20160816; b=RqZO6k7PLxRLUuqzMouEayrVEYiXc3hHw/gNWpmwZO7/Lz/Mz/PP3fIsN9iHXFNzDC YswaXGSPYW1ma4/qZgiMphFmyLZG1hEi9PtnqM9lmRoH5nKxHsHYs1RCDu/cn8ZEE7Jf msSRATAnU2rA0vcOe198jVYhXaWSMyUDJsd+x0q+bUPwHJTmih+hF/6Q+bv8Vj7fb6uG OL1bHk+NrbXhRMXD+QDrXt9wNzK3xGRBUBZrGnZ2rjaUcrKVKY2kSXl6o3CLnlVXIMqB 5WRLBOHJrLVTttrLaXYBGNpLpsROwX1J0+ekQteXO4IskahVbH6qatFVT2yhegTxlU+Y lzOw== 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=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=wYNbxENAB6DOUqMXLnJlMCUSFIT2476tJrY2wE13GSt2RbQuI9VtCFvnualo6g6NI3 mIdtISoS2C3OHjQc7QuskBMYnS9FoAM/OGrdaORo4m+dT1t45IOJAMmhUSOR0gzqNfJD MWmJbrk6IaafUWA71aPvmKIeZ3BO31WkJBCDWr0ZuxdLtK0HOfyODn/80yPeG+7+8Jl4 L48MeI+qYD3pXNZfC6c9wNv2GOj9PiEn2p/oWHzLCHOw8xJjaR2VqXoXGKYE0yqyOOSQ 22mmh5Ci+EzXtZtpPa4CH6Vbx+2BenybMoC3R612+Al6eA+2G2ye7jRpsXpT1qX/IRTu YfxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i2KO5MMx; 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 v28sor52754443pfk.14.2018.12.24.05.17.46 for (Google Transport Security); Mon, 24 Dec 2018 05:17:46 -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=i2KO5MMx; 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=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=i2KO5MMxJo3/5LWrPLeNLGeva3Ne1DqGYNQmkVfffqJy/7Blwc1ZQTxF5q7/4cdbVK vIexInnWRoT/V11j7MMRf8p2pNk7N6+FKaVdWJPsVT0PJ7MRGJWCmKDRYYVgzm9PVFZR 7Kz4JADaRzoTvV+K+ajZHPtgb0txgVU5jA3CliuIeqyf9MC+6XxOOcepTV0uLQH9GDeU B5bw7Mj0iLy6LrkPqE9j4pev1wfm6d67jrKNbReUFngf1M0upuqrGUYdICcRDO0tsAEw f+JmsDBaFgTBiSI+JannbW3PzQBDJacAB8VRitF1ub03PgJ8p0gttKrXb8wKIRMKAK35 /Ikg== X-Google-Smtp-Source: AFSGD/UmasEKtYGJVvYE7ECLRPqA3+g1rUsYqcP4hh5vWWnPBQkurqM+K4wJcBIT4twxElNbufrYjA== X-Received: by 2002:a62:e0d8:: with SMTP id d85mr12901342pfm.214.1545657466691; Mon, 24 Dec 2018 05:17:46 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id c23sm39254231pfi.83.2018.12.24.05.17.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:17:45 -0800 (PST) Date: Mon, 24 Dec 2018 18:51:42 +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 v5 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181224132142.GA22070@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 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 661fe48..63467b6 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,11 +1582,12 @@ 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; @@ -1595,18 +1596,11 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma 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 24 13:22: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: 10742263 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 C247013BF for ; Mon, 24 Dec 2018 13:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFC6528AAF for ; Mon, 24 Dec 2018 13:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3D4828AF8; Mon, 24 Dec 2018 13:18:34 +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 35BCD28AAF for ; Mon, 24 Dec 2018 13:18:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60C848E0005; Mon, 24 Dec 2018 08:18:33 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5BC8D8E0001; Mon, 24 Dec 2018 08:18:33 -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 4AC178E0005; Mon, 24 Dec 2018 08:18:33 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 09AA38E0001 for ; Mon, 24 Dec 2018 08:18:33 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id d3so10746123pgv.23 for ; Mon, 24 Dec 2018 05:18:33 -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=ZIM5MSDax33D6hZ8+4fI9xIIJicRnVk6KFCcW2n1IZPq4zDrgJI6hgvx1mW5SD4afX jo9o70CrOxGISQKAZSZx8FQkgg751nvHTNokNRlexvwDbGOFoxNOLfpNatKzxpyDZxlX kz6mAqbz+J9cux0GlTT1hUeUeOUnuUzw5pXi/OeLrpBiba3m+/MPfEMX4O08c/EcqVmK Xg6oNBWlQBb2Z+nXUD+c3MFgcPjRVCk3C+2c4Vfw1BTb6coMw9as4sW/ZFZvb7ypPWEB EHFpizI+8QWcmeEvwsEFwNeYIBD9JTusy8ufAIGvtYm7bZbQ7R+KfkpxzKrWR0BSFVf9 3pTQ== X-Gm-Message-State: AJcUukditKsTub9U1KC66+9VmwYJwMzxYuOXfJflE+OFt/y5Dh5SuVVy KysYajNBZvxU3fFOuZxvfhE9lSvm31n+1rAQJkPIdIE07sWHivvFLsipAtlkT6QcPV+p3y35anU njHNh2PKQDiBFKhsfbjAD7mDIyUK+V7yAxFc3ONJ+WVCVv/mrNMNRSVlkSkvkOiz3TLl+uFu4I1 NLjYqkc7k6gIz9mGL5w93xdB4aXcxRtIzpGTdFdq0I3cdi5wVSLwEerlqiNfeTXArs5C7GsCFVW A47R8v/BSadXbBZUVc37GxdlcIJLQ3bRpvOIT6dRx0nxoMyGzf2bfFX3M2vt7uY2Iu/EyzmBkUu n6RwxhSlnJ3QXLRn/uoPrB76ozAd+2fOQC9yZgTTPrjfRUcbHEiTIyFu8dPZfR81Pd/OLGsSbjS x X-Received: by 2002:a62:1212:: with SMTP id a18mr13484982pfj.217.1545657512520; Mon, 24 Dec 2018 05:18:32 -0800 (PST) X-Received: by 2002:a62:1212:: with SMTP id a18mr13484931pfj.217.1545657511800; Mon, 24 Dec 2018 05:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657511; cv=none; d=google.com; s=arc-20160816; b=B7sgn1E9N9vEsVi0O13ZbXE70s19fE5hyzsoauXeqq9d4EpjkfCXb5OKvIu20YDKJV QZQ5RiETy9l1qqLu3XoHIz3S/QOPldPCBuIvAAXX4hvaZEdFh8FGAUDdb2QkN6cOFns4 6RVxgfEA2+vR73vi4zA+feDFzh6edroADzHOIniPRQce09dbSUeZC1t7doQMUiQPJLIo 97OVryQWA82RY75SWc9cqS9Xbep4EIUB3gjC/5OHXppAyhKEjajcIS27Bz7Mq+My44tC J98J71BJrWvGQ72Gkh+Zs4VOsgDmxWBVG+/WB1kp2IaoqjSym6mgnIO3rIj9MPJEWAcK mOxQ== 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=xJHHYS6xvhXPuqJkndVF2XCZeOq2Ghe2FmYAvUSKtpT3M8U6VOIAL8YJyNjCj8lMvK jW1LdZGvXo6Nvl1BAiQ4TfwBJQoDk+dz1e6x0DXVGermVcmM7z2wfCnrj+aGU48WxJNi 77o6rEJRdjLdSZM8ui/lDrK1d+703NgPUtBRoJ8NF6rj7SYpa9uuXSjpi8/pwxwbzIFO L3EPUfGpFntwMabkxbynAxXsjNk+SgRcNsMgwUkjfxIYkWr1fFRbButrc+f67jqoeerS 5PADUApKo4YQm7LsRDJap7+LA+/B9eo2uS+4kuv+6H9BHd+GY9Hl6szAGz3BrAbc0a58 saHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TD45kp+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 y8sor48149385plr.42.2018.12.24.05.18.31 for (Google Transport Security); Mon, 24 Dec 2018 05:18:31 -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=TD45kp+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=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=TD45kp+Toiz0zyzHxRUMulEByoStvt6ALI4SRmA3r7+UR6vf1Fv9a5JZlAX5TD1VXN uySrs+KKlKj6AILhcxkzINzdziuX5bcL2X/eIZv1ApoknaBxtC0iQ+dScI6QyWwvgG9A KWU48g1Gzfc82fpG+paZm07hduVR+l1LiSnXUyIrBafxPSynW7LPdl8bhdzMYq/4AeCK OdyaoSSvevrLr/uRnMFcP5ABeJIURBQ3dcRXX9+4yECKcyCXvhymfBQVwrUDrubsv/sn T+AXjPEGV5m+ZsjztLaTPuh8na33XnafrsLskOheO2KRZnyIBRfgSSuM6Pn95LfGvPeR 06SA== X-Google-Smtp-Source: ALg8bN4XK5L89IhWFZWeXxyCo+XDDhmG6v7dUoEX5qNfkascP5MGDznUdyua+AHQOE+3TD6j5/G3fA== X-Received: by 2002:a17:902:8ec8:: with SMTP id x8mr13070446plo.210.1545657511512; Mon, 24 Dec 2018 05:18:31 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id k14sm58126547pgs.52.2018.12.24.05.18.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:18:30 -0800 (PST) Date: Mon, 24 Dec 2018 18:52:27 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, stefanr@s5r6.in-berlin.de, linux@armlinux.org.uk, robin.murphy@arm.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net Subject: [PATCH v5 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181224132227.GA22096@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 24 13:23:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742267 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 4D97817FB for ; Mon, 24 Dec 2018 13:19:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39A132877B for ; Mon, 24 Dec 2018 13:19:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D66B28A29; Mon, 24 Dec 2018 13:19:52 +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 B95602877B for ; Mon, 24 Dec 2018 13:19:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D11608E0006; Mon, 24 Dec 2018 08:19:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C99858E0001; Mon, 24 Dec 2018 08:19:50 -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 B621D8E0006; Mon, 24 Dec 2018 08:19:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 6AE3F8E0001 for ; Mon, 24 Dec 2018 08:19:50 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id o9so10793865pgv.19 for ; Mon, 24 Dec 2018 05:19:50 -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=ta45jCjTTw9h608mLSaRumjRsUxHErr+7YYhcRdk80Q=; b=QnG5rUSJlSLEzHxk3vbtIwvAikFxODlkZDd86GjrDrfJKP1noNTMhKG1g+SbC5Sy3m RO3b8t132JXMjAh9NRda1E+u00pFVGN4OwEyjC0G0++GjgEiPYXbUJ9fIBMo8wtq76m6 zh/ccr86b1zCLhZug6iMTgI1i7tm+FCA5YnJiLex1Lepa4IlKuRRgQvtPLaoZXpbrv4l ghspGC7AI1+VQcphY3ruFGlzQck3CFHoOG3rqv2jpQ1qkmVt9ijbXGTCs2t1PlNg6M4m g1Uq0/x/rUY+5H8h6Ed6piYr71qXPHi8Nni+gEeIym1E8hCgqeFFq/R2prwuU38R8DDI FBZQ== X-Gm-Message-State: AJcUukeUPoJdrvpwg3wVySfFnkJMmlsNK6zH8+9z+b3VZHB2p6tAfhqp dEA6XmkL0zX9JlJWyL/gF61NZvqN/PnoRm0HkljYWe54N2VlRcyooM62DtdtGtupFTZWLzj+B6I 4RPGgqTqyukI54lizYpshddOEI224/ZKflEZuSt6BL0ui4zJBRmhD/2AnVArACqCXAC07PkDzal KImxCcf8s67n059Y11tpD0sjL+7eEYpX5GSz15KVhrkHMYzIBBrFQRv0IOP4kM31vMF7To8URo5 UXSc1hyHGAVi+1tlNB9U9rbXklMH/udmzZToWt1noR6VO2d1dBs+i5YEyF2nbWzTlH+080B7Ggp nzdulHe6vs4aZrU//rYI5s4nvQ/ommPOwoVgZUjxOyTOaCDMy0aIfNa7/gRDvPkInL++BvjKvLt 3 X-Received: by 2002:a17:902:1102:: with SMTP id d2mr13044658pla.138.1545657590114; Mon, 24 Dec 2018 05:19:50 -0800 (PST) X-Received: by 2002:a17:902:1102:: with SMTP id d2mr13044624pla.138.1545657589472; Mon, 24 Dec 2018 05:19:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657589; cv=none; d=google.com; s=arc-20160816; b=PUeOZADbrloNNN/kzD6VVe9I/YgGRXDd3qnFK4gPQnhyh7wpLyWNKRtaOalBYfiMlt TI0ptjFKiXGYGlcjtkgwwkC5Tsm5PkNwMsytlm94JBc1324fWYH/e7J63JpzMAW0uS8s /H1BFPPN+noWUcS9B0IhtrsuLLlGkknr3sXuJa0h288Yl6qADcf5Cnq3oVyzEFx57zpr LEUOhUQwuFlweoCTpRQqDCXIoZFyRer6fScsrg69l/Mo4qH3FzoLb9FMyZMLwJpKQ04j u3G0KcBf4w+y6rMtIM680lQ2V2UNUykEsVWkSbmtQCD0H8dBogxvnYRi4X1NEERzaorY dNYg== 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=ta45jCjTTw9h608mLSaRumjRsUxHErr+7YYhcRdk80Q=; b=MUj9mE9JjuZ2G4Xq0AieRM2aTm/jLEtnCfKRRYgVDPA9EsGi+fyLVByhKYTKfzOBKZ 87BsOGxvPRFyklOtSqO+szrtDa7LDLuRmt9q5enWarsPiV2pAtwriM4HLq47Exh83ELH k1wauCMYGBL6Wok4n9iS56LQvAPD9byIaXF6xkAhAR2SeX3u3WvmCNDuwwlDg8Q+3XyY oHmWOZEY4rzebo8A86PKlmKBsh8x0EXYoKfecGA2PWRlI7t9+dXAZsRqAIBkopdDUhK8 L/7mB4l1lqZBpkIfvHAgvVtWRrC0fCSEWfURryuFWoPgBxEP0QjqOkVtMDdDyCWWem8e WkMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bZlLJOIm; 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 p18sor50649233pgl.33.2018.12.24.05.19.49 for (Google Transport Security); Mon, 24 Dec 2018 05:19:49 -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=bZlLJOIm; 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=ta45jCjTTw9h608mLSaRumjRsUxHErr+7YYhcRdk80Q=; b=bZlLJOImO/1bupplpSBgyvMTMpxNs0KKCyh9eTwdH+0uwPXfvhWmQ2pAF8DBwsk9Rh bUzZMgNq5nuyQY4GhD3gBu+bVpcBE11KxlyMH4e4GZcPAfuh33MQNhj1AdFZ3jCDGO80 pw0nh5Zx//0/hc8/8FFns4JVjWJHJEPmTg/eT1k0ZUpBl00xFnUcKdIg5f+PdxVKKQa5 FCwYRtJKVzzaeQlNqWS4BSXGJQUhPC21z/MJEvaiy2M9oJNQzcrFQKX4+e8lpIRSzbhj CXPgWhP0XbFWNCAtL9bP3cJwnXoT0RpNFDimxMCjz/XJnM+Mzti5wvF9ze4fxY1gPbV3 yV9A== X-Google-Smtp-Source: ALg8bN5WlOmqbcy4mwSttJzqAgLDaKxP0MsWaY4oRqlS6nY5gpEXpC5t31E85FE+ygzeYcDzQuE9IQ== X-Received: by 2002:a63:db48:: with SMTP id x8mr11898908pgi.365.1545657589149; Mon, 24 Dec 2018 05:19:49 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id s9sm42516339pgl.88.2018.12.24.05.19.47 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:19:48 -0800 (PST) Date: Mon, 24 Dec 2018 18:53:40 +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, linux@armlinux.org.uk, robin.murphy@arm.com 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 v5 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181224132340.GA22112@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 | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..28458ae 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,18 @@ 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 int 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); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj, From patchwork Mon Dec 24 13:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742273 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 16B2114E2 for ; Mon, 24 Dec 2018 13:21:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A9A28AD2 for ; Mon, 24 Dec 2018 13:21:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBED028AD6; Mon, 24 Dec 2018 13: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 8B61128AD2 for ; Mon, 24 Dec 2018 13:21:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9411A8E0007; Mon, 24 Dec 2018 08:20:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C7D48E0001; Mon, 24 Dec 2018 08:20: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 76A6E8E0007; Mon, 24 Dec 2018 08:20:59 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 2FC6D8E0001 for ; Mon, 24 Dec 2018 08:20:59 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id v2so9921982plg.6 for ; Mon, 24 Dec 2018 05:20:59 -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=GnxkUDCIlwXqpumvz+CfY+E2zSS1N59QevbKBf2LVD+8G+AbY8029DopF/hmKARtrs R32Zwp3WnWXVta2nkRDg+wvdfmad+6sFnh2VRZlNxRWmxHXL0McQhUhHRFEvpU+831AQ D40jl8geqNHI7h5ayw6x/22xhocrbppCARHAmPd+69Xw5cRb9jGQ9ZZttc69vtJATAM7 1OeFSz8bQIX9XncNhmfR4WHq/NAUdXZNR22ofw6ygDhTKtCqUxBjCPeml496mzjoQzOk J1m75WkHDEu3zNHJJvh6vhmiv6vR80TIuS7q2FgiQamLWpGwndp3ZyOAwhQOasYXsky1 oR6Q== X-Gm-Message-State: AJcUukefgtw/nmmCzuuKZK69QsfZPW6QDWCehmDN4B8pvaH8GjznUgAd KDL0qVgsZqffTxtJluFUNGPKjENaw4TH3ezqFS2grgXJPgxyK568rNphXCG6Y/QlNceSgOXgP7W 3VWICafGVskIzRv8oK6EGmFy7beKaRHe6uZA8GA4+6oxnoHHrtOTOzur/Vp4ZjzAyQVDTXig6nR dYPuAe7D8ataKTNyx8C7s1JGKN208sgQ1fH0BL4QjB3FWvAbTc19XjHeowhZp6lJiSxkn2mLe34 Yk46WIYMXXXcQSTE5NdvnBfWA1fL1ju+q51Wqka+OEYU2GDWhXmgWBvuhltu0IJ7WT4R+x5YpMD NBxrlHw4pdkDG1PAAN8H521wlr3gzUntQqSEJB56xnvCVcZIiq0dqbzr54SgyegfR5bQIzFGyZZ s X-Received: by 2002:a63:b649:: with SMTP id v9mr12368551pgt.436.1545657658878; Mon, 24 Dec 2018 05:20:58 -0800 (PST) X-Received: by 2002:a63:b649:: with SMTP id v9mr12368516pgt.436.1545657658181; Mon, 24 Dec 2018 05:20:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657658; cv=none; d=google.com; s=arc-20160816; b=ZgM15I4tgLpq00JOrvE9wq32XViS71SGGw0fkAzQonnTiQc4ilH5QSYOZUBKNQ1oUs 190XmCXsqFB2mVN/UvoQFuA/AH5vXQcYulda+T+8yXFnDVDScNXvC2TWLAj+KRfc+Jzw o8xdf0QrNy21woQdup/cQFpGEq9mTHMy0JVbO10xy5Aci/bxuRN+93L+Znq0HfpDuJNf dHenIU9USsq6ULSfc+lDAXC63x7S/A8siWKHytb61cI4A4S2rwUjtwpI6D0Iake/mw1e CqMUy7wzfkRF8A/IbNTDe1kpYauW711lu7tzFsClOARvKQIv0cBItCG+m0NhbwgLOzSi j9yw== 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=ZkIpSvZd3GogixalcVHylENrfeNb67C6fu3MbUFmfJ2bPxYtqI8Pgg5/QCsopcTJ83 y+5Jwncq+oqY1AyrROXxMpTQaeYcDIRZb8MSOpbosurnfQ9CiMn6H6m893TqZiQHnI6n e+X29cIg0TBWbxrTUYSBLrwXttDlBcAauOPDja8XRG5lE5KjDci8Vh5s6KzA8khKJSzs Rrk2j1YPuH2TyyFb/Vm3fHFULEpnZG5LkcJpmPrK4eRW4PKtPi3Nc4AbsiYCLmzlwix9 Lco0D1hV0l3AvDEPviGapSCJQk175odFIlFH+4Ud/R+h631lCe6WC+NGrm7ct5noBRFY 1bsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="CUnAh/Rq"; 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 23sor51720325pfr.25.2018.12.24.05.20.58 for (Google Transport Security); Mon, 24 Dec 2018 05:20:58 -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="CUnAh/Rq"; 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=CUnAh/Rqve+lXu2kbGyo9bkEQtyA5AD0Ti2n6JA3IoBI/ZQ2YxAVlgC5u47FeQQMhn RpjsyPtlNuUeBZsoZ+4VsJYM9iGoFNhhpJn2J68frv2rKaaO0T0uYDo2Sj+NUpduPHzm EgtQ1QgTv89NIcvJAt/gcyrEod5yHLdsLtYUsZaZpo25zf5zGahIyOpp2kMc5TgdpRt8 nKZrw+ux+pYMX7mul836T5MMdBuL4Kvuy3Nh05KJbMHRyYflMaTF53Q70EqkpjhsZmfa 17K6i6wlPIIC5zVJ30t12v5tkCWaDvMmkBB1Kla3Tlld8MXLACGIePanxTtvXoop3ANE 8tQg== X-Google-Smtp-Source: ALg8bN5/gh7iKSFeVbCDxnlm68Sjq9dvwVK/fGxmQ8vvM0+wZbEa4aML94BwBBLnwyDRbrgezk3ImQ== X-Received: by 2002:a62:c185:: with SMTP id i127mr620171pfg.43.1545657657811; Mon, 24 Dec 2018 05:20:57 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id 84sm87589245pfa.115.2018.12.24.05.20.56 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:20:56 -0800 (PST) Date: Mon, 24 Dec 2018 18:54:53 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, oleksandr_andrushchenko@epam.com, airlied@linux.ie, linux@armlinux.org.uk, robin.murphy@arm.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xen.org Subject: [PATCH v5 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range Message-ID: <20181224132453.GA22132@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 24 13:25:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742275 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 CC8D113B5 for ; Mon, 24 Dec 2018 13:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6CFB28AAF for ; Mon, 24 Dec 2018 13:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A74CE28AD4; Mon, 24 Dec 2018 13:21: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 5C73028AAF for ; Mon, 24 Dec 2018 13:21:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 681188E0008; Mon, 24 Dec 2018 08:21:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 62E9B8E0001; Mon, 24 Dec 2018 08:21: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 4D13B8E0008; Mon, 24 Dec 2018 08:21:41 -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 061A98E0001 for ; Mon, 24 Dec 2018 08:21:41 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id r16so10809256pgr.15 for ; Mon, 24 Dec 2018 05:21:40 -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=nK8Y9dXyi1DKpBb16BHEVmawNtbVvi2hjDwPvjbecflXmL/8Npopd7H1DwNUBiWsXL Vlc15qy7Rth1Jn93xuS1Xoc6RVJkWvJPcS7rqvtU7MOm+ee0h4zHwoJOAgnHaFKxvt2C HZQqK0J7HmxP2xuVfym6At6qMkx9PYiDZhcOXIVcyHphxAzEPg7ADqV2nwXKv826CDf9 jFci2jI/o48cVHYkNQGv0NpTa0uu5qumhJMmWiVhGDTrasBga51D6+iV4xWkSVIfTljR fiqiWkyO92A8quHMen6uiPL94znrY3srR92JoC7MPWK/ixVRzqotuetKG9LZ1bp2Bchq YPlg== X-Gm-Message-State: AJcUukeS0bApYJSuYs5IfcBCZp/VkIqxqvsvVxGpHl16Vagbr8O/AK28 e7Xm7LWiI/aJsBvgTpvS6O5EDlYxCqLwf7R0wq4/98n8AgttMzODff3fIFu5a3PKQE5WHEzPrw4 Sp/wwf6j7Jce4nGE/dTV/v3igf57aFcFZkubvglUSvHV9bQ4vZ8Px75EwOL8ie6xGXB60lXbLRA oGUhGntHRGPG4xavKYIYKQuJ3hZSpFCpkfR8GZd98fQgJAT6Sni5iksXTvil0U+1+ZLv3YIkDG+ s4dAdfai29gxcy9KRoh46o48vmTYvnnys8a4s4B3wtVGkqI2vjnR+JIXG1/XNcSNCqPzN0PkKSo AGr4ROgl4AuQ1D9tf3o2mhNfJTcL11b9c0hbdDqYTaiF8JiT0+nXqAYNNgvX+AktidrF+4+r4M8 q X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr12992563plb.169.1545657700714; Mon, 24 Dec 2018 05:21:40 -0800 (PST) X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr12992522plb.169.1545657700097; Mon, 24 Dec 2018 05:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657700; cv=none; d=google.com; s=arc-20160816; b=NYVPNX+AHYFD5uiBAlcDWO7RomLMWlxEb+En/iRFeFHuiwjTjJAn0eYJXC22y+KQtn cDUKKzREeCqQG8+DZSaxnY23qP0V93YA2qpyhgtWjdYN6kpq1mumRsbf02Q4PW5zblh3 NaKD527ePVMPQ/pjc6zXNBLoFJweWy15LhrEFFygkA651JrV6RqzbxdUC/gWFuVdn2GD YunRHzmBlTOrZh2APKFwSSDFmEkCi0o6nauG5XCoa5ADAwL54zzwaAlVDd7N/ns03GMr xQCpzIMNJX2XZIy6npkjJI7oiHDiDKJHWHZECV5yAyHYcKg/UkNGvnR1vmygaOxZtETU Hb0w== 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=YVnnLieCOfsmyOwxhiWvfBrlzOk9pV/2x+EEpNTj5wVTTr5vKhk6CrjUfaxKKAmM+K rOJ4ff9j2qNW06Yn3WiMU6Bj4q+/lVl+Dq3ZqsDOKmdVU3nKUS+694hpp/g0/rNS/3yO lPTVfsfr2XrWJsVBQrOWSG0YRp9oodOCuFkJIMlZKFeRkxMQ9jabOquhKlVJoOzDUxEc 3G1jWzlOKnhG4CvQMA3N8DU+T4IhnimOUt4eLWO4e0FIu0DdINNjV9PjkF00mfUWg/Pz d86hj+oriqPGgOvP5FFjQol9qVMt+OALnasT3agCoY4ex7HebfQaULQF6zAXb0wHQ3tP wshQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CEHFTcrB; 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 v13sor50589385pgn.66.2018.12.24.05.21.39 for (Google Transport Security); Mon, 24 Dec 2018 05:21: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=CEHFTcrB; 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=CEHFTcrBkyeCWeCmPrwn2688YXOdYONJIrN0FDYedH3wOLlUMBEllDzlhZcd34fVTK PVN/K5qsz/SDWgrxoU447eNOJ+Uwup96nxoNgOgUlQOQ13YmehCBt15uIzwDcL834WB+ 1V2D5GZRCpWh5bWe3K+7fli2aLbfN7muPdbKp+K5klF2OAEPz3Omo3WxJVWH+iE0KYW+ WRM7Y7bB/2Q4e7scf8d2tc9sHWt7qho4T1VtjVba0K8NyB9RvGQ16XNaDLKLohjtuJ7W M/GFEzgPI0wWXk5qZ9aQAs0zJHqCzO/cRE/cf/TYZf3+d4QEtZJUwwgpGUr3zwext/hT 2vgQ== X-Google-Smtp-Source: ALg8bN7sI6Y4DpvdHRECfX2DJrfkjetdnJLz04OveHwsKqHkXorBy4SWhZzQ1kNDsKb748UfZoEkUA== X-Received: by 2002:a63:9712:: with SMTP id n18mr12115990pge.295.1545657699357; Mon, 24 Dec 2018 05:21:39 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id x3sm101389647pgt.45.2018.12.24.05.21.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:21:38 -0800 (PST) Date: Mon, 24 Dec 2018 18:55:31 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, joro@8bytes.org, linux@armlinux.org.uk, robin.murphy@arm.com Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v5 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181224132531.GA22150@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 24 13:26:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742279 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 5C13E13B5 for ; Mon, 24 Dec 2018 13:23:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A38128AAF for ; Mon, 24 Dec 2018 13:23:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E54F28AD4; Mon, 24 Dec 2018 13:23:10 +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 9320228AAF for ; Mon, 24 Dec 2018 13:23:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9E168E0009; Mon, 24 Dec 2018 08:23:08 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A73B98E0001; Mon, 24 Dec 2018 08:23:08 -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 93C658E0009; Mon, 24 Dec 2018 08:23:08 -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 4E15B8E0001 for ; Mon, 24 Dec 2018 08:23:08 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id 82so12441872pfs.20 for ; Mon, 24 Dec 2018 05:23:08 -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=dSPE2fx6LTi7nCH6/U0YftMlXEEIFV7POPfBX+YHZyaBdayjXJrHhH/9KhSwsx2yPX 7BF1ZFJhdFFRnKzcO0Bg+o/73BzbW+wbWBo098s7FLYbFs3hpv9NCgK0eyDUH3DlJ6fX z9B+r+4QuEheGycfvnGtPsvaDje0d2I++Gvq+yLF8K2cDcnsmRZMwY/5O3CHUqjaMfgm E9FQJCW6RJQLhv3NgKIgEDShyl8gcsGYrYqEanwD9BIW48rC3WYJ2oy6rteYrbqcKa8y t6fSxw2PCaFLIGTf3wEjSIrmEYmPjXYtelhkqm22C58/wiJmZVlBdR9oNSduyy6Q2oW5 /kDg== X-Gm-Message-State: AA+aEWZzOF0S+snBlcopWD7148hIJpDWgw2lPzxPVKRR1uaFFkaQoeSZ z6j3oSHZTJ4hpqT14EJVSjdTNSV9BXGLJBMRyRWt3Bcj2jkT2UYztLhCo/21koY5NA3i0qhCCft yq2MvyT+jI0Da4U0idRQNKLvia8njh57w/l/ZU/XLihqgH7r7d3MFMx4R8GKYg6Y7IXfIbXZz7Y ukJmpttrwk1jzE/aox8d2jay/eiejAjNh+Y4nnwkhSUCLIJxW8vjoLw2c1i4dNb9J7MzIa++DCS gH96S8TyBxAinLlvOB5AL4uRhp356lgHSULxjvvArjp4tW/Yci3m2qCynjZncrE4K7GKOWK7GYF TR65nNYQGVAzx2USEHjqHt3BG/XYOHdXFC50r15DfVNcFVqCDQkMsPZaVHr+SsvNRhMLQziN3l8 I X-Received: by 2002:a62:31c1:: with SMTP id x184mr13505280pfx.204.1545657787869; Mon, 24 Dec 2018 05:23:07 -0800 (PST) X-Received: by 2002:a62:31c1:: with SMTP id x184mr13505246pfx.204.1545657787205; Mon, 24 Dec 2018 05:23:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657787; cv=none; d=google.com; s=arc-20160816; b=mniGNGOpYmhWhWEW6+aUZEa7PdaJx96Js3n/mEVtdsonF5Em/07a7FRzjHAERcMEDL kLzgeoHViRHMn03jUjKYKWYkYY/QwA65e4xzJ8pa7tklKWTQnjSZCc5o804R1aiIB25e GwzW+tg6XcgooTfC++YyVYRg4LqLHSeqr6KxoWXXKuAhHO7YDZRy6rAwPEGRdzEFZ0Wn HEXn5Ii/btzpgVdLKOzHe4uL2vpx4aDTjY0GE8lr0SCP4J6Q74XIQR7qJbrt66Hvg0GR lzB29ycE5jGRUqQpl5MJh+sewqkf9XH9u+0SSSf/6I9OYVRrfVed++nh4J9tLtuJWx33 /QpA== 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=kaKIaCDQd5SRB2L0bysSDQi69Uirsx+gMxwK1PmJj+9yVMGSBNhN2D77IM5q4q+yBC 0oW4sR9cqf0j1C9M4WVoSFQWygjvZqpB3HG+Y/XnDLS9RQ5NyP8E8BB4xSMFLrELMEok fgasagYbawGrPR2jL/Ueb3N0OeemPAROWgDZzCEl6HnnSgjZ81clYpllew82raGdJBIc Itr8tWgNgceh1EEoGKxf6jCk3Z8VtFuO9bvDPIb4F+rHxmOqmyiL77XIT/G/mJLMp86o 4UyMMLBcYpwx2WySAxcVnRXLEE1dzXKkEdDFv0UVtfoOgLtLn0ppRNnewG+Nv7STrsOL i+OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OUe2UBaI; 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 y17sor48007192pll.68.2018.12.24.05.23.07 for (Google Transport Security); Mon, 24 Dec 2018 05:23:07 -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=OUe2UBaI; 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=OUe2UBaIajVgiHJLICEiDaRmhg9kLK9hiO8qJEaN4rrxoH7k50qgnl6Wl+XySZ6A83 K1F8jaG9lYHSpu0zG42YwEpn+3YVl83fnNiLu4sAHKartC0Io7zN3jOBUYys/J2s1DAZ b0PemUtLvUPsZJ5WxS7a2Km1y+FbdYwd8Vqu1nOnq7zc0AYFm2cvML/bPUIVJE6z7kYI AarkWAB0WEA5VKCBss7dFq5ZPZq2mCmrnovbMMEXL5zRYsntVdEdUqvwab2ix4w5+GaZ lufgucxKqEtCZUxR5YLGIYS/gi5CtHr7q3PFICiRvdOSX2NGp352oE4H40jHM582Ec4m GYGg== X-Google-Smtp-Source: ALg8bN5kc/0nicwedA6pXaMV79OMWDwnVCptGPVVG8nZTTXxzJdQVTtTwoK88u8a5GB5BsbXczYDpg== X-Received: by 2002:a17:902:4401:: with SMTP id k1mr13003110pld.307.1545657786489; Mon, 24 Dec 2018 05:23:06 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id x3sm101409071pgt.45.2018.12.24.05.23.05 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:23:05 -0800 (PST) Date: Mon, 24 Dec 2018 18:56:58 +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, linux@armlinux.org.uk, robin.murphy@arm.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v5 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range Message-ID: <20181224132658.GA22166@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 24 13:27:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10742283 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 CA06414E2 for ; Mon, 24 Dec 2018 13:23:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4FD628AD4 for ; Mon, 24 Dec 2018 13:23:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A29C228AF8; Mon, 24 Dec 2018 13:23:59 +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 4277F28AD4 for ; Mon, 24 Dec 2018 13:23:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F77E8E000A; Mon, 24 Dec 2018 08:23:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A6368E0001; Mon, 24 Dec 2018 08:23: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 3987C8E000A; Mon, 24 Dec 2018 08:23:58 -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 EBA1E8E0001 for ; Mon, 24 Dec 2018 08:23:57 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id r13so10803596pgb.7 for ; Mon, 24 Dec 2018 05:23:57 -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=jg8S0iH/aHBhzsdmmwVJRrgdg20uG/+LiItjz6Uc6KLp5mIgrNDQheUhtbsWCICkau 6qV9A6MAP2mHnWwKS36vVaxtZ+cWyF/xHv5fPVmMPbJ8JSJOOiARPfuBn8xfEZqt3TzY 5/V4H/rMrU7yVqnR52CkD35cwqNEK8m7TY6PlV+ftT1vSurVcYfv9qzRYK+SJuHRPpsU Eok9et0OtfzCHKb/J6xFYaVK9q9mxP4h6WNJHXL+rUecW5lcFFK6GpmVViO85RKJoaKk ps/+/RrYyPPxeNYg3zCEUVPMpBmwTyaB78ibmrBjxuIA4ZyF/jsoGA/uDa4IPFDfUknh 040Q== X-Gm-Message-State: AA+aEWZgU68GbGU1DGo+wpuZYam/95gL9zMs5I3MWxSAEnjAbiXxz1S4 /cIcLtPjEZjUKOxIvJLc+3hhECblEw7awwIAp6yPq61chnX/TsTjdiTpWkH5Y3kFHKMCBrNLmYi H0ga9eZ8nGnj5e7DMmH9R7D2SyrwtdDpWFCGDBFy8vlAV6pu48RoLRUBC4bu5rmsRXNvlUEZFjT spm2DVc5yhxx7uM0GKFTsh2a8kmfZePZmzydXA8kCpBwgW4qmAU1gAZZMDOu/XwqaTzOTO2rGXX NvnVL9lfJ+65oSUK66SBo2BV1YjSpZWgZBQX0/y/JosWe6Xzt8fqp93G/s0MmzeVMaoKhpTHrXg 2CfMPD+gDTskZ+h48uGlFi2qNVaZRiQKR4NrWp4hQ995HRiUDN0AD3rD2G+5HAiNO6KA/i+atl7 u X-Received: by 2002:a62:6dc7:: with SMTP id i190mr13109291pfc.166.1545657837651; Mon, 24 Dec 2018 05:23:57 -0800 (PST) X-Received: by 2002:a62:6dc7:: with SMTP id i190mr13109252pfc.166.1545657837033; Mon, 24 Dec 2018 05:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657837; cv=none; d=google.com; s=arc-20160816; b=pnlkAA3cHvvOzU7z3DbAqIA9uwTenqwGYRSykDd3IGNfuB4TAxnBSxP0c4Jzy+so6a M5qKDRpOn35qMq+zA1bHi3g4364K1SFancv4UdYZY/JC5pDvTPUgCSbQ9wdToLzPkKBS vVCiQ+MiHWPl1vOEZoEF1FkIIIAVOTQBueu062hckwmj1VZonY9f8UkblUhCova2cgwO DziCiEGp7KcuypqrdpwU2aDf8ELSHiuPA+2/vrg23BaZ0PWfFkizcth16jTDe6FlxBN5 2sCKqGDzv7XNRhCZ1mW8QX++erI/KtQkXpDbVcnzYFHW92qJ3pHDKKDjk9Xg9ZsFGfpe udCw== 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=t1a4ipKWnFSQWoL8CzGMKQUKZ/MwmGLbxmvbjHa8O8gkbWEEDEir3K+mX1hCo/LcG4 ll10PMR0ZrOVGrKlucEl9T7Dn/FgeYFKOPwqeP2pCSZVe/BLGs4A8U4gQo9R4RhRo4On /aMjCJkQGjgKZeW/4ezjISnUTXfTglpbEpEv/kkLFuySTd0JNS1vxlFUJ0208AWk30/0 dIKKMYH5nWj85EmkIG9J/3bb7amcmYq80tpKTdLbCaWvr7bmO/lYIhqSoOC9Cu4HaTso tnQSsq+MfYsZsBQyJZOXLJTEjPxD8VbmsZit+nGjy3PaXhzmYCkudHfT7fntZN4qvHfP CE6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TRR1LFZv; 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 h2sor52849352pfj.47.2018.12.24.05.23.56 for (Google Transport Security); Mon, 24 Dec 2018 05:23: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=TRR1LFZv; 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=TRR1LFZv4DfYv/CLFab1H5gXj9FSE49ggM9pEjq+0mbLtB24XCJVWTEVNxu0Jr9jfP aXbKP2W1rQImrZhnsPScKg7NvHRhWsdijVauyLC8/q8oJt9aXNkvOTG+GaQHcE5pxbm6 /59fC4l6pTS+IZajcvb/jzZViGymmogxlrCI16XH1zhfCvxeCGty+kKPo3aHKl8+RdZo MI2IYw/aF6aDHfPUint+1oUR14/QseDL4JSYv2rWDOEAubkmzlmurj4Ur7Z3MVCx04V/ XZkEMqDeY8uT1l/YnM82QqZIRuKbwbzLb81ZIRdTXIFOWwGOvoUNEOBI/XET/IrHk1B6 9I5Q== X-Google-Smtp-Source: AFSGD/XNCF/AELM92N+4p9/KZr4mLV4IU7b+ZllrdzFyHIFG9XuHFhwnCGsyXsvCDA2cnfQI83lO8g== X-Received: by 2002:a62:11c7:: with SMTP id 68mr13037815pfr.21.1545657836303; Mon, 24 Dec 2018 05:23:56 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id b26sm71332999pfe.91.2018.12.24.05.23.54 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:23:55 -0800 (PST) Date: Mon, 24 Dec 2018 18:57:52 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v5 8/9] xen/gntdev.c: Convert to use vm_insert_range Message-ID: <20181224132751.GA22184@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 24 13:28: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: 10742295 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 DA8E513B5 for ; Mon, 24 Dec 2018 13:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C74EA28AD4 for ; Mon, 24 Dec 2018 13:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB8BB28AF8; Mon, 24 Dec 2018 13:24:41 +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 5A9E328AD4 for ; Mon, 24 Dec 2018 13:24:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 655508E000B; Mon, 24 Dec 2018 08:24:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 62CCE8E0001; Mon, 24 Dec 2018 08:24:40 -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 51CDD8E000B; Mon, 24 Dec 2018 08:24:40 -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 0E9638E0001 for ; Mon, 24 Dec 2018 08:24:40 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id j8so9950899plb.1 for ; Mon, 24 Dec 2018 05:24:40 -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=j2WpOBFxB4Fuh5k3+hK5AEeLnP1i+zXodYel36K8a1msHKlkRU1WQhg7OifZP18VpI uhBjGVMKdb7EGur0OGjH1lsQ4N+GpojReJpYsOXUsvXe+uHRsJ1u60T+cTcPdzozBaW7 iZZHHwDpEM7SswH65/KULgv5YksvxeI8+RQP4Q9gDWDnDYrCso2kYl30/jyM0rN4qQ4/ id+Si1EApwSiD0vXEourfNU/6Kchd7VkFSYg38YbmbDj7NOJ8Dlb4HLh5ituU3a6u3YX BROAgeBrm1orPzmTBdffmHW+HAkAV3P6WUg3NcbAsKhNWg8vbPf92bX3Xy7VMMAybUpx wCoA== X-Gm-Message-State: AJcUukc1Yjlfj6JgbVlvpY5ZjM7h0xRWXsKLVfjmtAF51nFe3Z1V7Tm/ CXpBtsKfidhiUFP21aErA0VSStLqdYeN8OYVCP2mZJwONHmVKWHIXbW1PeigQiltjmLzXP6I0IV JARXH1dFbKmcIyXZiWImfoTpbkVzANGvi0SeApvfK1VN7dePnCbzZP+mO0biPj2jrOulLfSkYF1 ybqK4sCedOtVSBwTTzAAtotO/I/34GfrcGQhFkPEgIMs96pULxLmm7DVwEz+P20BNTg03lL1vlC 0SMaVyhQzqnAq6a/5YbIwFqH7nOWKaTg1oGW5a+uFo10/5AH6JUOnjP//VXf8C0lKMob871mwtW tnMm58i0QTAem2RKlPjHIaGOSp9o9B672+O+4OApZEWm9pVFdlHwuIDQN8G4qnaOJjoWVuY/qGz 5 X-Received: by 2002:a63:6f0d:: with SMTP id k13mr12193776pgc.42.1545657879744; Mon, 24 Dec 2018 05:24:39 -0800 (PST) X-Received: by 2002:a63:6f0d:: with SMTP id k13mr12193737pgc.42.1545657878905; Mon, 24 Dec 2018 05:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657878; cv=none; d=google.com; s=arc-20160816; b=CQMUUqp0nIDhU8s/I7OP3qSVidpNg+ghYV/Yl/VAoQ7ne2DdvsBa8pji9UquNuE9H5 pUCjFiqBw4zRMwwiFvdQ5tbF1jHKrpAaoWC7RhUgxXuXzQGt6E8JihBNNoXzztuHeB2F THI/powYYJLyc7ub2LyVOAPoO0lsO9zS9vjiDvjjWAKUkYxmT3RNzjwwmsMne5ybMwlg lgKJ3O3xPqQU3t5IjzO62f/awVR0GK/SjS+ZUBjUopUeLQCVpup1P1Ag+rw+mS6weV5q 8MQIQSO6zFMcLS4tOTk9q976iR3+IJcBy0PEZ20OxNrhpi7iDEp4wJAUCC0cxYIl9ono VR+w== 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=UjvCIz9y62/eSo7qqA9ITENjYW9jNPm4XUum4dL4o5BYPhsGiUKjfpJjtdvNpDJYAe pcS0YF9EmYhTFhFkOP2/rxaOMhGe4SnJEqQbVUo+cHaYB5cMY92lS2oss6MQlY3gx7tb NCdIDcyD612R97RfKoR4vXPyp/FzmWaBraHVt1NisM5of4hfBo5AbpGSGKOxg8/goom+ 1oTWQofAndtZxcJuwIp72hflkM89iyxYt4CIX2y+gk0+B58LffC/e9Il8e43vKSTegX2 neMc/GDO+FHbJPJSWoSJSQG4dejUJMAh7Kc7x39iTVFFW+xMoYA5ijL5uq6VNoXr73FF ivvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="GDuxmq/A"; 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 i11sor51659368pfj.7.2018.12.24.05.24.38 for (Google Transport Security); Mon, 24 Dec 2018 05:24:38 -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="GDuxmq/A"; 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=GDuxmq/Aic15WMXOQMH4HrSFG0stmPhzQGi79maKq+afi8zw5IjbX4WO7EBtU4Y4Aa es7qIcOpTYJ4MljVBfAKdeTApaICyrUwH9OHwTSRD29kMCYJUvUrqfFRTtWBCFSDVNaB D+08WqR+rmVKV+OBhkdgasAMMBrRM3dftytU94MpNoljNyFWIQC5SLE3qv2rEmBJP1iY PlWL494kqT4wHJc9k0khQ6jPK4JiFTqKXalJHhj9TcvGX63+U/1VnAEr5HTgPK+1/Old 8ZWRZQjCT44ajiLNhJX8FmB02uUMM09edQpVw7rX6LARSq6srEeuDlG8Z8hUmpKJre3P rPuA== X-Google-Smtp-Source: ALg8bN7MqKdlBoEyyvA+3qDEze8cTZiGRFINTLDBE/Qm6sZIoDhaLCAuk2cAeM0YMez3riWsyZJJLA== X-Received: by 2002:a62:9111:: with SMTP id l17mr13092429pfe.200.1545657878185; Mon, 24 Dec 2018 05:24:38 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id v9sm44373114pfe.49.2018.12.24.05.24.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:24:37 -0800 (PST) Date: Mon, 24 Dec 2018 18:58:34 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v5 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range Message-ID: <20181224132834.GA22203@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.000001, 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);