From patchwork Wed Feb 13 14:02:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10809969 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 975EB1575 for ; Wed, 13 Feb 2019 13:57:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 839F92D0B4 for ; Wed, 13 Feb 2019 13:57:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 766D32D0CA; Wed, 13 Feb 2019 13:57: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=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 D0C7B2D0CB for ; Wed, 13 Feb 2019 13:57:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0728D8E0002; Wed, 13 Feb 2019 08:57:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0236B8E0001; Wed, 13 Feb 2019 08:57:57 -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 E55708E0002; Wed, 13 Feb 2019 08:57:57 -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 9B6B08E0001 for ; Wed, 13 Feb 2019 08:57:57 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id e68so1772069plb.3 for ; Wed, 13 Feb 2019 05:57: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=QS3mWzK39q3lW8WqJHFL6wuRYacMcGaOmOmP8soCdrs=; b=lDjUsjpnxdo34ar7wdqAjGGKY/BqX8o7GXWoFIgFnZxid32b/55NZ6GmYCh3Fn0qIV XTnkoHfWBpulhTk1BiNjv4GDtSzCzhnzI2415i3tc7pI2wFuRm1Zdc9eGrPKOGbsoK+F Q1MHb9aXxSXc2oc3+b7BGqB2eBhH+1pTtJPxKK5jy1uUVDZiY7+kSQpjY+4MGJ41j3Kh gtFlRaPtHzSVPI/tMn+0/FxFNrKx54JPFWxfKiP8UBC5OHV57k37vamMEhtBux/OefrS ud0y9ETT084dsgEe16We4amNH7Qytj9ORvmabiwT46v3oauLOeHqkRW8eQP5zZSC3AUC DEQg== X-Gm-Message-State: AHQUAuZjHzM/5E8BvN1kRz4pTgugzUF+g1Lfe2JiTUp+xeu6ABF5Op5l Pr4127V52dPRBz7e9E44F/UaDxmjZ0e2UTbxxg/YHeyBtWsc6Q1vV3bRQOBC+VLsSG4+3fJFGGL BxgZ0W8HBhEwjD7c0XLrYJupqf2v259IQM2aRKYKcMR5UIX9q/63q79UZ5qTODVGPfiY40ECqon 88oeazDhsDwLB7+TCiaqOud4EJqz+0fKyn/NRPwoqme+Ua7hbEmJnWaBgwTODrz/zKHMpBfekE0 4v36g1dE4XfTK4eotuuB0FAIvwPmAZ+klRiDorNOb/PrHGgGyk0KWfmJVHT/nR0AvVjxfQADaIy hFcGcVWCghBotmWQOGRJKXV3LH8HCpY2sZb9sGJNI5Brxj4ok01YWuB81J2lg3sWdXLA2KpVkIp 9 X-Received: by 2002:a63:96:: with SMTP id 144mr568489pga.315.1550066277193; Wed, 13 Feb 2019 05:57:57 -0800 (PST) X-Received: by 2002:a63:96:: with SMTP id 144mr568440pga.315.1550066276327; Wed, 13 Feb 2019 05:57:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066276; cv=none; d=google.com; s=arc-20160816; b=bxCSj5/W4NyA1QpbaEfrHzCuryofAAdJO2VCbxsherLs2zXXLaan7O+JnXqP+sOPlF HCkXntiTN7byxrjsyudvWF+dsKfbVgpeEQuA7U9u0fU4A3TaP0G1bML7ohcKTF2b4BoQ 8yJ3KVTBsM/gVFZaHfGcMVSR2oB+E8RGH0DObVdW2ZxjxGe8/0uA6C+igcqzIpnw2S2e 5xDYGQTlMQ4W0Unb8jldp2/F9V8xJejsGQtXqqPO9sKCn5zQuDa9hFJB+j96IhKK0M33 bWnAtx/rHytlz9xeemTTQijaWGgIoKRih6WRyhM8Zf7IuaX7AvfKRsxZ3S7+ZtmxnFEk uo0Q== 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=QS3mWzK39q3lW8WqJHFL6wuRYacMcGaOmOmP8soCdrs=; b=jC+84bVqdEBYT7duqRJnHhS1Hc1CK0L3ox1jFIry3nZd/L0OA5EiQ16Ff7Z6K4eWTr Sdj+M9mGymUeeKAF4dEmX14w7kSxkli5S7vDedun+IjOxnE2hKJTum+FBDus9Aow0zQG es7xpm7/jQxb3ld9cjbNk6fCn20jYoIVCmN62qzyvlPmEDUqZM+3bGrAX54GuM0B45mp sUG+Mwj8GXUAxh8F2FTnebOoWXnv7jbc6aME0GRZohSKrtSB2MPMoeb+toxc/4ye5ISf dvLFKA24eqZhL7b+Lgb2Ns7vZtuKDWp1StwPY3qb2iCWSOSUW/O3aM53z0RgzdRP0p4/ UW/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UHbAr6Vj; 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 v15sor25251415pfa.0.2019.02.13.05.57.56 for (Google Transport Security); Wed, 13 Feb 2019 05:57:56 -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=UHbAr6Vj; 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=QS3mWzK39q3lW8WqJHFL6wuRYacMcGaOmOmP8soCdrs=; b=UHbAr6VjHIA6sKDIJjq+403Y2d7WPguSXt3rzmIl6IBY6SSfTp0rLgonfEf6lGHpCs CrqhOWcnJqtDs+YhZFN5PrBEiC74DnXBT4v+K/jsCvtxEA8T8Scf5lmzpX7lohjU+xvl A2rPHRTJZmYRrO65TcR9WlQZvULjczqLPmErv17xJYk9d75MdbexEIZI5clY7YNBgJ49 Zp9HE2xqWl71SvZmGVzA+KbEUvV+xrOI14XqbKjbaXYpQXQawuxYvX7APazz3N9/jRar pL73Tp4ZQMXOJ3AmD52pjLwG6s9XYcngHbZ5fEeW1hxuJ4Tzz1denDq6BM6ddw761yqb zHSw== X-Google-Smtp-Source: AHgI3IbsRbeaAyePsoPA34qPEwK9ju+Mwor/j+wcsqcPpuYwN399ocFJJNJYAe7AZfgfl6MyXeqd2Q== X-Received: by 2002:aa7:838b:: with SMTP id u11mr644881pfm.254.1550066275977; Wed, 13 Feb 2019 05:57:55 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id g14sm33624506pfg.27.2019.02.13.05.57.54 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 05:57:55 -0800 (PST) Date: Wed, 13 Feb 2019 19:32:14 +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_map_pages() and vm_map_pages_zero() API Message-ID: <20190213140214.GA21954@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 new functions and use it across the drivers. vm_map_pages() is the API which could be used to mapped kernel memory/pages in drivers which has considered vm_pgoff vm_map_pages_zero() is the API which could be used to map range of kernel memory/pages in drivers which has not considered vm_pgoff. vm_pgoff is passed default as 0 for those drivers. We _could_ then at a later "fix" these drivers which are using vm_map_pages_zero() to behave according to the normal vm_pgoff offsetting simply by removing the _zero suffix on the function name and if that causes regressions, it gives us an easy way to revert. Tested on Rockchip hardware and display is working, including talking to Lima via prime. Signed-off-by: Souptick Joarder Suggested-by: Russell King Suggested-by: Matthew Wilcox Reviewed-by: Mike Rapoport Tested-by: Heiko Stuebner --- include/linux/mm.h | 4 +++ mm/memory.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 14 ++++++++++ 3 files changed, 99 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 80bb640..e0aaa73 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2565,6 +2565,10 @@ 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_map_pages(struct vm_area_struct *vma, struct page **pages, + unsigned long num); +int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages, + unsigned long num); 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 e11ca9d..cad3e27 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1520,6 +1520,87 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); +/* + * __vm_map_pages - maps range of kernel pages into user vma + * @vma: user vma to map to + * @pages: pointer to array of source kernel pages + * @num: number of pages in page array + * @offset: user's requested vm_pgoff + * + * This allows drivers to map range of kernel pages into a user vma. + * + * Return: 0 on success and error code otherwise. + */ +static int __vm_map_pages(struct vm_area_struct *vma, struct page **pages, + unsigned long num, unsigned long offset) +{ + unsigned long count = vma_pages(vma); + unsigned long uaddr = vma->vm_start; + int ret, i; + + /* Fail if the user requested offset is beyond the end of the object */ + if (offset > num) + return -ENXIO; + + /* Fail if the user requested size exceeds available object size */ + if (count > num - offset) + return -ENXIO; + + for (i = 0; i < count; i++) { + ret = vm_insert_page(vma, uaddr, pages[offset + i]); + if (ret < 0) + return ret; + uaddr += PAGE_SIZE; + } + + return 0; +} + +/** + * vm_map_pages - maps range of kernel pages starts with non zero offset + * @vma: user vma to map to + * @pages: pointer to array of source kernel pages + * @num: number of pages in page array + * + * Maps an object consisting of @num pages, catering for the user's + * requested vm_pgoff + * + * 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_map_pages(struct vm_area_struct *vma, struct page **pages, + unsigned long num) +{ + return __vm_map_pages(vma, pages, num, vma->vm_pgoff); +} +EXPORT_SYMBOL(vm_map_pages); + +/** + * vm_map_pages_zero - map range of kernel pages starts with zero offset + * @vma: user vma to map to + * @pages: pointer to array of source kernel pages + * @num: number of pages in page array + * + * Similar to vm_map_pages(), except that it explicitly sets the offset + * to 0. This function is intended for the drivers that did not consider + * vm_pgoff. + * + * Context: Process context. Called by mmap handlers. + * Return: 0 on success and error code otherwise. + */ +int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages, + unsigned long num) +{ + return __vm_map_pages(vma, pages, num, 0); +} +EXPORT_SYMBOL(vm_map_pages_zero); + static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn, pgprot_t prot, bool mkwrite) { diff --git a/mm/nommu.c b/mm/nommu.c index 749276b..b492fd1 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -473,6 +473,20 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); +int vm_map_pages(struct vm_area_struct *vma, struct page **pages, + unsigned long num) +{ + return -EINVAL; +} +EXPORT_SYMBOL(vm_map_pages); + +int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages, + unsigned long num) +{ + return -EINVAL; +} +EXPORT_SYMBOL(vm_map_pages_zero); + /* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty From patchwork Wed Feb 13 14:02:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10809981 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 5DEB5922 for ; Wed, 13 Feb 2019 13:58:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4945A2D048 for ; Wed, 13 Feb 2019 13:58:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D4A12D0CA; Wed, 13 Feb 2019 13:58:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF6A32D048 for ; Wed, 13 Feb 2019 13:58:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 380CF8E0001; Wed, 13 Feb 2019 08:58:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 275AE8E0006; Wed, 13 Feb 2019 08:58: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 E317C8E0001; Wed, 13 Feb 2019 08:58:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 960AC8E0004 for ; Wed, 13 Feb 2019 08:58:40 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id h70so1926792pfd.11 for ; Wed, 13 Feb 2019 05:58: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=cNyFM0J2DfW9voxw9FzV7E7Y/LrzsWkGDKLqwe0d5pk=; b=KoLA+3LlO7WJ84IYtjfADIs6cz3FANegvVG5T66Se1yyA0tjM6saotpKKc5urCU5LW /G7KC9uyXEVCJMJgxSI8ID0DROLBAJ+7O5Akyt2zFTdYqiv5QMDdtxyJ+fmQUqUJbIz3 c2KEQrt+9Rt/I9GpGmXoavu+KmOscONJbogMeU+y3rMoHT2nsSDchF0Xw2RAmu0kzoos cRMqleguIp9bJaSA8KkyvKsYwVdgh2+Hraa1EMIjgXb7kH419wSmmhH6uMmGcmHLyiCv sIcdW7GEc4PJVFczAO9V6sYpApDFRHQlgGB8UDVxLzX9dkuoGAbklG7qUSKMUSTE6cUl wuOw== X-Gm-Message-State: AHQUAuZ5DD7MT3InCFgM6j3XThaRobqhvJNt+XqcMYIRxO6xW8ZYbc3A +gEwviwZbg2ROq8Iutc8kbze4y9ENB2JaJfTqRaJxj4TkWDttBxiehNDKIxh1uUUMLoTGRdxzPg KmzS6SiblWw0rMNi8MVAkw07vvFpErM1s7MIf84fiASItroxtzePS0kBKdkrtFpQvmHE+qVHxCr yESvGFdUcfD3JDukVORonWN531zvmLLmfqV1YrkY6l0sAMwToA/+yKG2eE7q4rrp3hDPeJYQkLp M/PEXrl/T+oYCUKydvDbsnRiqQZiWrYNVWsWMS4tegwPTdEVVHFdshnKgBR+vGD9VItybN1Mh1O Yn46atOVET7BkS/I8ccNX29hMzFPJIUgXALb7QRUecCv1dqCUC792KhkG8zuGZRHrNt/UdwiMQ4 n X-Received: by 2002:a17:902:9b87:: with SMTP id y7mr680203plp.336.1550066320256; Wed, 13 Feb 2019 05:58:40 -0800 (PST) X-Received: by 2002:a17:902:9b87:: with SMTP id y7mr680125plp.336.1550066318859; Wed, 13 Feb 2019 05:58:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066318; cv=none; d=google.com; s=arc-20160816; b=tmjK6vyMz8W7KsopngHDbEtSzipOd4gCIpSJT5IAot3DcgbdYDrVi4fzZ/btMvw8j1 KcK7lWZRzxg0FFkEF1Q+2/5WBWzV55OlOPYVhkZO7bqmK85OT4+dhdErvxKnq4gEkAiB ZnaFAB6JgYvinzP3e/xIcRie06Z2gbWqflRYVn0qJ/NtssgqgOGf5Rogvx5g3kpyqZKc UCl8SebqxoMOUMn5lfWU8QJ3dTx8AC2tDMLlfkLXevmEECjalbJlE5YGqLlUahHOjduO aeP9WAIWsiK40HdJrxfY6a7ZjDoNmPkzaWdHiItixOIYgj6/J3mOXtWFkDmoyaDGKquJ riqg== 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=cNyFM0J2DfW9voxw9FzV7E7Y/LrzsWkGDKLqwe0d5pk=; b=ASH6rQdzAxFehsd0Zyva8V5MyM/2p06tFySZGPwcSEpGBxZSeBQyq4ry/tRm+WSpsR t3zEKXWCC5pqgoXCXOgBzzPHi+HgzuLptyK5FuupKhQtGgRa9VDmSOgMr1b44KcauE92 kvzAazeLUFJnZ7d6lvm47MUJecauyBthzdYmNZqEbqBwHHxZ1bdYrM6ReyhpECOk9BG7 9TzgpbqY+o7Bzl3BnLJwu54l8rsuFU4QcdBgWB5xoCGVOMIGgd8fmURzjZpLChB1nZtx UAiqjN78fmdyRHkUTwRCN8lvc/1JDByYE8hT1VIsHZCXprv+5HM79u8ugJNRynEnaDuZ m0jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pbigDwG3; 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 y2sor6550781pll.68.2019.02.13.05.58.38 for (Google Transport Security); Wed, 13 Feb 2019 05:58: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=pbigDwG3; 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=cNyFM0J2DfW9voxw9FzV7E7Y/LrzsWkGDKLqwe0d5pk=; b=pbigDwG3xTm4YxvGqJgLG5mkUt5O5OB6iH/4JOZPoXunwWHE5QfP4W9AElQvSudJa3 oftivCtQcvYNS8YSZXakLgY/n/6uMXhgwbuZgbrYOMW2A6d9qxKamu6y4VDWZG9hKIXJ Ozs0l8wXg2IVBGQ5Lx1acSQcHqvuaQpFa+H5Y1d0IpRM9leug/xYa7/aLNdDjG8Ibi0w 4YGogL/vRIFJoYsg51t1pmC4flEIvAwvnxiLzYGzdVd4eEsIiXYF+OFdhEXjta13phln wgXDc3SFMpLh8t92NQ4l/buWitqvWvWgjk6iHFgB8KwSjqoqS1sBA9XRvXu1Nzpx0Uuh rkog== X-Google-Smtp-Source: AHgI3IabBr7i0UINT5tZChzG9mkUSIkz97ziRf+i4G4ZGRQ2Pfd1KkCHgUpEt1D+OFFkb4bWmp/4Cw== X-Received: by 2002:a17:902:20e2:: with SMTP id v31mr640198plg.307.1550066318585; Wed, 13 Feb 2019 05:58:38 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id f67sm30721286pfc.141.2019.02.13.05.58.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 05:58:37 -0800 (PST) Date: Wed, 13 Feb 2019 19:32:56 +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] arm: mm: dma-mapping: Convert to use vm_map_pages() Message-ID: <20190213140256.GA21977@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_map_pages() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder --- arch/arm/mm/dma-mapping.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index f1e2922..de7c76e 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1575,31 +1575,21 @@ 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; 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 (vma->vm_pgoff >= nr_pages) return -ENXIO; - pages += off; - - 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); + err = vm_map_pages(vma, pages, nr_pages); + if (err) + pr_err("Remapping memory failed: %d\n", err); - return 0; + return err; } static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, From patchwork Wed Feb 13 14:03:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10809991 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 5E853922 for ; Wed, 13 Feb 2019 13:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C722CC7F for ; Wed, 13 Feb 2019 13:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DB492CC84; Wed, 13 Feb 2019 13:59:16 +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 CB6DC2CC7F for ; Wed, 13 Feb 2019 13:59:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1C698E0004; Wed, 13 Feb 2019 08:59:14 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CCC208E0002; Wed, 13 Feb 2019 08:59:14 -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 BBAC88E0004; Wed, 13 Feb 2019 08:59:14 -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 7AC8C8E0002 for ; Wed, 13 Feb 2019 08:59:14 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id cg18so1782171plb.1 for ; Wed, 13 Feb 2019 05:59:14 -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=naB3KMuHNTCaDD6/Z64EGJGrk7XQ7GW1pzVQ9Q3Vf6s=; b=nOSSudmnAC1fe5UYUElrmr//S5qbAuN8VLodISz1RKSnTsfZUl3JYQ8aPZcy2ZbEUS K7YR37qqNcHyzqyNXUBLs5+6MoVE1gZJ/pwE3GQ84oMaNnKfH/mqOp/CJb6v6P8LLeWi 7hhOkrQTuZ/JO46DRCh2PVcpbD2//vtsLvba5kg4W3DHeOZRb6Hg/IV69mhz/nxYhRzt 0DFUV67onq3YRtByOR30Lf8RuJOpSFSKcrxjaMGnzSQafDrOk8+MiC/9hVvGH6bT6j1j oCvfVZfD0I6YlLO+ZWMS7fyQKRYgh0sxhA6EWpq3S7z19y9+P9/2bflCIOowfS7vYhJA zbZw== X-Gm-Message-State: AHQUAubKcyDUCkt7F6D9ybv6M8+BxhBmBO/aOmK5JBnXgd9Ah4gcr2ck PtXqB+f1/Bbz2o0SUVxEutQ1Wp5nEOv63biJbMexwiiLbUP6O0z6BXfoQrSeXWqJNKRcr7cwdTn 8/KAt4yXVWnBwkPta3zXY4wM2bXvBxy9DEvrDKziGuOecIzIos3oDSgyeV3lWdPgja8BLL7vZrX GyEk6t9k42qGin5BKohJvG0pmHQVxvIknQUp42Cz/bxpGxd+acl9BG6gJvztGRDPLUMbqSJE9hL byj0uC76nxknOnZksYi7n2qGbfW0xRjsfQVDoxnYK2wXlEyuHbFO8ba+mhZRoF8q74Z6miKfxf/ EJviTd9QEr3qfjf/Ne3oFkUHylWakZu9/XjWn6C8bSzBgOX81yqFdxK7bywuIGSTa2JBfZS84VB 2 X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr720392plo.50.1550066354183; Wed, 13 Feb 2019 05:59:14 -0800 (PST) X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr720362plo.50.1550066353572; Wed, 13 Feb 2019 05:59:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066353; cv=none; d=google.com; s=arc-20160816; b=lY4ZAB3vJqWub3Jg9ojeTGXqK2RoxfzWmcLwp4qB/MsDYDylF4fpenfgGBbMVYKa1A P8y37Hr3wNTXL5d6d2tLI3juyUpIMmTf7eeCA59UR5py/5NPnQIQP0AyH/eX0vS9SdXZ jlj8+WoM8M6lofCndMY0lnwBtZKQW2SLz1kGxNHATUDnoTR6wd0zcRom/cye5+MT76TH G5vMn6w0csqczrXcS67kV9xvl2Q2tt3h3sLBnG+DsATfxRDn7GZ3EorpsC72o4GVN2qY kGCHzXiqBqbgDhENy7HUBhovBt/+tKXD9qSsJDgjMPWpj6Y6bQpXeJwv9DmvPie6MXIU +26Q== 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=naB3KMuHNTCaDD6/Z64EGJGrk7XQ7GW1pzVQ9Q3Vf6s=; b=T9vN6YLvvn5R20fvHiZQQCmWh14wmnyCUbcbwyqxdTf7rhggRdEmVMJrbsD7m7T8TB cFdjRQvILHUv7IAzckJReM5CSYGw3HlE6V/LqwkBT8l2Fs0dkgck1Ud46zf5Yu0I4/vu 35QS1cHDoZDC/VAMHC6Lu7yowTviIazx4LQlClVkXeS6dxF1G0bD+mtmxhYvcPpqQPpA OirX90ialwKGwd8IGpmfZFk8GaSxCs9Agj44YFnSYatHUxUe/RtoCByHvq5To7yyi8DE mfRXr89FU5qiRUQTu9nmS+2QR0QlAqmyrrbQUOyysKFZ90hxUopWGHCQon60m8Xt20Fl FA2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HHXHCXDq; 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 bc12sor23914773plb.37.2019.02.13.05.59.13 for (Google Transport Security); Wed, 13 Feb 2019 05:59:13 -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=HHXHCXDq; 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=naB3KMuHNTCaDD6/Z64EGJGrk7XQ7GW1pzVQ9Q3Vf6s=; b=HHXHCXDqjrbjv9vKNBt9+7oEqMLimW2KaqFOqXNr/HA7rhmmEUFkNlY/u1NnQgZNbH +CDaalSV78Qcw6kY5OQUhGjsfrH+by8CS5/gJGu3VNqes+WPN1dRNmLxWbGIfZdm7c8f 15gEiqZIi9KcnTmJeiE0/uvejDFQlK3pGLnh1YPOu2dqmZ2OMrKZkGjN68Mg+yf3YDmN Ttkvg6nMsBdyaGH/uB7E4ipzK3thPAR0ZqymOfIw+XSoxI5PHoZerSNybOokoRu9/Y+c A3BYZAAsc1mpb1sa8omgtYbiZEsojeWq9nmMQjwKjC3dkqWy7hcLdNXjZUfWSeiI7qP3 8jAA== X-Google-Smtp-Source: AHgI3IYElBePFcn4s9J3Tqwya9pPVWfxESsTKj0N4GiKgmRE7PyggN/XPQLDEGJiVcCZzaxyw7jtWA== X-Received: by 2002:a17:902:724c:: with SMTP id c12mr673309pll.144.1550066353286; Wed, 13 Feb 2019 05:59:13 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id a15sm24035107pgd.4.2019.02.13.05.59.11 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 05:59:12 -0800 (PST) Date: Wed, 13 Feb 2019 19:33:30 +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 v3 3/9] drivers/firewire/core-iso.c: Convert to use vm_map_pages_zero() Message-ID: <20190213140330.GA21993@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_map_pages_zero() to map range of kernel memory to user vma. This driver has ignored vm_pgoff and mapped the entire pages. We could later "fix" these drivers to behave according to the normal vm_pgoff offsetting simply by removing the _zero suffix on the function name and if that causes regressions, it gives us an easy way to revert. Signed-off-by: Souptick Joarder --- 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..5414eb1 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_map_pages_zero(vma, buffer->pages, + buffer->page_count); } void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, From patchwork Wed Feb 13 14:04:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10809995 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 570941390 for ; Wed, 13 Feb 2019 14:00:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B0772D0E8 for ; Wed, 13 Feb 2019 14:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A0602D0E6; Wed, 13 Feb 2019 14:00:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9CBB2D136 for ; Wed, 13 Feb 2019 14:00:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE2548E0002; Wed, 13 Feb 2019 09:00:20 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B92868E0001; Wed, 13 Feb 2019 09:00:20 -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 A811B8E0002; Wed, 13 Feb 2019 09:00:20 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 68F628E0001 for ; Wed, 13 Feb 2019 09:00:20 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id 74so1929946pfk.12 for ; Wed, 13 Feb 2019 06:00:20 -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=+cqpEOgVsQX6FuKbkjkqnPdK6JJEhfhSEvMIkCtIVgk=; b=VQTkob6N2t7sDyP1BfZgTmEX2COvsZ3fN6pYakW+CplbIA4TGrmpSvPMrOcSvT3x1g PYzde7+gzLWz0uAvBHkWRY9xTZnbQYFwzqAW66THSvCmmI0gt3BXRET92GOfAO9tbrDl wLmU5UGTyYApZ+vyCZoOScEvT8Ctt/5Q6u7AqUW4iRzjzwG+L9K5z6tcq6T/6U/lBrBA MxFAFdWDehik3eTIMbsiAaT8xfbdmDMOU+rfAn4UlrSZ+RZOHMF9GAG05USj9J9LCEdP Jb2p3OlbpOUiFmBOhzX3d5OzpqljSeNNVs8cVZMNuYla9MfwCRmPh4T8+wQO2yhWsUUM DH3Q== X-Gm-Message-State: AHQUAuZ8PqklwcxS/XSS0Dv9PLiFM/LPYs/eTRXcau7e54r3Mkrm0HBe qEBfJ7zFrYXXpnlbpGU71Jwh0McBE7c/JxPxzBSQeMbCeegWmLp51SnVS+hz+/ucP2+X61X/uV0 ZTGdgcRcSzpNwrbOegGrGqNbSrMVSSTQfsbYhH6Zr6Xcww993+l69hIkNDFmZNm4AGq2P/troTS cuDGbfLp5+YM2AdrwsYFEXobIXD3rV4ELG7+U+1rdLjubqnsRSHz+W0WXMx6C2bCU2uR+8bX2PG 2lE/spt2rcXyZm9c3VOMPcItGEE7O7oCAzAbjXEtJQvNAHtpFNKlln1kaaIm8dlOQig02zyr9qX nWEXKQMS0T6cK6qjhYEdsTmazGw4qNKkkab7XybE5SqTh6yArRkcC19+vtddqZJG+02Hx1HnvoL Q X-Received: by 2002:a17:902:ab84:: with SMTP id f4mr635183plr.207.1550066420106; Wed, 13 Feb 2019 06:00:20 -0800 (PST) X-Received: by 2002:a17:902:ab84:: with SMTP id f4mr635117plr.207.1550066419438; Wed, 13 Feb 2019 06:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066419; cv=none; d=google.com; s=arc-20160816; b=Qi9TiO5atT1iolKhdlRoMt5/B7AeVmOXdCPrMgOHk1rv1MKgdEliO/9Umooa6k7i79 fhH8UdKoEGcMZ1k/E7BpmJXwvV0m57zZm55hA77qVjD+psLyMOjpwlIV5WH4D4CnQHih N/r7LwCwcFAh6TVrD4hmxfb4pBaxYic75wLTdTB8LBBletUChmqUTbdbK+lXSOtOodni zYvrORhYcbd3z5TUB+Wj94CQEpDT1oWlexxg91lUuK1YCdmvEZt0bXcohZVcdkh4+NBU aLyMpo4rF8lyRAsGXZFi3mCf7dlHKKZgbwuG8xwvIxnRHEB7e8PW5Ys35yiOUNb/dSYF VC/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=+cqpEOgVsQX6FuKbkjkqnPdK6JJEhfhSEvMIkCtIVgk=; b=BHekCJIx6AZ079Z4sCJ1l+8cSyzhhV9BjlcNFlZSWzVSxQhjCguU0YC+JJ9epOi+Wl fqSX2RbRTy42ZyngloSoX1lo4ulkLNn47ejpdhh3bZCiPr/mzSNYhGqiEaWH0XOqxhsc u6NTok9b5vx9jjrxi2MdGffysLdwLM3vTAhj/16+I1uNxhn1zhaRZ52Oj+SehoHxsXhO IGSpOSORIPIQfQcWDdQgLYOwuXDViOqnVGZS3LkuKUztrJo+AREd/zKFwvVjdo76/X6M 0mELUVK66IjJMSJVcYcRtCUeA0qovE9KFjvo8cOLDPQXG6o6S3cqleFvitYqDuNIgy54 LW5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FTkvJIhi; 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 y66sor22607625pgy.45.2019.02.13.06.00.19 for (Google Transport Security); Wed, 13 Feb 2019 06:00:19 -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=FTkvJIhi; 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=+cqpEOgVsQX6FuKbkjkqnPdK6JJEhfhSEvMIkCtIVgk=; b=FTkvJIhiZxuB2UN3OVrDxEf8j3emEZw9A9itD1oPd+tVJ0e8g/nDyZISMfbdyXaAP6 Ku+f1/oU09s8dZXMCE15EC/lZ4jhE9XpyVezCzRAsRLdy/21AR6rTdyIxoZbfsMxmQYr o1QFAdcjEMZ4hpVPbwUZfbKD3bP3YaF5W6bCDSkoV9uE7cMXX9QTOFBJsVTZFBub3vD/ tLP1kpXdfL6PFeEz95+peYCFGB2V3ZREDDgo2MiHR2YRRTInP7Ujlzf+v8xIEwW/acLG YYBPMe+meJlZK/PpLg21XpK/Zqy+ohSuq8qV9XGFBs8K15TIr80jXNZJz+mddYFSLU45 kSXQ== X-Google-Smtp-Source: AHgI3IYGzYQtaDAzpRnw4j6/fnsbGP2OWM7ItsKgcpabtFzajnCQ7pxNpaBmZJle8XOTxzleQFh85A== X-Received: by 2002:a63:5442:: with SMTP id e2mr628034pgm.282.1550066419102; Wed, 13 Feb 2019 06:00:19 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id o2sm27521833pfa.149.2019.02.13.06.00.17 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 06:00:18 -0800 (PST) Date: Wed, 13 Feb 2019 19:34:36 +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 v3 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_map_pages() Message-ID: <20190213140436.GA22010@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_map_pages() to map range of kernel memory to user vma. Tested on Rockchip hardware and display is working, including talking to Lima via prime. Signed-off-by: Souptick Joarder Tested-by: Heiko Stuebner --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..a2ebb08 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,13 @@ 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_map_pages(vma, rk_obj->pages, count); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj, From patchwork Wed Feb 13 14:05:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10810001 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 8F4371399 for ; Wed, 13 Feb 2019 14:01:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B0672D187 for ; Wed, 13 Feb 2019 14:01:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D8AC2D18A; Wed, 13 Feb 2019 14:01: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 D351D2D144 for ; Wed, 13 Feb 2019 14:01:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2BD18E0003; Wed, 13 Feb 2019 09:01:03 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DDB8A8E0001; Wed, 13 Feb 2019 09:01:03 -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 CF16D8E0003; Wed, 13 Feb 2019 09:01:03 -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 903698E0001 for ; Wed, 13 Feb 2019 09:01:03 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id a26so1929328pff.15 for ; Wed, 13 Feb 2019 06:01:03 -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=wsI5nOykFSX6S7SyN92+LRaxG3yXSZXxVHkiaYJTa/M=; b=uZC5aAFXC3RSBzBneQzUfezvhPJ0Efi5+OvDp2RRuWIMwF0CAEXbc2/KODhLY1A2// 00Ttta51cWcsqVbdIa50Cg6jG2UcscRTCzyUP9izg09GXCsE5889crM5e0GQXLX/6u2E u28mqAK+7W0l2fzGGJL+5UKHX8bB6CacggnwMCScxB8zJJlAEHS8vyfpp+fZJRQYbZ0U U0kuK1aY4jF/n8/VyEaochLQwxv1IoVaHP3bZ/rdpFyS2+cIfLCWA7eEI7KI7W664qwq JudqpEu/8WC2Js3XXBtQIH5hlhg1k6inIY70dxr9QACWVjYR3+aykekXt9CvNFqb17Tr rdmw== X-Gm-Message-State: AHQUAuayLL5mP2RjzxHCNbzlU9b0SMfvMVMVAfInBS+xyoXgw/IrFpab qGsUvXE5mYKx9jcYZrfosImhWwLlEFmcSRSw/nv5WTwj5EfoIdGzih6eX6UfpZ4YYRNWJ5Sg7V+ TVxW3LAwpYVwd02qgbt2l4VsBEF0ld1HVdl3JwXkddRMGec3fY/rmugnU8fwrQU5hr1HNxJCJnk I+oX0ZDKLP3g+j9hQaZFJpmMOoub/zifnxXsXmoc/RI/2qKnPeya2yLTEywdqKds2JQJm+pFKqE KKTDSYorhxjtHZMJv6VnaY/9bX3aedcm7fdcvwuYW1cb2my3u/XmYMyrC1qgiEcwp+cwyXzkZxc hn4B9KszljtfH191fZ1mTW+MoDIjISuwexEuSob9rV6IcZ8kALB/qguKcYIaYEkO3b8PqW63eUg g X-Received: by 2002:a17:902:2a0a:: with SMTP id i10mr625174plb.323.1550066463260; Wed, 13 Feb 2019 06:01:03 -0800 (PST) X-Received: by 2002:a17:902:2a0a:: with SMTP id i10mr625102plb.323.1550066462456; Wed, 13 Feb 2019 06:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066462; cv=none; d=google.com; s=arc-20160816; b=FoEiO+y6XqZCz2TdCg+0uDQa1IXuNpfz/XqZ1Aaua7aKQM985Etl9GuuRHS2eS5GDD LHsbhIrexfCGe16e3W8PwFjyLvdwL60EDjIGo9KJ2cwR8TKX6LdsrOcmfLCVAxL0ioZD k630tVoeB45m/zj9BB4Ws2g9AREcMg2gEKqecTLCS2B62LjBQzjNSYLXeFcmh2Sid613 pnCch2gjUArOr8X0mcPJCC81SDUX8F8OyoCg4efOXcbAiACoTtoMogXbqpaoatLPxVIB 4CM9Q4h9zrOVMyUkEVnepXfQnh+Rrw5I/6Ox++aAXb3+JDmrRzzk3B6vv0VjOM3O+kJQ xo/A== 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=wsI5nOykFSX6S7SyN92+LRaxG3yXSZXxVHkiaYJTa/M=; b=yCgWAHor43lzVKpXwMwONc0VtmJduEasvWkRB3KGqBM6iPHuvOzMBL4UTwhVEmbJgP IQmfPzoSoEHPonFLx/pBuxdBITTo5HELtsQLP5KE2PKyHW7uaq/Xb8qadJu60CkzvhLo X8TdN0s4L6M8+jkYpILmCG3eI0JVj07Sq8ICq8aGuEOsTSR9m515+wy3pADVG0QOVVEf URHjw5WtaDaN76E+Nqr/PCoy1+Y08TDxajc50dtzUUCLQN2yNS7Y/q7OMKi/acVK1x3N 9HNzs3Zr4rZDxxwkSBEQSGR6OgRsYVf8wNgfYRZybayM+weth6OGoBnbXen2UbNcyyY0 vWLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a3NB43+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 l30sor23369199plg.17.2019.02.13.06.01.02 for (Google Transport Security); Wed, 13 Feb 2019 06:01:02 -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=a3NB43+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=wsI5nOykFSX6S7SyN92+LRaxG3yXSZXxVHkiaYJTa/M=; b=a3NB43+TY8+WgWQevWmth0jDcxyBS/n2gAoDY2YZP49uixFVqF9mvLnqWGduB6Va/H feQh5HfmgXevrSsUjZhdngnb/naX2abIqktrI2KmmPQ8oNpgax5etRPOVTOOFtAOb1YG zhhHS9mNeuWvPEeHM5vcn+7gTBoWwJ0R+XoaM8QBfMA+CTM2NXjJVl6JImLxquz6l9Fl BtCPxnokINBzCCKtI+vM8SJ03eMGBK4CKngpr1xjCKL7zP2xXkcut5n3iNwAMAKrAb7P epNaoBisfUaCTj5Cg8+sPkYrY82yZ+MPAE/klZurmQjZ9YF6Q78A1sMJks+f4FhOgCiO J+WA== X-Google-Smtp-Source: AHgI3Ibm0TTd/gAqweslKR095bYfBxZMG3ZrVdI1TDAsasHXYl9RczcsJBx08hZyBa/705vkTwMYUg== X-Received: by 2002:a17:902:346:: with SMTP id 64mr650376pld.337.1550066462186; Wed, 13 Feb 2019 06:01:02 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id w65sm18734568pfb.23.2019.02.13.06.01.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 06:01:01 -0800 (PST) Date: Wed, 13 Feb 2019 19:35:20 +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 v3 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_map_pages() Message-ID: <20190213140520.GA22029@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_map_pages() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Oleksandr Andrushchenko --- drivers/gpu/drm/xen/xen_drm_front_gem.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index 28bc501..dd0602d 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -224,8 +224,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 @@ -246,18 +245,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; - } + ret = vm_map_pages(vma, xen_obj->pages, xen_obj->num_pages); + if (ret < 0) + DRM_ERROR("Failed to map pages into vma: %d\n", ret); - addr += PAGE_SIZE; - } - return 0; + return ret; } int xen_drm_front_gem_mmap(struct file *filp, struct vm_area_struct *vma) From patchwork Wed Feb 13 14:05:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10810003 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 C4AA81399 for ; Wed, 13 Feb 2019 14:01:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B09E32D17C for ; Wed, 13 Feb 2019 14:01:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEF8A2D1A4; Wed, 13 Feb 2019 14:01:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54A712D17C for ; Wed, 13 Feb 2019 14:01:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5018A8E0002; Wed, 13 Feb 2019 09:01:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4B2238E0001; Wed, 13 Feb 2019 09:01:43 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37A9A8E0002; Wed, 13 Feb 2019 09:01:43 -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 E79558E0001 for ; Wed, 13 Feb 2019 09:01:42 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id e5so1720725pgc.16 for ; Wed, 13 Feb 2019 06:01:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=XQSNSZywn2J5tIibcMqEyCRYg0DoENdsUd09NDa1qxo=; b=ebg8OhEHK88aKlFNOAWe7msQ0xm2mBoNQWOUXxwnDaDMGPuliVUTMpHrFQ/ylfZ2d9 Rx6z1nh5Gq7K1UP87PSRsqpN5zhDaEWRhnRVQnLj6MSMpFR8Tpci5If2f++7NWDW8KWE HhjVFJlzwCOzbmO0mdntpjuFW2R7e0/5EPFkXhZagafC+M6aIA9Wu1TQBzb0GDyOfVU+ 9wzh20V7df+8iY41vwDMxWaJzYq1CmPsInKxCpvV743u7NlyHchCG3j5SM/BbesP29N6 eAjEoAktOczpPKQPgYYw7AaIqh1Z1lSV1WvdRx3cu2W+VvWd9pTRhxDwrPUd6I2vt7u3 nv5g== X-Gm-Message-State: AHQUAuYAfeH8fbGicT5zU+aqpsWNZbXSiwdU/wNvlwJTEkGeFiaJMTOx NxpHpk8rHqaAPgWcLn82xrptUTYhSELA44z5Xl/Jrd9zGz7/x5XgPJLWN/MKj/KDnMXpQvcuuXW csO83rXhy6mTYN2XcyBclnIFiQ0IFFpLkiCiwfnZBozhD+tPsr0+swgT7yFRCAAGoZF6RhRU3vT wvhKI/SOwocm5dgdJv71uM4yG/OlafXDlLRrBiHk79tIKEaF6MmUUUiZjLc1/Ujx99J85+z2dcR XZ+xHSOWJYia1EOeHQqr3UYjIJwov+Wwuy6UocffyQ/fFhAxvIvP1aDS5mwo4wXaVi4YsVobkve zhgK9ExyUjekK5+0QVBWxiI4W4LbyMRfRZ7M6cwaJGVQx7BUn+HhmVfyNFoM+IM930VUUbQz8pj n X-Received: by 2002:a62:6453:: with SMTP id y80mr618515pfb.203.1550066499127; Wed, 13 Feb 2019 06:01:39 -0800 (PST) X-Received: by 2002:a62:6453:: with SMTP id y80mr618453pfb.203.1550066498414; Wed, 13 Feb 2019 06:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066498; cv=none; d=google.com; s=arc-20160816; b=CNZpFL4KbXjx4hlbLvNeAv8E8gMrZgvDzCwKSmOEAs0N0Zb28UrabLfBLVTVDibeib YqefjsbavVIm1EqgkFbd8ww/jagJLE9jhWaK+CXwgriL4KyScCjIrI7JdPRkjvVdXvq7 pDDVhppyjXkNxrDjxZUcjyEGzZAxSj7vRKUmWCXT9iD524+/151rjzuu3liRQYYGageH 9uwzEwPOgeCV4HOM89JIMofXKPFv165M/qJ2J0cKUAKm97i61bon7EbcknX2jT79IdfX IzFU9dnO6IhnfsY7OIQtNIXRsN80Ld1C/OvcY9mdP7lFQXJ0Mx4xB06fFnFM+MC5OkSQ OiJg== 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=XQSNSZywn2J5tIibcMqEyCRYg0DoENdsUd09NDa1qxo=; b=qhu2aMJVcMNPE3t55GsAYngGIliKltdvKKWRIGzHkFV/wGGoXbRcn8iqqBa0T1AZzM C0x0bzqQZPM10Osfo1GLd1smgCvqVw/p4BXtFH5Ryw/vkbqNBAPCaUBx5HEhQWD9U9Eo 6ibLTf3Ia6WPzXDZY4TKzAfWCcES8aRDpMFm5SPlIpqFvCIBFq7/1MKoRFXWOo4FvP7g 24gg7u84qR1HE6EKJmg9TWH3kY9AnrgAZLXzgVZuUEgNFOpg+NxkxnQ/o/6kdwRxOGqX dv2RjD1meGZdsoeR7UFCG1vBumRDMjqb1nhLTI9JKYxkXu5YIgXB7+XGmSM9toN00yko pDcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Zwi9ddgs; 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 z188sor23982628pgb.42.2019.02.13.06.01.38 for (Google Transport Security); Wed, 13 Feb 2019 06:01: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=Zwi9ddgs; 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=XQSNSZywn2J5tIibcMqEyCRYg0DoENdsUd09NDa1qxo=; b=Zwi9ddgsFqc+aI6RdkAmjVmRVQY2kIKEA/goavGMF2UFBR08h4VxEcopFWUJ8ademS ZJOhPqL44qeZwQfJTEnpnw7+bU9w18GR7lIPaDoqZq57oox4meb6Xl74zzQ8HRGJgbov qInTG5TXVfyHQ4zMGO1uJ+vVConWVyQmndvdBQ+1MUmbcUjqQb5pD2dS7rqEHlwTiamY lH11ZOtRgcKEnG9eEW+nFs+LbEWXWyfD8JNldEEhi2Vob6oqD2b8EtFVXo+OCAXHAWRH MSbOIj/OUJgJkAbowIXY0GDKCpsjOzNv45CTvhRmag02UpXHiTn+BtsFC2GwTsr/2bQD r6oQ== X-Google-Smtp-Source: AHgI3IbSufXkNPVxD86rAOaQ3sWfm+MBjGYH5NlkKVhrp9RhHT/Mp9udXAimuDrAmAMeLxIHijJ1fg== X-Received: by 2002:a63:f552:: with SMTP id e18mr588329pgk.239.1550066497651; Wed, 13 Feb 2019 06:01:37 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id s12sm15439846pfm.120.2019.02.13.06.01.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 06:01:36 -0800 (PST) Date: Wed, 13 Feb 2019 19:35:55 +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 v3 6/9] iommu/dma-iommu.c: Convert to use vm_map_pages() Message-ID: <20190213140555.GA22045@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_map_pages() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder --- drivers/iommu/dma-iommu.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d19f3d6..bacebff 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -620,17 +620,7 @@ 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; - - 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_map_pages(vma, pages, PAGE_ALIGN(size) >> PAGE_SHIFT); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, From patchwork Wed Feb 13 14:07:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10810007 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 DC7641399 for ; Wed, 13 Feb 2019 14:03:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C70DD2D10D for ; Wed, 13 Feb 2019 14:03:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAAC42D132; Wed, 13 Feb 2019 14:03:13 +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 592182D10D for ; Wed, 13 Feb 2019 14:03:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 774978E0002; Wed, 13 Feb 2019 09:03:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 723658E0001; Wed, 13 Feb 2019 09:03:12 -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 5C6EA8E0002; Wed, 13 Feb 2019 09:03:12 -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 16C488E0001 for ; Wed, 13 Feb 2019 09:03:12 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id q20so1782252pls.4 for ; Wed, 13 Feb 2019 06:03:12 -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=H3f1MfvSqhk7fYk2/rKXnYTMr6+lbY/NU0rOXhC8O5U=; b=TsG+z4oxi0qtx9Ay48e04jc9kV6FsqViiDjz32E5JqRCESwxs90eiHX+p0DSb4sFY0 Swls+OFXHCiB8xJYWtdU8caRq4XcVz5uDI9vVDm35FAut5yDXycRudv9KYIWdFBPQ8eC iCFQJdLJ61BiqzKWzPUIw5EYsG/rlZ0dH8EC3RQoxH9seK0StUceC3/YpkJMoaqPmdvy xajMpDMMZG2Capbe8BiUIt1LfKkMbv50E8LrI5UI9Bsvi0LFpSPMTkWfOhMFVwn3/0/F 5037atv+MuzG5R9GMCyeM9TNGf9BwEEEHpVHHRzaTq3GfJ5Zt1M/teI5ED3WHjqP4sYy n1Dw== X-Gm-Message-State: AHQUAuZTUS41F4cPW0lkI6eUvKklF+XAAKVXeCEazlTXWl2ww/mbMlOR RH/VstodosF6CmdaOrluiSXNttSn9IRw23wJehBYjM4QpTn+T6SDmrhw/YszELOB+1bCUvzd6lu DukfnBJKGJZ8DN0KJSTNc0lNJrCEisAe7+7TUSR1wxAUnUoirhVYsXNOYe2zltlxCFNRcEAVPAK p7n585UfUxAJokv+/NJjoCWQwGDKkX0Dar4m5JGHFHpFRHCYoxrEkP+7bIfKiLi1Ra2VHJnsOT6 7vNjOE++C7XqIONiMIoIy6XV+swTkug6UaOpHPFqBgsDPILAtGGQg1PVcoJLHOT8rZ5cFz4PRgz MegTJCkytZys1nt/7tkZ68d6dIA3Q8/h7fCJuVCrP6fy8q99lCVdv2X4gnRGgGimvB7q2va8qXB s X-Received: by 2002:a62:1043:: with SMTP id y64mr700606pfi.78.1550066591766; Wed, 13 Feb 2019 06:03:11 -0800 (PST) X-Received: by 2002:a62:1043:: with SMTP id y64mr700547pfi.78.1550066591005; Wed, 13 Feb 2019 06:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066591; cv=none; d=google.com; s=arc-20160816; b=KO+YfERRAmBoA6yNBbsMuZGCytfHa4x+M9QXhnMVJBwrfQx+0M8vPIgN/Vxs5plw3K mUhYos/FM8dI0GV0cLuDxBJ38CTw0TiHz9F+lFkayTPmKxfN4EOSitwFTr9HGKF0NeJc umVv9EWMIp9UjM95kEp6xB3KDYZfaQCVWFj/H6p7hvmOVhPJc/ifBON9GHpaklEXtKVi 3NR2fmatRFqBuyTXLE7japXl+gvIjnFUpKI6ktF9Q/+6xfQgSo0e5eCRRQF8gIB1rGjS e0WD9bBEZiL63jZ4F/EFjUn99Sd1hpl9o3NCJxxLzVlZVcMCNXd+YR65PBap60Pc86R+ ujzw== 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=H3f1MfvSqhk7fYk2/rKXnYTMr6+lbY/NU0rOXhC8O5U=; b=sJbpbUQP78GT6S487a5Wrp9547VLeZ8iocD75aqEbNj08tYRgbkp/5WWxAyRfupExn TE4sErQmZ2DJOOAxQ+dU2RxSVufGqw841UXiIKIoGmjBbdpDh57+w4sYglMsaIfy7DZQ 60wtotFawPRhBpCH3fn7x7payW/w5YhBYFPxWMIn61eEHAX3IwnW/Eq9VuNk5/owswtI CeHpajF4rXta05bH42ja2G71Y0b6mYOXX/nnUQKenVJBEtyJeXjeM0ZwJlz5T4jrw91g FIhJENDB8gTPUHI2zDWNqBXCYl+Y2xgVX96oI++akhB7RxOdgVAymQqpnkciaxGcn8jr nlLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VpMiZSwr; 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 k20sor24608719pfb.26.2019.02.13.06.03.10 for (Google Transport Security); Wed, 13 Feb 2019 06:03:10 -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=VpMiZSwr; 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=H3f1MfvSqhk7fYk2/rKXnYTMr6+lbY/NU0rOXhC8O5U=; b=VpMiZSwr42h7RxTwV/fk8d9BvpQX7IxZRgpbvLieA3dNWhefjo4gx9DsgkSJxHG5xY wC8gs8rhLMdhakzvA7oL3jNRziwz7HEyOTtO2L3OQIzTamDfB/biwjzged3RE0GG3ATU xuWbBjt2GRG8opSicVG2QUTYyUnn+GGduoR+U6oEElaJScHfTOMoRrcwP5w0vms4QADZ 9VBDPI8ieNLKUwgTj1XSYpg8Ft8L5J7CWA6BmuBq/Ue9jTcjw/QWui/8DSIihzIKTXLv OQeBIirsIL7XlCwp3H6auQQD2MIsgvPcgl9fMY7o0nzmpEMK84/HhiQq7ryFqw3J6BLN P70A== X-Google-Smtp-Source: AHgI3Iak/rjAyAcN8Vw2WTjmvGMW4dx0H2O1oZmqXhf6ReElXpJJUKu4heHYpMVKWTk/KCbDtzDT8g== X-Received: by 2002:aa7:8497:: with SMTP id u23mr631577pfn.253.1550066590259; Wed, 13 Feb 2019 06:03:10 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id o2sm27533402pfa.149.2019.02.13.06.03.08 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 06:03:09 -0800 (PST) Date: Wed, 13 Feb 2019 19:37:28 +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 v3 8/9] xen/gntdev.c: Convert to use vm_map_pages() Message-ID: <20190213140728.GA22080@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_map_pages() to map range of kernel memory to user vma. map->count is passed to vm_map_pages() and internal API verify map->count against count ( count = vma_pages(vma)) for page array boundary overrun. With this count is not needed inside gntdev_mmap() and it could be replaced with vma_pages(vma). Signed-off-by: Souptick Joarder Reviewed-by: Boris Ostrovsky --- drivers/xen/gntdev.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 5efc5ee..7f65ba3 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1082,18 +1082,17 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) { struct gntdev_priv *priv = flip->private_data; 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; pr_debug("map %d+%d at %lx (pgoff %lx)\n", - index, count, vma->vm_start, vma->vm_pgoff); + index, vma_pages(vma), vma->vm_start, vma->vm_pgoff); mutex_lock(&priv->lock); - map = gntdev_find_map_index(priv, index, count); + map = gntdev_find_map_index(priv, index, vma_pages(vma)); if (!map) goto unlock_out; if (use_ptemod && map->vma) @@ -1145,12 +1144,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_map_pages(vma, map->pages, map->count); + if (err) + goto out_put_map; } else { #ifdef CONFIG_X86 /* From patchwork Wed Feb 13 14:08:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10810009 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 953241390 for ; Wed, 13 Feb 2019 14:03:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80D902BB00 for ; Wed, 13 Feb 2019 14:03:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 723FD2BCF6; Wed, 13 Feb 2019 14:03: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=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 160052BB00 for ; Wed, 13 Feb 2019 14:03:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BD628E0003; Wed, 13 Feb 2019 09:03:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0458F8E0001; Wed, 13 Feb 2019 09:03:52 -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 E296F8E0003; Wed, 13 Feb 2019 09:03:52 -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 9BCE38E0001 for ; Wed, 13 Feb 2019 09:03:52 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id t72so1917334pfi.21 for ; Wed, 13 Feb 2019 06:03:52 -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=F9hIq6OqtC1SVS2O3U7ZkPoLnNclA70DsapCWy7Q+lE=; b=nyt08jdY0K2UdNE4q5JvE+8HRGAN2/9ZYFp7lDFOmjk2XhEFBghGg9Fco4KBxoqJQq /7MaE74tqvX6IsfWvTzmi3OjN9QqTwF5dCHUIyrzbxp/GYgQ413VV3qB38ibo+LVPRCo FAwTnn5L9Csbynp32H4I5bnc3bF+uwsmyDpaqw9ue+ri2C/EabxQ86zGNZQvpqzBsIeP r8iVBAmWv8C9kE6OsVnsYfGel2eG0FdzmOD6ad48sd9s6sKyPv1EEEIz0X8cMt7nzEbZ Z9BgPqkSPKsyK7RqlpHHD8+IMVqorwXMUPutxjLEKK4FeaRQAwynZHVk8B1iwQYx9GXw 34cw== X-Gm-Message-State: AHQUAuaKS5Gmi9rq5L/3Lfbv/yotATNjW7q8tn5UJ5OejULtCd9VSCya 7qB+9J9Q5GWKCyf7pQfd7ohLiIMF65+MqQiVl3h6pEOoCbgVCXeBiHeBjqzpdRNvSih/4v4NEvE oS6RVbDfcm45L9E0EEb5jjtTziTAi+2+/xBlYaXT/SmomSJ37fFqSZRJ2XU/68mv4f6FLvz7/+H vM8Ho49P3xuloRec/eBiKNVmJvBbBC4xqiP42da/WuPIxSnBbsvldpjhw/3/yDq7UwurTXS6h2N /wagcDMqVWSoFvmRQBGnVtq9kiZIU7QUX3CnIJrkL5pTD43F4bmi7+SQJ8uEdTlTGES+xr5ye1H 9oGD37yfQG0MEqiUqJMnFH6RoDr7sWj9uoS/BT9M93i8DP+ETV0hyPfydtEvSxhGULw8mXftFF5 7 X-Received: by 2002:a63:4913:: with SMTP id w19mr617531pga.394.1550066632293; Wed, 13 Feb 2019 06:03:52 -0800 (PST) X-Received: by 2002:a63:4913:: with SMTP id w19mr617461pga.394.1550066631298; Wed, 13 Feb 2019 06:03:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066631; cv=none; d=google.com; s=arc-20160816; b=FZnzrJ9G3G9HF53M465WHQNbLYlCJwvr2CJ26AsVBREkTrKm7IZ5MFHHjwEwZyTiBc JS9W0TulZE05nNlgL3NdcNTFPmL2c3XLQIj69Po96CHowry5u4odAlook1KBX3yQP9w0 oLlhQ6Iy054HOk2lrN+sLuno2rCtlgOCXtdHlDrzuoa5Sc7PPOqWgjymvbECwiAx6T/a zTg7wEGrAkRryq8RjFMP8mzKxHFLeaBJ0j4OVlmHuHAmWGui07m/s3NcU7cb/FOhBPAC 64k0KwMKF856DB0zTXEtAujoL+R4gJxa5+RJGxSxfdq5FXWzU3pova1hg6RD5GEbqYq/ qTHw== 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=F9hIq6OqtC1SVS2O3U7ZkPoLnNclA70DsapCWy7Q+lE=; b=ak9NFKEQKGR9Xyx0igani5XgnjVTXB9HisGMybEShlUKzZwOxZyI3Ej+tOl3CuLQ55 nky23ADah2ZuKnacEumM6TqqwVkoPZkADTyXtOHo4J68DJ1E72R9pRisFzJM/zE7MFcz DdtfPQ6hb6PwCg1wZxeF1EwrIK8XdDsHkFWIuUjT5+AXKasN69csQk0IPwwR2mhlmIYe fSo250LD8B33tDrpO+grdz9XNe3Scqg/8Njz4WPRD1TnwiNfgnH9KpJ3++4vlMLBCnKc XIB8dL+NTNKkN9Vk2p08KIckFgmPeOr1+5x9KwBd+0BNyu1gq0bvE/GCPy+TWUlDaEAj OIFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mR1zb3ZE; 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 e6sor8959984pgn.60.2019.02.13.06.03.51 for (Google Transport Security); Wed, 13 Feb 2019 06:03:51 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mR1zb3ZE; 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=F9hIq6OqtC1SVS2O3U7ZkPoLnNclA70DsapCWy7Q+lE=; b=mR1zb3ZEg02mBIPkYaAVMZE66k5L2R/4wFfthpIKD2x3RXESd7eiszAW4r1knRLpTn wnxSzM8wZc5Mkz3Z49kMS93pCVbrKDkebiXliRr0MLguCoBBzx3UIY6gRbVSevX8sUlA t0TnCvA4KzIxDQ1NhguOdXUGK6CEp2PM35M5kw6L8CUGCQorsyg8koIIUymChKedDxwo wDUw7vvME3QeIWVpILxu3BZjyCiOfgTp+xlM8wcQWb2ioU0gaK0lIdJ+zNZxg+bA9B1c 6HYiTaKbvgyyQHIL08zPUp5Nm4UWICDz8npUj7KAUtwMGujiFlESyiR4EEVtAG0NSBzJ vYBw== X-Google-Smtp-Source: AHgI3Ian//MU/KECqqeVW28HKO0eOqidmv+3nYdGVBdjjqesuGGlM5g1X58lilAYfu4GeuswRHCPdA== X-Received: by 2002:a63:d444:: with SMTP id i4mr600550pgj.237.1550066630319; Wed, 13 Feb 2019 06:03:50 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id e2sm36513942pga.92.2019.02.13.06.03.48 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 06:03:49 -0800 (PST) Date: Wed, 13 Feb 2019 19:38:07 +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 v3 9/9] xen/privcmd-buf.c: Convert to use vm_map_pages_zero() Message-ID: <20190213140807.GA22098@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_map_pages_zero() to map range of kernel memory to user vma. This driver has ignored vm_pgoff. We could later "fix" these drivers to behave according to the normal vm_pgoff offsetting simply by removing the _zero suffix on the function name and if that causes regressions, it gives us an easy way to revert. Signed-off-by: Souptick Joarder 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 de01a6d..d02dc43 100644 --- a/drivers/xen/privcmd-buf.c +++ b/drivers/xen/privcmd-buf.c @@ -166,12 +166,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_map_pages_zero(vma, vma_priv->pages, + vma_priv->n_pages); if (ret) privcmd_buf_vmapriv_free(vma_priv);