From patchwork Fri Feb 15 02:42:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814103 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 EE3E21390 for ; Fri, 15 Feb 2019 02:38:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D97292F1DA for ; Fri, 15 Feb 2019 02:38:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC5DE2F23E; Fri, 15 Feb 2019 02:38:25 +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 E29512F1DA for ; Fri, 15 Feb 2019 02:38:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01A578E0003; Thu, 14 Feb 2019 21:38:24 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F33958E0001; Thu, 14 Feb 2019 21:38:23 -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 E239F8E0003; Thu, 14 Feb 2019 21:38:23 -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 A5CF48E0001 for ; Thu, 14 Feb 2019 21:38:23 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id y66so6383591pfg.16 for ; Thu, 14 Feb 2019 18:38:23 -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=hAc0IiZ5Hzb6Ahh/nnBBBrsOZQHU6iQhUhD80XgxLUwvSWYowizWZHhPuwTapjkPH6 h+DWMQChDb/Xmn+T3iRcZX9skc6sp4d2ba9F0/rsvo5Jy2bkwL2lJJf2EjFvQWu9tFy8 AqqOGVCmjex1WhJnLw+KZlPzKByP2lCkWB5jRJO+RRN8aGeKwZIrL64iwVIjNII1nv+n BN4iNWz7u614io7Kmy2yJdbTtzvB+WwvEMb59f2E3h+TpFH/tBSzcr0+GHeEjTVgoHOu eEGe70Fl6nRikXaHh0HltL+wD7Wxt0FH+OEVnmNNHoLDZ5lD5YGnkQ0TtMaV8rDklxj1 KEDQ== X-Gm-Message-State: AHQUAuYj/0OBkRJioplifFcAY5Zy0f+VE22qocUGnbgzMBRD5DdK7Puz CATN37AFRb0Ld/4iL3ci3jFWwf4kL1ElKfkOqnvLIhZvfihyfWRKNaqLxMxyBknmwf5xRFxvnOK CWiOe2JlZVbSopbvXiEdMvlMJOgzrJm9BxpnMA6LDx4LEdvZf1Iyml7p90rDjaGkz9AwhFgEpWo M+0wI0FEI1qzxlPqQ9/Ir+6aqWRWxRQ6TOUQZpUkQD05V2qW+curQDH14OYiQHcD0xbVYuS/pFz vsmcBRcIER3C4d0Us2AYQSaRRsIYEVwZFRWoic82m6lqTQLW+q7EKKAqMMATkktR3ABMFFmWk4p AVKuKopsxoCU4iPW2lRaeAx5yXgCBttUtAIoRs6ZrxD+6ZD3gC2yHMeft6Ylet6CocVZgMN/9Xi z X-Received: by 2002:a63:5153:: with SMTP id r19mr3104610pgl.281.1550198303267; Thu, 14 Feb 2019 18:38:23 -0800 (PST) X-Received: by 2002:a63:5153:: with SMTP id r19mr3104556pgl.281.1550198302309; Thu, 14 Feb 2019 18:38:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198302; cv=none; d=google.com; s=arc-20160816; b=oeXZ8FSEaDw9e2DdRPNjg1F+rrZr3EL091vBQGX1tjQndeTLoGBYiUNj1Q5Nxbdb7S eEE7RZBa0QlfnaGN6jERQpgyQnppBGCXgFdimY3PjqqGrJwWIuUoydIaFq8pFVAf3N+b HBjnZH09muAxsjJky8u7oHpHyYEine9mljmFsYgEjo3czr0+mWUe9RdAVN1+1EZFs93Z fUDMx0rHv4kx4D7S/GdNZC99I4r2VkSpXhfszDks9LkOOjcDaq7S0ggIRsPxbKPWbAP6 YVVsLsU9o8G6DAbstPtLHgG/nrEUcJnb7lNhzU48QxaYP34uXYWl/k7LBLCWUT4MY9ik LzCA== 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=cNkVBT7mZR422bWaJvypcM9JmC5X/9gGeceDBiONKK91bTJM103kfTUEoWlQ6bu81G pgQw4H2zPq5Cs4TkBWwGh0p2D+UGmBdSB0ecvu76Y7b7IBea1dTyLIzaWbPuzqHX07jq RMr+Y7AUO1eKQ7XpESQbbIHxrNk4oGhBWNTjP4xCF/2k23h4UwQlnjrJgVvPnB+0k6Yw nQ8KWo/OzWsYl37nqFp7uy+/bcOzymG5NGEY/VRfTG4J4EG9wPmMVxu/E2ldzxzXmnFO 57bfoj6FeoV9MW8QsxrtrMD5LQXCp/kJpfW7bUFEGyvxilFm9MHCUPakV1ibiq22bSg2 +veQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="SvKO/8Qu"; 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 b36sor6687186pgl.8.2019.02.14.18.38.22 for (Google Transport Security); Thu, 14 Feb 2019 18:38:22 -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="SvKO/8Qu"; 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=SvKO/8Qua3oK4cc04JxBOABmX9Lcs7OlPSis//wxrWJYxpUEEW0AwWfwFg7XPPkM9+ QADPLQsqmaC/p2ZufsCfS3Ge83uGWPUWE09/20bfO/mh4I0ezFUGT63uVWuoI3PWUc0b 7tkcSKGPRr9Z/G3N+gPRFwa09FtMiLR/oAZZ6Nfw3V/23rM4gjawS+m+B/f2q95GXwF4 DG85JqW8Awyst8kSFZ/+DNXV1GycMdMZkuYlI9X+lNzCnx33LVj20wM0JmDE1ZhBX9ye ahW788DDSK1er+310WveH4ER6u0KEwCb0tkfiCK/ym7po3kDquKXj0FnrzXnfMhf5v6s OI/A== X-Google-Smtp-Source: AHgI3Iba0jcQFwegqG4NLDbZHaOWcAX7sXcmudyJYCZAfU2Rx3rH8jIxfvL/3yVO80UpTMBO9iuHZQ== X-Received: by 2002:a62:e704:: with SMTP id s4mr7409860pfh.94.1550198301951; Thu, 14 Feb 2019 18:38:21 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id d13sm5397358pfd.58.2019.02.14.18.38.20 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:38:21 -0800 (PST) Date: Fri, 15 Feb 2019 08:12:41 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, kirill.shutemov@linux.intel.com, vbabka@suse.cz, riel@surriel.com, sfr@canb.auug.org.au, rppt@linux.vnet.ibm.com, peterz@infradead.org, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com, stefanr@s5r6.in-berlin.de, hjc@rock-chips.com, heiko@sntech.de, airlied@linux.ie, oleksandr_andrushchenko@epam.com, joro@8bytes.org, pawel@osciak.com, kyungmin.park@samsung.com, mchehab@kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, xen-devel@lists.xen.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org Subject: [PATCH v4 1/9] mm: Introduce new vm_map_pages() and vm_map_pages_zero() API Message-ID: <20190215024241.GA26350@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 Fri Feb 15 02:43:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814111 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 7A48A1390 for ; Fri, 15 Feb 2019 02:39:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 664DC2EA65 for ; Fri, 15 Feb 2019 02:39:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD0C2EA6F; Fri, 15 Feb 2019 02:39:12 +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 F25A22EA65 for ; Fri, 15 Feb 2019 02:39:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 328008E0002; Thu, 14 Feb 2019 21:39:11 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2FE0C8E0001; Thu, 14 Feb 2019 21:39:11 -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 1EF6C8E0002; Thu, 14 Feb 2019 21:39:11 -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 D0D0A8E0001 for ; Thu, 14 Feb 2019 21:39:10 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id a5so3104821pfn.2 for ; Thu, 14 Feb 2019 18:39:10 -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=r6vAt/2/gQNPea/HeVCbVzHkeKAxssXtmW+6owRf+rf1lewSrxA4YksfwMX2S1fDJA xIPDZpgom4U8vME6yMOCk3kLt+zLc7h0u1k+a/KZX2QFanA3utWy9Ru27s+fFwTn2mOV MiGW9J8WegSm+Nn75aLBLni3sMOir55ZMZ9Wju4dptwKri0KJ73beFbbag/3VoiURm+0 CyqKgYMFXFOg3vEbgmYz7NSPOnpZ/0FdRhxc5+nJCtJfU60PrNBokR2hUc2RdVEAFySF LfZ7h7xCVpHh1AsolhKb9W+J0D6mpXI6umJU7g7abKpf73a2RFAoynDOo1Y7r8jClgeK cnqw== X-Gm-Message-State: AHQUAuYjK/93SGlk5xnD2E0aKiuuKONDEuib4Xcd1ZCr5tzHfjh/k4Us X98DcaF+zjCUfKS+eX9H2MxJ/lftwDchewV3hRImqEvGNMiDnHG4Mxm2H1i92ERArN+eR5bl6PU 3sDRyUgvmjH7jfJXAyMIHnhE8I1T/k7uXezGQ3fd1b1YrUkfM0WpekL+cO0iJxtGf+UNEtL+NER hUKBlC8ZFMVCBdbENfaV8+sMO83pPbg7QBxwH4RWYWW2d9YwAkJ9WGGHU3fFInflD/ok7DrRq9L mcfY6iArIu/JHODl0aIuEwXRNHeVF6aROHs/CsB/EU68TJeD2lNnHSgIoL2HxWISMKfaabEHww6 y9pnydV08d0nyyfqyblpI+PUd3MJ9zG2/yhYcKm0DbR5HILUnJ78aODQidexNUOYuwJKqmuvTWY F X-Received: by 2002:a63:d50f:: with SMTP id c15mr6968408pgg.287.1550198350536; Thu, 14 Feb 2019 18:39:10 -0800 (PST) X-Received: by 2002:a63:d50f:: with SMTP id c15mr6968360pgg.287.1550198349777; Thu, 14 Feb 2019 18:39:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198349; cv=none; d=google.com; s=arc-20160816; b=JJPdc8rov9qGRAgR/YKbKZVWa7A2lkcxTEgULMykWx0OMcG5sWbJevVhG0txr+4zmZ 2a40xIMKFFNY4NHPeUHadcL457WXAkLQe5AFMhCtTuX7RNijaAQ58FLKrMu5c7/8u01/ Bn0lsFxkAbmDDSD+BeviNeIk3RlORftPYvhqnmuLTST1jUsYFubRhFjHC27vZG4nz4f0 tDlt0IzwD6kidM114tkbaAY48RsuuCrFtp5w5S6l8799Ee1ZbPlDJ6fnENeB/iNtJLDD SG0y3M8F2GoXFaodW6Mri7JU2mt5aETYB6W2PA9WxmypXnFotx2AabXQASPWVsHgUvqF OY5A== 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=MWhM9rU9iZ6yXRJEQo8YKWs9vZyb9AHHlbnSoqGlh4jkIVvgK9XlvGIgSirsEMRuEW M2vg8lT9iO2OA5xsMMUTQ53vpSoLjHfJiT9GBv7s2LKuCL3kLUhpLp+Hu/31ZXzARFE1 mfDGVDIQjQsCPoONZW29vDS8p5JzxosWUUmXFyuJYcDesdP5ElTtWWBcsDwHeIo5DrNH OggtTkeYe8DEoGdHaOf9Bc/cEJe5/mgQICEbV8YhrefhoNiQt6xz1ZmWVbU8aslQaLwg 5H/wLRvplXSul+ApneXLDpfxMqftqflhVf9dW1hsC87oc6jau62LOsl3wC/tU5Im7JHq lEsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=C8J8YEaP; 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 h131sor6773321pgc.9.2019.02.14.18.39.09 for (Google Transport Security); Thu, 14 Feb 2019 18:39:09 -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=C8J8YEaP; 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=C8J8YEaP1sXar/+zW0yONM/GThKVOZP43UoKx+bsMs0rR+kOwbwuiT2BIDoESBLxKN X6AH8lyLqHVlJ3S1+7SjnEjca5R1G8T4RFnjNToQO6v4YNaQSQSNkLbvxe90zZykLVDi 54ov/SHMO/cZOMqPEs91uSOr6MV9wmu9R1mZMEKYCox3q1ABu4U+roRJf/5xpBsTlTDO KAmeeosjCfbEhSgpHYgu6X3qTk/lRll1yN/eR/pYc5h5Gznm4xGDGVTvZ1VW0BjA2yKi 9shB5cJBIHEFyFW2Gn9ppb3AKrv2U+8H26GIKZ1mUlV4K3ypWZYz6UbQihzp+r6bWUJk St0g== X-Google-Smtp-Source: AHgI3IYPDJcfAJcux7am1/kgkI8RGRJz/Eho2e26RlxYpln5H5W4x8B/Nfk9OSESdiI7mMZpfEdzLw== X-Received: by 2002:a63:4b12:: with SMTP id y18mr3125993pga.340.1550198349469; Thu, 14 Feb 2019 18:39:09 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id t3sm4758131pga.31.2019.02.14.18.39.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:39:08 -0800 (PST) Date: Fri, 15 Feb 2019 08:13:29 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 2/9] arm: mm: dma-mapping: Convert to use vm_map_pages() Message-ID: <20190215024329.GA26372@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 Fri Feb 15 02:44: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: 10814115 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 1748A1390 for ; Fri, 15 Feb 2019 02:39:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0330A2F27E for ; Fri, 15 Feb 2019 02:39:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBD302F297; Fri, 15 Feb 2019 02:39:49 +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 8B2802F27E for ; Fri, 15 Feb 2019 02:39:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C00DB8E0003; Thu, 14 Feb 2019 21:39:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD81D8E0001; Thu, 14 Feb 2019 21:39: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 AC8AA8E0003; Thu, 14 Feb 2019 21:39: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 764188E0001 for ; Thu, 14 Feb 2019 21:39:48 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id y66so6385789pfg.16 for ; Thu, 14 Feb 2019 18:39: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=naB3KMuHNTCaDD6/Z64EGJGrk7XQ7GW1pzVQ9Q3Vf6s=; b=T4UjB4KDsGJj8a3L24ZlIo6TNadpy51d/FguI3WLTISyEeP2iSSSSudqj2BZh8BH3z +T9d/i6NTgNyBZ+zbrnMhnio4NEwNXIVSB7mZen/BlbVDAsVZSCd4VBFZ8f15y63p8et 9xwleMxhLf6wMHUhCRsseUU+H/BJ4jTB64iPwoC/JKW1vJrBeIQQvA8bg8mT/q1kn9UG KfimOoMv3mM36ADWrTL6+QF/79bsoDpsx6P0dU3gEwo7nNoNTfARJ7XmjcBpiVdyS7wM ehmd7CwioDMWt8K+fW3efIgp6GVqoi29Zv06wL9maRQSej2jLTUBV5Ul51nXIJsRTVkQ iE0w== X-Gm-Message-State: AHQUAuZIoZiJsUsrny2oo6SZj+elA4pEgyTxO7gDALSenAvgTzm661p3 j74Uuhn5ezz0berZgSF9zum2iBB7IRkOMVTNkDIazrGheQ5BnIAdiCJCP3IwpaJdtJoBvNUAmpl jxz4ozrU8qU54yH9IoIIWklglb9zgLu69g3CWvV+stL9FpTfLHTbrE4WowwpWgpvCJdl/HOkYrv Uk/GtadxBJREP4M8/WA7/z2mXIRYtLs/jwKghSuZ/+otq7YdmO+8FsxlcI2gac78cnrOcApQEVC NsQVOMRUBfv97BJQVgUTlAA5JDVnlAk44D9lV7YADXiU3evtjM05Gv1tXv+6+dOHHA5m0p5fEoI 6siObRKz+1XrsaRjmOe903uCbk8Wsh+bTMJLxgRlt6ot+H7qcJ6KCXuCS9pp/SrpJbEqUCOp5YJ r X-Received: by 2002:a63:cd4c:: with SMTP id a12mr3146156pgj.252.1550198388165; Thu, 14 Feb 2019 18:39:48 -0800 (PST) X-Received: by 2002:a63:cd4c:: with SMTP id a12mr3146130pgj.252.1550198387544; Thu, 14 Feb 2019 18:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198387; cv=none; d=google.com; s=arc-20160816; b=N94lrJHH/frwQmnjou8sbz1xisNpMutoA0BEf5kzny69PpHIjb3Eyv2+zmLDzXz84q YMzwRS7iMGfVTxPcLdZIjCMZ+95feKQA9iga3p0ON89cNjmdjBcpl4gbccm1A09/uuuu 1qjU3CFepqUMfV48kC3SlmxAn2/MFJK/CPgVM8u2L0fKujkrVf1kjT4rCM/3xk8EV+gX 7IN56AogXrurfSARs3dg5ieQYwJFJAcXqDkDdAy5lQdI34DYnaVBszUW7gd9UOVncepN jNyceakG1O865APQkt0NM8i3/PObq7bHdE+xfa6mtkkFUrOSzpzSoQsfA7HGgIaygw+/ 9Ydw== 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=tAwt1lFGrMEIVGgPaKhUwbsRnYJ1gcUyvRzkb+ZFo02FoRY5CnNdiLfNiFFcFhUgTH Qo4vZBPsDlvfhCaN7QeeVsALXGHbvR0TBWSUoyRFL6o2PovNmAOXiPGwvr91BGexj6zc OUlXLUiyW2TVe+A1JShGow0A6CnPJ/8A0HO2W2ndovMMEuEvBDW6+F0hzjVcAAhVRVSN WY26YZIWPHQM5SjRC3EgVr0yDNs3frZG+EJXEATF6HHCZMq1lHXLQp/N2Apk29G7YF1F l2kDG5fSqDipyS7PCnoyveqpBRSmJkSZ7hVg43NeBZh4Fm/+dig26d+UG4BrIOU7sVcV yuwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kLj6pOyk; 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 g16sor6555673plo.1.2019.02.14.18.39.47 for (Google Transport Security); Thu, 14 Feb 2019 18:39:47 -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=kLj6pOyk; 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=kLj6pOykfXcUG+qvmp8kJ2UtHrXBRj6IN3Rg/liMZsHGVPGT1Cp7dMXvFmX5uZCSeY B3KIkeIYAm0k1MB8GKNJ87FZ4Vy695j5l38NPs1xFMYDCLZUvhkvGy1mlKkfvT+k8GQ2 sxhz7j+Ff8zJlO1XPDqtwuLtZpw+ZlgXtuuxCDdo1lQuxcTTQZL7hLUUEsrmJDB7raae ML3zxRkAZIlYzUwLc95t1N0v/NAKk5JyljdPIuHYJC9t4svAJVwEY6qRlPpJWfd+8Y21 tfowupbrIJH1YLp3e5fxV5An+XpPk5PkF0zIASwVxYHrVgB2K7TOXw9wK0KqNnd5f49U yn9g== X-Google-Smtp-Source: AHgI3IY7ZJP/9c0JvwcJkUpHOWFlwfJrQShpMUSfzKDJXptrzyrCoFV9i84p4XJmD8juyeubZ7QRMQ== X-Received: by 2002:a17:902:1:: with SMTP id 1mr7294631pla.276.1550198387177; Thu, 14 Feb 2019 18:39:47 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id k1sm4194873pgq.45.2019.02.14.18.39.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:39:46 -0800 (PST) Date: Fri, 15 Feb 2019 08:14:07 +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 v4 3/9] drivers/firewire/core-iso.c: Convert to use vm_map_pages_zero() Message-ID: <20190215024407.GA26389@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 Fri Feb 15 02:45:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814119 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 AB29C180E for ; Fri, 15 Feb 2019 02:41:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99EDD2F460 for ; Fri, 15 Feb 2019 02:41:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97C682F3CC; Fri, 15 Feb 2019 02:41:07 +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 28C502F3CC for ; Fri, 15 Feb 2019 02:41:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 520E98E0002; Thu, 14 Feb 2019 21:41:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4D2BD8E0001; Thu, 14 Feb 2019 21:41:06 -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 3C0428E0002; Thu, 14 Feb 2019 21:41:06 -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 EFDB28E0001 for ; Thu, 14 Feb 2019 21:41:05 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id q62so5794297pgq.9 for ; Thu, 14 Feb 2019 18:41:05 -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=fkK0V/reyLTTxAbdbBNdhE+RYUNUu8F1Tbina4lG6z2hMu+RZWGNaWG39Gd9Z0oKhC BCayEdOaBxdLVmS0sAFl7iVcbjjNRHso7MyktXQ2YLEFF7zR/XAKtWRqVX3VFP0n+tza uIlTD/i1b9R1ACOTvkkHoxQ/N4ZTAElvCCHc5Q40J7gTDzIvDc2J8Pm2eZVjjwYyp1dK EVpoXdmuad0nbNqG7y3E52yHzXdopPrevHkHkW+w/EMV7qXhZugiPSgdi9uxmglJbSOe vRBmYF/mzIspQV7XllXZsYZIk4j7AVo5gPEPfLXkGZbIkMlCWwMpF9A35rlPLeo/h+XB wpCA== X-Gm-Message-State: AHQUAubGG8L3mYHpcl7s4WEHIn0bOJRJaNMkRozkG5Yq89cmpOja2659 qsihra8kphMQ4GU2dhLevRihnKcgs+3aqx5nIuejGICga1t7MnKchOgSZOB9e+F4RS4dNxG9bDx hphOdL14I3p9Vg/4kVp7k0pdqDFba6e/OJI5BijQJCMOQn8fAgModwaFhTJtZqKDf7CERVyxpWO KeM5VQl6fHvanNBqrJV1QhzPyL7UofrYHukfs+YeTc4y0ZaCPi0bZKkw0gADePgq7sGoUxgeV6V IfsFXk8ymhXJjQtk4FiDdTf3Km+7w3qE8ew/TR1XYZI45SMq1R1Qv/pSdLFO3TkLCOY6/pZfJI2 S2cVaM0S5ZoO2805QMxpme+lTgUxEkDt5NqRTG9aKA7v/9dHkyjG++cLkdeLy8c3urJfAyqudJB i X-Received: by 2002:a62:f5d7:: with SMTP id b84mr7460426pfm.36.1550198465657; Thu, 14 Feb 2019 18:41:05 -0800 (PST) X-Received: by 2002:a62:f5d7:: with SMTP id b84mr7460378pfm.36.1550198464960; Thu, 14 Feb 2019 18:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198464; cv=none; d=google.com; s=arc-20160816; b=e8tMJ1poGplJN5MJAwNxQjahFKhGpem25MM7QYnUn6rpm0AR27CdXxegtvXmtLovAI dgFlo+iKr5g/LSX1nu93Cq2uYCXWUGz+Q9STjT9aDjOPcto8+l/xVuOzKuv1hGTt0gYL oM54vRCKnd/AhDOXGrUPx77agVYrSGnq6K8zODhtYh8L6R/CmndVTyt2omKL+VIVuyGa 3Z5cjoUPezKkQ76s9mNOXMmPbPVdknKF/RcIjjtTP3uSOgNme+0U4puiPj8ilynd4S+b cevAUUnqcUDrjjfT/bYcl2tTh7lQGIHfREcoZGLL8nHfvkxTEgf1Nap04bl3e6DdfGED JO8A== 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=APPG3e/Kv0mtlje5grpEySKN9zSNyhbJracZYykHVewvXiYHcj+nVIO4EKPeam/b5U 48+CmD1bPmbq1ge/AO2jlE8Yvqv6g/+ZwRM+GBx7VJtNT+9lrt4UETs7BjQDodK7SM+W Cl5aR1sFIWPa6XwieDGeirI5ySsFT+rfZ6vGtEc4u4gWfn/+GiPRkpajWucHPclBtaoU qBH/KEoQ6rzQhdqb9K0LOMTAX9q9oFBSeS2Kpb2Vd3MCqEZ31XAmYc/WRfvS+ssKbSuZ s9pna575QAAPu4xC35d89f+3K9ANqbpIWyszaAyqDePE6o8nYhL5nSGG6oAHBBfLRlkI ch3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PZBET/v+"; 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 91sor6555755ply.13.2019.02.14.18.41.04 for (Google Transport Security); Thu, 14 Feb 2019 18:41:04 -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="PZBET/v+"; 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=PZBET/v+AvTm5uI6YhLQd/yhp9OJU4BXs5QA0Gv2/WEpddBD1QACIx3W+qj/R+DwpM B3BzpTqjks4wX/579seQjUOZNkBasPTeBbzS7Ts4S8uR/gAobhLKvuuBjPvnZ0p2M1+e UH/Gc2iPGBMYC4EV/ODk3qG1i7BTa624G4IbAyHgpQom75nwKU1TVfguAY8NM1SpQhag t/bnF90mVuhLmHwSRidYkQGL4uxY7KCT7jqdywdvHspXzYeX6exXlLeF+WVbzBFla7Za xrpAZoUBgGaI0ABuhCyNn+4AoykbvyaUO80m2jJbnwhHLhgC8kP1xoZ96ASplt0w6m2V UyKA== X-Google-Smtp-Source: AHgI3IZkR4bUjIEoJN1Iweg1I643mATKe+Qg6hd5B30hfMqsOz0sR+gJKonzI4eh8rnzPur2hIb3aQ== X-Received: by 2002:a17:902:d83:: with SMTP id 3mr7519491plv.43.1550198464676; Thu, 14 Feb 2019 18:41:04 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id g87sm9521109pfe.43.2019.02.14.18.41.03 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:41:03 -0800 (PST) Date: Fri, 15 Feb 2019 08:15:24 +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 v4 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_map_pages() Message-ID: <20190215024524.GA26405@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 Fri Feb 15 02:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814125 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 8A3231390 for ; Fri, 15 Feb 2019 02:42:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 796332F46A for ; Fri, 15 Feb 2019 02:42:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DB822F488; Fri, 15 Feb 2019 02:42:07 +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 D7E352F46A for ; Fri, 15 Feb 2019 02:42:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEC7C8E0004; Thu, 14 Feb 2019 21:42:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C71CA8E0001; Thu, 14 Feb 2019 21:42:05 -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 B13288E0004; Thu, 14 Feb 2019 21:42:05 -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 68D6C8E0001 for ; Thu, 14 Feb 2019 21:42:05 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id 59so5788091plc.13 for ; Thu, 14 Feb 2019 18:42:05 -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=Ffm9ULQ6h9rWR8LY3P/l/L2jmZnHZP90ilNhPf0R6oHcUv8LbcbYO0GZOnInjWUmob yDc8eFiwdYhKf/YaP81hsAQbk9+rWG4E4l+NMdQhAQy2DfMR/Q7Ux6MYWIklMLpRWx81 Bwaw22zFAtfTFTYzg2j2LYHIR62L15ek39C25iN+V+TIGE8F4Sb/liF4LDb9li4JFByS qu29qDWHTjCKuEyGiZQ/fr7YZS1IPZjoegZ9BSWgXv4KEfeyUOCbeBrpEqvBq4Zji8Hn c5KPYBQBEmRmZXQp8bhfpCXbyZOpD4qtIuw8BqXRAEXErGTkJ+ugqPSTns+8PElSQLJr 79CA== X-Gm-Message-State: AHQUAubc83lGfkm0avaSRmZwQV/vYrleXRec0wFkzBvehdgfJgjflq56 QP5Ow1PhBVxNbMf1DmmOJlU3pBut1WYMp5OGluPZA8MfR0V2AJdlGfvYxvPBK1CuEs7iRWnXCkG rZOkq8r10yFje4rRINA1Y8Ar/hVBIYrNIXfO0OVeKKCLrbO9zzbgmw4syIAKLwexklJ+21NnW7j 70i8Wswq7/E75amDFU0I6HMJfSPFAzGn0q/7+dfv6HzrD7XS3OylwUJ6NE+6BX8LGXvyYxSjNWp Qw5Kz7Ihb/fMlQiCrTCnDaKFTXMy4sst6IJbWFdpG5jmEYbS+cc8NfPk4H/P7eYzqdvU8rwyJVB gTGhp54f2mwSQjrc6Zwd7907c1JRkEnvbPnxsUmRtN1O+WA8g2oyS/7ncTOERVdCWpRVCkdmhRR u X-Received: by 2002:aa7:8c97:: with SMTP id p23mr7585349pfd.229.1550198525100; Thu, 14 Feb 2019 18:42:05 -0800 (PST) X-Received: by 2002:aa7:8c97:: with SMTP id p23mr7585307pfd.229.1550198524420; Thu, 14 Feb 2019 18:42:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198524; cv=none; d=google.com; s=arc-20160816; b=aWhPmOzVsSFNkEIixyysNMDq+wroumjNdMw568UAtExng2W1O8ChWQgvgYHS2eM9+0 a1XcicxRET3ELt7PXXzRTknvNEleWAnfOL8oxO2od9LRv9+0T+mp3YLc75iYmS3Ldujb aIAVSgqEN95B+ROXgd58BAG1TiPoK6HKZXoohDhq15FMGKFtfnAIkTg+2dxBP+BhXSth 5d6XumxVFraBb+j7tNfARfej7229TLPNVJfBB0gSd9J2iiusJHZ7hax62oyMM9osozyo ApAmdXndlYt1zZnsfDzqZJoHMz41v7lLXu9H93PX3p6HEtD75PXU1VlNT7GkzM/lgaa/ GSfA== 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=j3Ud8gKXPRe6JEDO1gmjPaSNecToMN0/AKTUQyPkZ2ALMJS6VtkZLwKfD4wedDh0h2 v+y1jDvp8OIeiHmg7siy04pMjnYJFpT5MjzVJV4OoTnF4F72NbsuTCzHek/oBB5Q5XMg rYd5DNjXcZNL0D0yhVoOegs3HH1UkMlkslT1gQmGfLxSD3z9AyFtBfgR/B1tTwaY3xWl v9MpeS+2t8CFjUXQVkpPgTAumKWSqaxtZo+h1Ce34PKo8OEU5JOunXCtL1/Z1XarVo0p 8b5/twnAoj+qz535suheePPnpfnH4n7MHpL2i4A/uwqLXe+lLiYT4no5CxISR8UeS/2s WnFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=foVgED8Y; 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 j4sor5702823pfe.25.2019.02.14.18.42.04 for (Google Transport Security); Thu, 14 Feb 2019 18:42:04 -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=foVgED8Y; 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=foVgED8YU33cGUdNyMsYu1taL/xGldIA8jDJx5x9y9I6QigtUvC602CKjwOr0ZsAS/ PrLVwNvSCYqqXgJkNNgsj/JW4o6PWnnMVV+sOZHXGFsGHwcW805LK+wgOzI/x/OVBO8m OE0NJpOQoDOheB7ogbrxz4yXHYX8Q4ORkgGb4p4hR8jDn2jxBGx513wY4g/BSbtUttC0 +EUbqxPKWKxaEIwFfueP5dYGJ5wiFaiaVgytXN65xCDqGoDPEgYzQajnm8GLjMI6x6lJ uIsXrJrh4nv4qyfZmh7llHMdCo3NwZqLV9pBFVPB3QNi9ryMrkqN29sj6ImJovEthc7N Txrw== X-Google-Smtp-Source: AHgI3IY09of71qEdGWmLQ9N0pTJcuq75/YFXp32CyRWU1WZj24MjvjzhxprXcBsoC8HhuoJWLmu0dQ== X-Received: by 2002:a62:2e03:: with SMTP id u3mr2225821pfu.257.1550198524099; Thu, 14 Feb 2019 18:42:04 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id k19sm2131657pfi.126.2019.02.14.18.42.02 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:42:03 -0800 (PST) Date: Fri, 15 Feb 2019 08:16:24 +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 v4 5/9] drm/xen/xen_drm_front_gem.c: Convert to use vm_map_pages() Message-ID: <20190215024624.GA26425@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 Fri Feb 15 02:47:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814127 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 BA6A513B4 for ; Fri, 15 Feb 2019 02:42:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9B4A2F498 for ; Fri, 15 Feb 2019 02:42:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E00A2F49A; Fri, 15 Feb 2019 02:42: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 445942F498 for ; Fri, 15 Feb 2019 02:42:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CFF18E0005; Thu, 14 Feb 2019 21:42:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 657338E0001; Thu, 14 Feb 2019 21:42:44 -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 4F8BA8E0005; Thu, 14 Feb 2019 21:42:44 -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 116698E0001 for ; Thu, 14 Feb 2019 21:42:44 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id i5so4911483pfi.1 for ; Thu, 14 Feb 2019 18:42:44 -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=lnqKi/9yHx1Cjuo2cKS6tihJoDHuz0pzs1Zxny0B1lfOA2KpsYSphRI+WEX4ERXbU9 6zZVRXbenia9B0WCQxisLMOEo/3ztroOLsHkoTxbkWMbaY6rCFskH8Tx3EMJ5Jq25g4t uXsxvxDHLf5F+i4M4crb3e8Lt81oW9pnig+NtnlQvcWTnKOEAsufUe+lg3Ohjnzf7QLh II1BYN2ODsMN1SyKGQoQUkSA3CpkOMjY9cSJuZ/syd0uyfh2R6nB8EzRKDBsF+EE1NSg AxlJUj63IPpvZH9qrooFsvt6xtKenEGNt9qVtdTibrCie0SoWxKgsy48nXvqR1UlWPNn gHyA== X-Gm-Message-State: AHQUAuahuUkD2TSOmQ2EMykn7ex1hcBbSB8UUhWHsvMvUwUhtfbYIXg9 egLpPXiDzOqXD+9elxXpzQi9CtspP14yWLmDQKNJdiBOrInC1FRPPiCshKbUsub41wevs2raIFb FS0VCFR6yD9fT6uoD6k0gMjZ+hhF/A5x3GZI90UW8nThy3TgX3R/TmX8dghPCSVT2BzMlIrhj9n lY8V+oiSRvYRQn2vLSue8VUjrgbikTmSWNwdRg8+GpVRRZGFij+BYHx8ZbeZVBsQintqwQMtjnV L/DG/rWcIlEztYjAzGOa/gNQJ3TqZQ50E+f3u6fHNTSkfzXvQ1vgGM/oTjZ2AJHsl/sQdKd82m7 X/wSMJCNp+FCCKcpn35IF0cM36AKmykN2O6tphvUR0LLxbUJbSHw77K68DLzNPHkxZUjY+hAliK i X-Received: by 2002:a17:902:4124:: with SMTP id e33mr7681474pld.236.1550198563757; Thu, 14 Feb 2019 18:42:43 -0800 (PST) X-Received: by 2002:a17:902:4124:: with SMTP id e33mr7681440pld.236.1550198563135; Thu, 14 Feb 2019 18:42:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198563; cv=none; d=google.com; s=arc-20160816; b=tB7oYnx4d4sESPU2LPXMiIHk5EjrUkJCeDL7O91x/4epdBgTEQvcdMHya/cbVUPrKO N8xeWtee2m0Sur5RG0mtvAauB2ZIfsCnYBYTLadgiq1DsahOuyuCCBC1jy/FwTPrnXXy rIidx8fPGrvmSOmEdPdYrvIk9ru4BpHyZSV+NNGh72BR4iJxJZBzSIcGAVcaUXH06WDg Ap/sgQUfyg+XCxo6S/cNajrfJ30aqhVZPEe1/vM0gPZB9L/VQtQooOc6uM1Q2kQCvsWG 01Da70V2lPwPNEHRS3lolfdlZ5lGacIvDRQDDSUJMMPfrefHtsL2gjDUsfNe8chnpec8 KSUA== 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=rSIxXsUPe5tbSLrvgRG0MbMX5K6OE8jdeqocDiyHVO6flVfyeqBubBFYq/pTI3fNyG rEFHetkUnG7ejPFA8ajH7g+6RVxBARVuE+pzn/j+WXKDHysa1yRCf4LnaIlkhHBlOH7l fSSvvrSJTo/XM2K3/SjD7Sd7ShxGclyT56FbeF4cs168ynz945KplvZNPM+7BbuZaRpc UvbP5ceRVub3WUCQWOI2LK98ZVTIGTvInmxz7DxhIZ6YZZGsoI8aH4PniwIIqI+ruCB1 7IkNGQjmtgsQaw7XdeMsLBiGrzGd5uHF2xpxzdCBEk3Wfgmzpu1eQQgos9kD70PrZpnl 5dsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JZi03g5m; 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 35sor5817876plf.23.2019.02.14.18.42.43 for (Google Transport Security); Thu, 14 Feb 2019 18:42:43 -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=JZi03g5m; 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=JZi03g5m8SqN4fzXTLvaMrZBoX3tseOnsMCKC/62M1fb+WcWoioZRu2l43B9pfFRQ2 WXlq2oi4wn0yLXfiWFYswzWzIwq4w5bg5KUOQqXwHgWQAE+lk6jNrBiI49ibZOXzAjYB S8xwAOlxwx6HrAa45AL9/1l+BkEjI1D/wYBYF5rR1UnrnGZzphD/5/CSGuRCJ64MvEcH DReeXATf/+Jz4/zN0EJD+9cfFSCrLW6CKrkgZOu8eMnbvIrFvUZ+1Plc5qyMCcYCp2YU 2sV0wsN2fmCXsUVqfPMdD0e6g3l2vcbQyVMaPVeMlRxx/bfrmGunMWVPf8F0LURXsG/d FuLA== X-Google-Smtp-Source: AHgI3IbXbVi4CkMxM7o0ba7dPvq9bi9XCTF85E7sfNodnY+9YIlbe7/Qi7XYnRlOQPjwRJgGuWuFBg== X-Received: by 2002:a17:902:bd82:: with SMTP id q2mr7737899pls.156.1550198562436; Thu, 14 Feb 2019 18:42:42 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id z62sm8961035pfi.4.2019.02.14.18.42.40 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:42:41 -0800 (PST) Date: Fri, 15 Feb 2019 08:17:02 +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 v4 6/9] iommu/dma-iommu.c: Convert to use vm_map_pages() Message-ID: <20190215024702.GA26442@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 Fri Feb 15 02:47:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814129 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 2D1131390 for ; Fri, 15 Feb 2019 02:43:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A9F22F424 for ; Fri, 15 Feb 2019 02:43:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EEE82F45F; Fri, 15 Feb 2019 02:43:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 665292F424 for ; Fri, 15 Feb 2019 02:43:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87D988E0006; Thu, 14 Feb 2019 21:43:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 82B738E0001; Thu, 14 Feb 2019 21:43:27 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CCEF8E0006; Thu, 14 Feb 2019 21:43:27 -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 243668E0001 for ; Thu, 14 Feb 2019 21:43:27 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id 75so6406853pfq.8 for ; Thu, 14 Feb 2019 18:43:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=36ygGGspzW8ypHYiojY4a19UR4qM+LFcK/AqwiiUnW8=; b=Vik7NIYt6jSNZrAiunSY4X4yXrT9RGM2kBQHeeL9FqgClYHazSAfC/810zMNShc1O+ As9xi3Z+sKRQ39GHI6Qn5txAG5sknY1Tpa/fGXxg8bpaJR8AGyhmXZ6RPHdV4Bpz8zbd 2AEwPVWS2hF8Lc/vOefOyTrRZwo6+u52PBxE87LG8d7N2IiF1OxGzSJCerqPKwcX+EcG ut4ZSAbZFLLWbKRedcb3HMya8bMAUA5W2e95JbJzQ0QOR4887xMtVOvDZ8mcfOy5OyFv QhAnSXgx5HiWqiTrRYkG4ogtXNYLp7UXisHGlw5GP8Bu56eVdExQt4PWlJZhNSsnHEUS HkUw== X-Gm-Message-State: AHQUAuYDE630y1eT3Ifx97fJGcDMHe4g7ZBGDK1ZjdfB0kwTG1bK8f7y 4fOYG1ZEBv3gOc/qTh/QoS18+5pkntfKvTZcMvKci7p0H1gdZ9MBg8kd3qcDB6AisjnC9sMqcAI rL043Tul7OBt6dirpnn1W+Nx9XeEn+vkqkg21OGeEf2jt50XvYJ25yvfAKCGOA6/kuarIPmLkvk IQfUPC8ErBj7xPkuE+QEQ4azOPJu9NvwHAOY5APRo64I8iU/lWwwx+zC3UXRadazidOme7+3uJK p9X1fuVOnOUM+nWL9LFqjrMxgDlm1iIf/87wyPDG7QouKG6PJb+3QMjzDXrX1iozn/Z92feDRMP UnaaJAIJqtXS4db0ig8eWk0sqit+LqWYGxzF0Wk7sUChH2DX+/ADT14JXhbW3hjVPjPVGWPBcUM 1 X-Received: by 2002:a63:2d5:: with SMTP id 204mr3054529pgc.407.1550198606768; Thu, 14 Feb 2019 18:43:26 -0800 (PST) X-Received: by 2002:a63:2d5:: with SMTP id 204mr3054486pgc.407.1550198605991; Thu, 14 Feb 2019 18:43:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198605; cv=none; d=google.com; s=arc-20160816; b=jRuR1dWvU+vbM8wddNKzvVZLBUFtCE6MZZmR9uB2lE8X7h3HiAdWwqthl4qXhl2aG7 vwsA5qN8lx1HQFQRJCkbgwA1w1FIZ+CnSx2SPxGkv2KJ/G4JeRf4ouf0mo1dw4t9l4LF dM30ddkcvGQT49M7IEheKzKWW9Xs9151hT2kmcWwD5JL6n2cw1dN8jr18iBovK/GPQ5J f+rMzM9O5luK8fosC0W6uAFmFq+9i2hv+sh2Q7Djxj0Vjf/Xpj4ZjLBmqK9fdgiP8dVr ynryVf+zoutBVgKevW8Osz/oPGJNO31yD2xObgp5nnChwRj9aJGj1P/5Bob3dKSepWrn 5Q2Q== 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=36ygGGspzW8ypHYiojY4a19UR4qM+LFcK/AqwiiUnW8=; b=IAgmqYNhNQir/ESihgOZkUK2ZsK7lZ6QvStYrbrEB55ULMd+9sYEnWSIVeFt7N9CgQ 21jMLXj6bJHTMOBUZspzsKIpw7iVh9b1b7go7km8WWz0TZIhe5ycBgFkzu7ukGGJQCaZ gNkSgooKdFYw2Cgt1YHoA3yx04Jr2c+cyNYPgX2Yz0EPDU4ScAc5nlm9X+Yeh98xtlMJ 6cUzrtJq4NUrtEFDLC92GsQtuT2xfFPEEnKf82VCOa6m0Bkyqkosvw2842aYSCbeXJs8 21QAKWD7DwofbfsRIILsKZVkK/r+u/gNFUdRIry7evEEDZJQ09ViGQw0KbCpvL5d9p8g 8lzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=inn83Ew3; 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 q3sor6590617pgi.58.2019.02.14.18.43.25 for (Google Transport Security); Thu, 14 Feb 2019 18:43:25 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=inn83Ew3; 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=36ygGGspzW8ypHYiojY4a19UR4qM+LFcK/AqwiiUnW8=; b=inn83Ew357K/ih8pfbluD0tHChrNBeWgVepxNoqLsPfTGsSVcd+Y2TvNyaOt6tsH+E l50EUJtl8WJgmunL6lScD8TdLHN40Al7FiBSXz8sPTFqYjA1D9Y538OponFb/96GzpPK c7Gs+mH17TuI2e4p6V0hcG4Do42SWlWbQApZfFxh68EAjYcMIWUuUYrw86EOJbzKhDiD F9cHRzu5G/0kaQnWGWV+JeffZh9moTJCTuaKNTxwhDR9Q9myrlC+HXeayONpB5vLZOo9 qKY92nsunQvlYAczN6fc4SxQaNmIXCkZXCJd5cqy9NompO6I5cSTc/B1zSJVmYRUGkNJ MolA== X-Google-Smtp-Source: AHgI3IY4Y9LsUJAtQBeI8TTrDehjCuwGc2OKrBuTZ9TvWhq4etnfiX7gHURQ6oqPUVyDoepRwe1zcQ== X-Received: by 2002:a65:6249:: with SMTP id q9mr3013034pgv.229.1550198605218; Thu, 14 Feb 2019 18:43:25 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id g10sm4582058pgo.64.2019.02.14.18.43.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:43:24 -0800 (PST) Date: Fri, 15 Feb 2019 08:17:45 +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 v4 7/9] videobuf2/videobuf2-dma-sg.c: Convert to use vm_map_pages() Message-ID: <20190215024745.GA26461@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. vm_pgoff is treated in V4L2 API as a 'cookie' to select a buffer, not as a in-buffer offset by design and it always want to mmap a whole buffer from its beginning. Signed-off-by: Souptick Joarder Suggested-by: Marek Szyprowski Reviewed-by: Marek Szyprowski --- drivers/media/common/videobuf2/videobuf2-core.c | 7 +++++++ .../media/common/videobuf2/videobuf2-dma-contig.c | 6 ------ drivers/media/common/videobuf2/videobuf2-dma-sg.c | 22 ++++++---------------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 70e8c33..ca4577a 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -2175,6 +2175,13 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) goto unlock; } + /* + * vm_pgoff is treated in V4L2 API as a 'cookie' to select a buffer, + * not as a in-buffer offset. We always want to mmap a whole buffer + * from its beginning. + */ + vma->vm_pgoff = 0; + ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma); unlock: diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c index aff0ab7..46245c5 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c @@ -186,12 +186,6 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma) return -EINVAL; } - /* - * dma_mmap_* uses vm_pgoff as in-buffer offset, but we want to - * map whole buffer - */ - vma->vm_pgoff = 0; - ret = dma_mmap_attrs(buf->dev, vma, buf->cookie, buf->dma_addr, buf->size, buf->attrs); diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c index 015e737..d6b8eca 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -328,28 +328,18 @@ 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; + 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_map_pages(vma, buf->pages, buf->num_pages); + if (err) { + printk(KERN_ERR "Remapping memory, error: %d\n", err); + return err; + } /* * Use common vm_area operations to track buffer refcount. From patchwork Fri Feb 15 02:48:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814133 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 513D713B4 for ; Fri, 15 Feb 2019 02:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 441E629C54 for ; Fri, 15 Feb 2019 02:44:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 349352EE54; Fri, 15 Feb 2019 02:44:14 +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 CB22A29C54 for ; Fri, 15 Feb 2019 02:44:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E21408E0007; Thu, 14 Feb 2019 21:44:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DD0D98E0001; Thu, 14 Feb 2019 21:44: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 C99628E0007; Thu, 14 Feb 2019 21:44:12 -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 8BB598E0001 for ; Thu, 14 Feb 2019 21:44:12 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id 2so5761627pgg.21 for ; Thu, 14 Feb 2019 18:44: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=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=r1M6HFHMjY6nSjfNPcyHQ2OEXoS30L+hwwdfMT9pXvtMnzM7SgCK5Me/xTx6kRwkIt K+dG2CLYiuj7VKYX60X6dr7HVetGkE0TydDN7YTiYywMgf+vO/jFj7nJ5qAyfzDJs+Rh Z5+R6CcW03YUqnXquGuLSPQw2KE7fhnAOsLTe7Jg+oR73NQQ1t0eoRFlSS7twj1QvBy4 8/pdR9KPaR4+YnKX/qC7ThGO2jN16Xun/xNPGP6LGSNvs2wwtMOgVG8dhXEiY+08d3O2 e8sqkdiS9q7eLk3DCl5bwwN/GMnI/Iae1OWv8mxobhv/1RSSdcNSnqkNfux+IfWndwZT hgIA== X-Gm-Message-State: AHQUAubE+RJsZcVFD/s0jnOQB5S7EY2lzlnTuHWrS6u7MMCWGTk8sbzz z6V+KIqeNgriIRL9bVzURHElvR8F8A9UGPS1akPGqKUFEquSu7/FsuiXjpeAoj6cZbttdPxtPj/ w+fIqHi+zqTmb3oNqQ6EheSB/uiPpMscNmoWc3pYueDRULYl7AnqfC60vHJiuRTznBDZDS4rFZT WagxscL6Z42iA5qHPdg0kJImEGi3ROGNXwcFnSEJGo3OEN/lL+XkmIbXZa2bSOgUXe8r2qYDAWX fmWqoF2n+YrpQKxBIcfqoLzgSRLRDZ8vpNvxL+pLjL4i05JH5b4kgKodDiPlEY0nomSXmOIt2AV qFEo1H+TulXX9Xfo5+kI2PjZCe06by5UqjaXWV01SV6UVfMLUQ1yT17tBd8XUTWZKfmZ53zWIK+ I X-Received: by 2002:a17:902:20e2:: with SMTP id v31mr7738203plg.307.1550198652259; Thu, 14 Feb 2019 18:44:12 -0800 (PST) X-Received: by 2002:a17:902:20e2:: with SMTP id v31mr7738163plg.307.1550198651628; Thu, 14 Feb 2019 18:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198651; cv=none; d=google.com; s=arc-20160816; b=lGjZqezCg4Hn3r19w/CSx3/WfX1HtzEImygpnk+FQRFkoUP/xEQoguvY0pXt7dXVEJ +OEMf7QNyuXTsD15c21TpKy4aJTNqF79GGvDZ73c7vheB3ZW3HzwYx0l3gcdEfZwIK/w m2SfasyH76WiLDn+My1pSKp59NqHZLSMNvcL+jeJiQPknxeOos+7d4WAlm3QT+EwJKvi JUQhl4frOXYOFpn6vCHKfR5AnS9qxpU6FxPMmJU2QusM/TDInAgO6BbeabJ3NNU5QOva morHhLTMUYGI0ocnpqvndnCQWlFCOyS48PVS4u6UQozK+cPmkoFvl3rC0u4dqAF5u9hW YLXg== 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=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=D39r4K4UGKmjJCoxN9S+MsCrH6hQO+mU4yZZCKm1jV7ZaQCEPF2hvXlcD8rQuMChpD 9VV+nMkyatBKvGBvbPwCYXioBJ5au6ubTBiPm2AEu6dvxTR14FaS0YKSflo/EyTEoxh7 1KIqPIptHffQKwPauAb4RSGPMhZW/hkHUw7Y9FWOZ1AfmVD0MxcXni6qVvLwbFSzFCQJ dMDeKe4oGOccirfDwtrhIbRicg3CsRdpydUuyEIrGM1UEq5/jb5rQRAFuRpV91SFUL/0 r9ix4hQ2lJXWJ3zNCSNUo1N1FGB1ShHrBntxFpM0EZ6OBQX7jiTt4mv4UA2UvZa7POMa Hvew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Vt8nidr0; 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 x13sor6390887pgr.56.2019.02.14.18.44.11 for (Google Transport Security); Thu, 14 Feb 2019 18:44:11 -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=Vt8nidr0; 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=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=Vt8nidr0rK41Os0HWq4+4aF062X7h4v6mHNSGJrNppzhNDwX047qRWP5LTYUmhuLuy Iqtt/oPfQUVesoOPfP5pR37mpT+P5HeBjY/N3FdmN8Wc13V9Ij1VlOFDdTG1KkCD9Y9h LQKENgYLW/iXqE4T1/ZrhykWcCV8gemdxOrir5XOiDFzPc11Wj4/BnVAjWyDbTbpt0ta VbW+K/iPDsPHPWxg6IhMue9P7ETAnU+10BQ5VBAg8a1B0RRapCC5H5wh6eFntrZbvsCk v7WtGBOaFUVs6JL1Q2xUIeJxfF53otn17DmHM7ufjAiDUwRCJGfexUeqg6ur38YrawW0 RvyA== X-Google-Smtp-Source: AHgI3Ibcl+fzq90jisjOqRBP1UVmKB22vuwt6jwUdH2scf6jctjGOQhzTZ2VTYmiKE7rY4uCtAp5vQ== X-Received: by 2002:a65:5003:: with SMTP id f3mr3127549pgo.39.1550198650905; Thu, 14 Feb 2019 18:44:10 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id u8sm6577915pfl.16.2019.02.14.18.44.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:44:10 -0800 (PST) Date: Fri, 15 Feb 2019 08:18:31 +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 v4 8/9] xen/gntdev.c: Convert to use vm_map_pages() Message-ID: <20190215024830.GA26477@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 condition. Signed-off-by: Souptick Joarder 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 5efc5ee..5d64262 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_map_pages(vma, map->pages, map->count); + if (err) + goto out_put_map; } else { #ifdef CONFIG_X86 /* From patchwork Fri Feb 15 02:49:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10814135 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 C891B13BF for ; Fri, 15 Feb 2019 02:45:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D66AE2EE80 for ; Fri, 15 Feb 2019 02:44:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA0522EE88; Fri, 15 Feb 2019 02:44: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 6C7232EE80 for ; Fri, 15 Feb 2019 02:44:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98D788E0003; Thu, 14 Feb 2019 21:44:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 93BFB8E0001; Thu, 14 Feb 2019 21:44: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 805348E0003; Thu, 14 Feb 2019 21:44: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 3ECE58E0001 for ; Thu, 14 Feb 2019 21:44:58 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id r13so5789713pgb.7 for ; Thu, 14 Feb 2019 18:44:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=F9hIq6OqtC1SVS2O3U7ZkPoLnNclA70DsapCWy7Q+lE=; b=c4jCjnggpvJu2W4XrUfdNqtC9bHH2L7eFZ36IP0T3zouDAEW9axsXvpsAGlc2YTSMG +Yvi2z/3rqdYUPuWn/2PzcJjYqLoAQ/GoNMf9mJFDNMiV++ZrDG4GF+MdeJbW6ruc3UJ txC+lRs/rmWvRRnXA1P/nX/qVT5dOz+5qbvvUuhs3Sqi7NyQqgLQWWa+9KuDPI3RREe1 DfVbIDh/A1i0QWz0P+UDMbL+PJNT+5hD7TlFH4oOYdTlnuMyDt37a2Gaj26+XGro6YHd 2Px2U7RbYTqOdjZtlk0iZgVlXjlMGHdEGV7uf3oNXas98uhL6O9WUCP88k8e9KoPifgK pw0A== X-Gm-Message-State: AHQUAuZgPuA2YtiMm0SDbMWZeL5e5RohnbWlz5iH3S5qYCLMmr7m70yx 2yv0vIU2fbrmFyNE7JMV+YExosq1nXyvKxTYRcTR/E6lKsR4AIkzJqT8ZwaRbX01opPwj9U0mr9 A+BBb2a7LiY+IBT1ZRsl2VoTbbqqNjovVBpO7sfOERKyuePPRXiR1bhiLMjSO10wHh2/hr51VkY 45pUslyAKvzmEDKCJ8UHKtJe97Tlj8l9NLBY0SCkmN0P+qyLTRA7M2kjK9QsA3pKahACL2QD6YH vFUjZl/pjPCEH2DUeQujMpqyR/Sxi1UrPRNjsYgyUwllvRgWxOeKT+MQJMJC7z5ZX8FPTjFk1OQ pebzNOQZITM0PzkVLXtnPAmFloRILw8SvvFu743VfuamTknW/kq9MDtp/RIvw9MMHZa+KmWRWYQ Z X-Received: by 2002:a17:902:112c:: with SMTP id d41mr7671662pla.177.1550198697937; Thu, 14 Feb 2019 18:44:57 -0800 (PST) X-Received: by 2002:a17:902:112c:: with SMTP id d41mr7671626pla.177.1550198697285; Thu, 14 Feb 2019 18:44:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198697; cv=none; d=google.com; s=arc-20160816; b=xaWa64B3IXEcOfk24ke/UHKZjbI1RnvfAImmOZ8m1z6PVw+28R8KN4Wa1si5nKW/sf nlS7lXXwDJrpHix40IQLORZdi8tCdUEDYC3b8DJzR8bQzOMmFYBpFwFH+VnjMGaRDiK4 bXSUi6McsWRUm9A57aenaqgiN3aexJ+ferqu4L6G6GVIiaTZi5xdG0il0PwRKq6t8jGy x1XVx2PRsMYOJ16gejkEskpl9cLwTps3l0QJE4u+LqbTPY0WoHK4ns3Nc9aoHu1+Flr6 t8HYiPY9oTPBiMPrLsH4K+ERvyH0i7GMV7c+ZkivD5YmcCAp3F0SnHG2wBGAJ5waKg8R 9A1g== 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=As9tFz/1l4KJBkM70eHNvPs+aJznmnSdB+DVIl+Bkpljz6r2BnFEAcUhunKorFPbPt ZUTBnHZc9yGN7KlYkzOjraKwUQCR0OiAY8BxZz7TvbPxu8OBEzikgaw6RhhGkqAjDjWY 3A6YRhWC6/Y3cw5Wa4Fi/iZmcM0sNhw59qjtc3E9X7nuiRfSZYe0KNCS4no0UMcNeVPv sC3tnBJJ6x7jhWCqXbXBlGIQmawNiummfc0qaE5ALEW1+LtuqFxa0lShf7u2MrD+4xrV yWFqIWez1SrBGMc5VseUj/fK0fcBVRcgjaTIeqr0Sb9ni7uz5xKTkGTdHvHTPyaMCXiE tc1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QWuFZnGW; 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 d2sor6401403pla.7.2019.02.14.18.44.57 for (Google Transport Security); Thu, 14 Feb 2019 18:44: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=QWuFZnGW; 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=QWuFZnGW1rAFmlIYTR8KT5WNdvrhaezr0i4ZoVMqFLa54ofNW2h9D9a5ZzgYyp41MF rvXlFdLTe1vJbS+yYGRhKQFGPj+MKLD1iVlvMm9nhnIlH0nFQ5/bX/r3BgdjW2MtktLL fE5F7PKlj7zIDHLD10ydW/9+vyhDv6wCFhmmc9esTga8VDt9eB/q3GWtNUJB7Ih4v8gF hysNnNr3phiGvpEKd6M8VkY5G2p4IwHVd8tz8sNvMG5Yof71tMkfCzELiIvS7ATGGdrk f2Fjtt+lYU6DRmN0pNS3UaeqrhCqlzqJPjrNKTGR5zpPj8DyL7JWfrs3Bxalf9n153ai kn/g== X-Google-Smtp-Source: AHgI3IYS4Rmfmmn4KPKMZ+5sCz/9GuQcTZN8Ld6ccRNBZU9OLJommfG+bJc6qfgdLMUnSbD4C9x9Pw== X-Received: by 2002:a17:902:b190:: with SMTP id s16mr7726474plr.262.1550198696592; Thu, 14 Feb 2019 18:44:56 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id t5sm6861584pfb.60.2019.02.14.18.44.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:44:55 -0800 (PST) Date: Fri, 15 Feb 2019 08:19:16 +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 v4 9/9] xen/privcmd-buf.c: Convert to use vm_map_pages_zero() Message-ID: <20190215024916.GA26495@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);