From patchwork Sun Dec 2 06:19:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707847 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 B6B8816B1 for ; Sun, 2 Dec 2018 06:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3CC32B11D for ; Sun, 2 Dec 2018 06:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96F302B12A; Sun, 2 Dec 2018 06:16:18 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3686B2B125 for ; Sun, 2 Dec 2018 06:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=EnTxqhTPWtIbvs1vXRwvbzvl8j+enRT+T5argddrCOE=; b=SwwUOEh2nIxfDD lTgcb73Jb9Qlhe08/XViFCCcK31nwyLC+5pXDUaTpVmlfkxrSpqsAJzKrwxNzg4jJ58lxLx98606k vLaJdtAs/r+gJ2LSq/y18cSYaEUi9q98d3p/MQYxh0+5BmM9tG0M0har5A95OqPYs1eczFSDkKDgx DUKFtzvRuRR3ixTbtxilczr8hWMlOvzISuJi+kgUUV+Dt0PWKXY2t1FPyJBPfwJhxi65jQm4wCqbC GtPGpwx2p7GbNQ6iYCn8kliutfg/nG6iz1j0GEjwtVy/9p3zQ5O+1kHVcYMSezAwQeFxLPEQN0WgA 731RQE55WS7kq28L7t3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL39-0001i9-JX; Sun, 02 Dec 2018 06:16:15 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL35-0001gt-F7; Sun, 02 Dec 2018 06:16:12 +0000 Received: by mail-pf1-x442.google.com with SMTP id c123so4796301pfb.0; Sat, 01 Dec 2018 22:16:01 -0800 (PST) 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=zpuGNdUnpdN5wTEIRBOxYuxj5rUfCCVuWQ25gpRoE6s=; b=bWk6uLkFrct4pezrRVHDS3fxAfnzuH30JJU4oMJOz2yuRc6qGON0LS3euO9PI18qCG ZWCJ/La6wnc++Nb6Jl5M7htxappQkoe07uJn+Tgm2gzZrUpW4u6sFMq4hhElyN39p+9v zz1vE8r8mohE3kP3S+LsBxTj9Y9QmOvTxyr+xuNsnDmySrcEt7Zz/1uqxJRqxgRQTFTW h/SSYR9cuTSYigG5l+TwSwbmOvd7pT/sHv8kYvijQHX0gOgpzngqpuzQWss+3SjvQuvP Q74IyFtYvg1IFgMLRPd0NLO+dpLsHbzDcBnYYIMyHZbKylIA5otr3Lj2UWKVL3p/SPpM lv9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=zpuGNdUnpdN5wTEIRBOxYuxj5rUfCCVuWQ25gpRoE6s=; b=oqd+jTb5niOe0MPJswwtIHCf2gcionrUvms+eFkvjOwNEmTEkbZX8GWD8hj5ShSoFG 5DmmhTwXCp2pB5p3W/GpIGM4cH5fq4vDNTo2PFHSg/rvruU2O1R7VFgOemf2cZzf2mcx vuJ0AKAl1yumKhnK4vkw47DUKZUHdNPyTaQ9ojzrR4RUSq2zR0baDCZbPcMte49MlHOR zKdKDKnN5rXZTSm1PUuwnWOe1ATN2EOIyDsiS7nf2l6+AINxMlBEeMQ0I70asfOb9nTu IThhX7+hffwPuFTQmUy+U3Wf+ehLVgqPGSBtrOL9RMcB2nZrMWk0uFNTmu5UB61sclTY PrcA== X-Gm-Message-State: AA+aEWaRzHghXmj3EvuGQuAGYezSpCyriAyZJErluuS2tcmf846h1E56 CRxIx28M//5KQuHUEHoYNiQ= X-Google-Smtp-Source: AFSGD/UBkP9uRpZkSu5Rmi17UiqjfK/g8dHm6TgDXv94eGr1l1iC6bkXVyD45WRhl9f9OjSvEy60DQ== X-Received: by 2002:a63:4c4e:: with SMTP id m14mr9689461pgl.173.1543731360563; Sat, 01 Dec 2018 22:16:00 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id v14sm16952190pgf.3.2018.12.01.22.15.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:15:59 -0800 (PST) Date: Sun, 2 Dec 2018 11:49:44 +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 Subject: [PATCH v2 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181202061944.GA3094@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181201_221611_510478_93E54419 X-CRM114-Status: GOOD ( 16.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xen.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, linux1394-devel@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop. As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers. vm_insert_range is the new API which will be used to map a range of kernel memory/pages to user vma. This API is tested by Heiko for Rockchip drm driver, on rk3188, rk3288, rk3328 and rk3399 with graphics. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Tested-by: Heiko Stuebner Reviewed-by: Mike Rapoport --- include/linux/mm_types.h | 3 +++ mm/memory.c | 38 ++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 48 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 5ed8f62..15ae24f 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, extern void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count); + static inline void init_tlb_flush_pending(struct mm_struct *mm) { atomic_set(&mm->tlb_flush_pending, 0); diff --git a/mm/memory.c b/mm/memory.c index 15c417e..84ea46c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1478,6 +1478,44 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, } /** + * vm_insert_range - insert range of kernel pages into user vma + * @vma: user vma to map to + * @addr: target user address of this page + * @pages: pointer to array of source kernel pages + * @page_count: number of pages need to insert into user vma + * + * This allows drivers to insert range of kernel pages they've allocated + * into a user vma. This is a generic function which drivers can use + * rather than using their own way of mapping range of kernel pages into + * user vma. + * + * If we fail to insert any page into the vma, the function will return + * immediately leaving any previously-inserted pages present. Callers + * from the mmap handler may immediately return the error as their caller + * will destroy the vma, removing any successfully-inserted pages. Other + * callers should make their own arrangements for calling unmap_region(). + * + * Context: Process context. Called by mmap handlers. + * Return: 0 on success and error code otherwise + */ +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + unsigned long uaddr = addr; + int ret = 0, i; + + for (i = 0; i < page_count; i++) { + ret = vm_insert_page(vma, uaddr, pages[i]); + if (ret < 0) + return ret; + uaddr += PAGE_SIZE; + } + + return ret; +} +EXPORT_SYMBOL(vm_insert_range); + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page diff --git a/mm/nommu.c b/mm/nommu.c index 749276b..d6ef5c7 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + return -EINVAL; +} +EXPORT_SYMBOL(vm_insert_range); + /* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty From patchwork Sun Dec 2 06:21:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707851 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 DA6861579 for ; Sun, 2 Dec 2018 06:17:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F362B11D for ; Sun, 2 Dec 2018 06:17:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCD882B12A; Sun, 2 Dec 2018 06:17:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 731162B11D for ; Sun, 2 Dec 2018 06:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=yDs4Xms5Ue56josWB+LHsRMfigi+c1rAhzGbOMhld0k=; b=LIOXAWXBBYB63+ Q/42Xm5WHYYXh0pyahfDIJVOiPSJIG1iEB3dEvzG+gSmpNrEN8aJi6EDohgoJ5BXYy53Ea3nMmGRY n4SEkjr7d4qS7M/0jThkH5n5Mgx0WcvKZviOBvduJEGSAw+ude/InvUg/5xFTn5AAjiwTPDvoszUk xttVd5tEK1MCWHTcjB5gU7OuKlvt0tjQ0VYHkuFTBKlEpSymSVvTcBnwsIHQN2ySBRR5DgIZeoazR 4DFznwG6h6l09AOZ9VFpPgHz2WAY05g7qbB2VzotH2wFbvAfEwj3GeH7ytIUpwYDNrm1wdtKCdetG WuofN4Wv/RgxrIlNGvgg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL4U-00027H-UJ; Sun, 02 Dec 2018 06:17:38 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL4S-00026V-66 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 06:17:37 +0000 Received: by mail-pf1-x442.google.com with SMTP id g62so4771936pfd.12 for ; Sat, 01 Dec 2018 22:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=mBs4dq/TeqPHUFL3AVrh3JJ/g+dMhVdSUtuuYiWThyelgCPlvamNLncj9Z0m9wretJ dHQvALWfWyfZ+7pRKHCJ8GadHqubftSlzYY9F1kU9Q42HBarg2E2uV5mDeQzLVNSb048 gv8GxLTCIgRIx432n2ija9tH3s8sgqauV6Ulm8WtyP7po08V3uPqb5C6Xs5u3x4KCpZC GAXsbgqClWr3kUjmQtErJtDmoLutvnGAy293IObP4qojbp3bkmwLacBfB9qkW4bQdN86 hJ62U470REpyHVCTaNKFe5GJyUfNQi/0Px/7/+s0OfcUYwyXdeauPqvC1Q2BEUbrPjW7 CDmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=l9fpSL/x+vdFl3FA7imjgaHLS9HUE2KOzsyMxAKCOYDNVdcLb4nlA2NbkY3SvphDJT +uIueN1GEmVYtKLFSW8lGSWwikPlmTBb0FBmTdUXnlz3dAXnuVhHrJv/7q7yd8OJT3Ck GcpMCW6AO6dtCf6L94fWwk/NykveF/xJGjfev3okhvBevJTJD+R+mMiXT/ZGiZsQssyo dZSNW/2Eai5uZF+a3uKuis8n5ZZ0v+dQWm6EgIPz12jtN12n8pqDzInH9shihkv9+5g8 yVadQWpgy/V2BBK9JKOJMJeHx6pXYHLmH9vwt7aOnsNOiyQWZhLZtkzEBiPRfiLcoM8k NPfw== X-Gm-Message-State: AA+aEWZejBUyLA9w7Q6AkQjABaBeSY/J4X896ZYoxSmjH0V+nSTuwb3l bfHqDqYMpo3V6Mxbb3pkntUfi/F2 X-Google-Smtp-Source: AFSGD/XskkVCLMV56P5G6hSJkQEj8Bb7420tD78vrgpfyz80/Ofs70Y80gJpaUlH3MXPhcU17HkqjA== X-Received: by 2002:a65:63d3:: with SMTP id n19mr9785026pgv.179.1543731445240; Sat, 01 Dec 2018 22:17:25 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id q1sm12648437pfb.96.2018.12.01.22.17.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:17:24 -0800 (PST) Date: Sun, 2 Dec 2018 11:51:09 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com Subject: [PATCH v2 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181202062109.GA3111@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181201_221736_224190_86D1D55F X-CRM114-Status: GOOD ( 15.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder --- arch/arm/mm/dma-mapping.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 661fe48..4eec323 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,31 +1582,24 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma void *cpu_addr, dma_addr_t dma_addr, size_t size, unsigned long attrs) { - unsigned long uaddr = vma->vm_start; - unsigned long usize = vma->vm_end - vma->vm_start; + unsigned long page_count = vma_pages(vma); struct page **pages = __iommu_get_pages(cpu_addr, attrs); unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; unsigned long off = vma->vm_pgoff; + int err; if (!pages) return -ENXIO; - if (off >= nr_pages || (usize >> PAGE_SHIFT) > nr_pages - off) + if (off >= nr_pages || page_count > nr_pages - off) return -ENXIO; pages += off; + err = vm_insert_range(vma, vma->vm_start, pages, page_count); + if (err) + pr_err("Remapping memory failed: %d\n", err); - do { - int ret = vm_insert_page(vma, uaddr, *pages++); - if (ret) { - pr_err("Remapping memory failed: %d\n", ret); - return ret; - } - uaddr += PAGE_SIZE; - usize -= PAGE_SIZE; - } while (usize > 0); - - return 0; + return err; } static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, From patchwork Sun Dec 2 06:21:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707855 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 7AC2713AD for ; Sun, 2 Dec 2018 06:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 669102B11D for ; Sun, 2 Dec 2018 06:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 582CE2B12A; Sun, 2 Dec 2018 06:18:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1253E2B11D for ; Sun, 2 Dec 2018 06:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Loy8BRpAHtcpXHPkVZSW+j0QVNFil9xaFXoMXhsn+1M=; b=RJXAc/35c/MveB g6d6grTeu+tygcaDaLqD/mu7aFWeysZG9rHLjOXEVXe+z/XcPvM9FWfvx0oDlS19C8Igt6vxiosQo yj2IlKUjpAqowzCb52aKiepVG2Q4zVESwpPT5bCUl6suXpH85JdTPBuyBnPyVHwBWpW75jqQW5V2Y udFWyVaBOxTqbmQnFIn3akKHozHxNuclvYvUWKSBPVSvh0jbqlHBRbvhhC9nWPyqjvftvMKfcs8kb Bu8Y8bnb1CN9X7bkQjYPWv8T3/a9XaJFk0jLLTwl5mtLkR/jGrmHf91BFYxwUu8i/hfplklbSWpa1 4QIFXvfndQzLNZQOaKzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL5F-0002Uf-Ot; Sun, 02 Dec 2018 06:18:25 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL5D-0002RS-L0 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 06:18:24 +0000 Received: by mail-pg1-x542.google.com with SMTP id g189so4284963pgc.5 for ; Sat, 01 Dec 2018 22:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=Ob52eAybZ+ukSyGdY8U/Z1jdhXxFQFle/dMi4Et2nQndtm7MZ2i4ONnKsVDEIcjDDz 9W38WqOW1p9mt0J7xkQxfLmLL/jnq1/LcrLmoOqnc9m337jYRgsykPHqvssdhQ8pmZqy AcyrBFinNSivTuQmUI01wz1gKLQW9G1svEowGTi2+SAQF6CW3SbPSPNlOgF5HsoRXG/R 9K9JQ52ZvaqN5BHcgkhczNdO8IQ5qGjOakvBGCY0Sm0g3u6hbovABd7E77bu2Yv2l4eb Ba8iBaRv7cN2h5YB8JO3+4IihJv60g16Rfz+y3KC66wo+3y0mJ60ov/ncoRJ0hAIFPOQ x9gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=pFA19XQqRIOonXczeaJc1JMDfCxsc2SPHw+vTN0jttk=; b=Y2zCwt05u2hboKVbK9v74sGkDbgu4r5RyfzwTF+Aazs2/fcQWZLJrsELMaofZT67aY Arh/eVemejv7mzD8rdaa/xXZDiy6TrxEpKj5NaJZSIixm0YNPVEgWZ21W63X1duJsNEB FdUiUUPf43tTNrQa/uUoNZoaPytdYjz9rh3XxTL/KioS2GkbkLefMDaf31YMXYnXxzBX /Yyjd/xIhxkViCpyniSHgMiTX1YzwOZCjA5aWYEUCL+djEn76Lr3JGmKc/gwQPLCepuI AsqfsIcAHw2pLl546sMcare6X9I9EZUQcjyNLqVkiT295utmlYrp25S2kuo7nieXbq4D wxhw== X-Gm-Message-State: AA+aEWb6n040qduni6Rw9xdcIqWYWuKxS/UGiXx7bn3qPttECc/3fTEu uR92FXjprhUZSJ0uxj/DLtc= X-Google-Smtp-Source: AFSGD/UHCJICHgiE0m052Ybq6CARBcS+P92LNUcrBDatOdJIiC6ahi3tnqCNt66ImpC9ArLD+LG41w== X-Received: by 2002:a62:546:: with SMTP id 67mr11166313pff.99.1543731493182; Sat, 01 Dec 2018 22:18:13 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id g15sm46055783pfj.131.2018.12.01.22.18.11 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:18:12 -0800 (PST) Date: Sun, 2 Dec 2018 11:51:56 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, stefanr@s5r6.in-berlin.de Subject: [PATCH v2 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181202062156.GA3131@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181201_221823_693443_E198EB3E X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- drivers/firewire/core-iso.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index 35e784c..7bf28bb 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -107,19 +107,8 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) { - unsigned long uaddr; - int i, err; - - uaddr = vma->vm_start; - for (i = 0; i < buffer->page_count; i++) { - err = vm_insert_page(vma, uaddr, buffer->pages[i]); - if (err) - return err; - - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, buffer->pages, + buffer->page_count); } void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, From patchwork Sun Dec 2 06:22:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707861 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 7C64C16B1 for ; Sun, 2 Dec 2018 06:19:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BEE52B4F2 for ; Sun, 2 Dec 2018 06:19:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 600682B4FA; Sun, 2 Dec 2018 06:19:31 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 132932B4F9 for ; Sun, 2 Dec 2018 06:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=xZk8hOjUlTR9IlM12AognHsJl7P1bIz51rWxTqY8ZBM=; b=JzL2UqWMoMpOeY mKsF6MMYy4IhUwXA6vz/nJDAELp5EnvMFbz+S4c2kFfK0MXv4QdM/7tEp1ZiWM2ZU20BgtXxtmPs9 e6hfWFjA/0Jns1gPDiXlQBPPv8E7LjvGXp5yxaLqxC5yG95osnsTuRCU/470V1cugwLtzn0MZF4gj 8bGUlNrW5gl6+YeZfKWutuStYwd6d5bNTUJaVCPQkbOnimEqUwmNljjwrGDMOje1bUU1m11Ymnrw2 HahGnHe3q4TiD9dZGzoAfON+bz7GFPFczK6W6Ui6A8a2ok5kvDgeu7UaKzw92NgNmBxbFH/2W+kou kEURIaRkQ9BGj2OQQ20Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL6H-0002rM-9S; Sun, 02 Dec 2018 06:19:29 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTL6D-0002mn-A8; Sun, 02 Dec 2018 06:19:26 +0000 Received: by mail-pl1-x644.google.com with SMTP id t13so4805719ply.13; Sat, 01 Dec 2018 22:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=Uy2BvgZZkqOXNK7hWBYo3ARMJUfASECRH1vDxiNUgHBWwBso/Dw5MVQ3h240LKOn9r NhpjK25eGn1477k5XxEo8EOyY+Y9o+E/DUJKbzrcAxAiamgY14sFBQ5e4pPJJZIPgx0x NzFau/vgdlUWyYjWlRMcagejTL6DGAwAmAsSxpCb68yXr9XBuwp/SaCrwZvvzqcGm0L3 4PgcxWbXzJwKYve3R9DhlAzPDVVBxKO/xslBA5HeS47vJGvTrlgakEwa4L493x3uvLwo PdxNdGZOUlyPHJ+JMUkdbANMZcGvWiGUFFuBO0DsdK/adiQyQW7EAu9QSeBXHtYH1PiP vFeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=ng6k7XN2+E7qu+YJG+ewVaHjUak4Dnv0s5kVr6uQuLI=; b=YYXgrEgVE0Hx/agaICeIIgsdXZXb7hprEcRiyLyaB/GkdWurwCONUcYEuwOIsqHZX1 QH7mzHKYof6G85I0dFpY31cTbuEHMomJJrn4BDjYyQ6Q0BW4eHv8BbVfn0AVbcgeG/IG n8BhuE7CSFdFdRuDHYAllzUKcqvSxLpxdTcLxoMjJstKOYzzD068b+YUvftVhsh3eXCj tXXhMEByLwhLTeeUQrr46EM4GH57pm3VcjaAR9ve1sPD45shxZ7SAE5oz/oroubWTtCe NE9E3fc8m+iFmdtpcg+RJD26r2Rmxjjp40wM8gQXS9YeqHonFpYOC4UQQkt57Sg8pPEX Zfuw== X-Gm-Message-State: AA+aEWaiEou4twM9pauvWKQ3FgOHOlu4XPRyqYHGj45dSCBnaa8QO4n4 9bS57vIjlGdWPDfvJfLySZ4URaWz X-Google-Smtp-Source: AFSGD/WRNjFD6zB7/hjn8Xn+aoz1dyOHhd/PEH2NIgt7PDmUyJF+fZfXXjivwgpQAMMMOqZJ+B9xkw== X-Received: by 2002:a17:902:e085:: with SMTP id cb5mr11348736plb.24.1543731551018; Sat, 01 Dec 2018 22:19:11 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id n73sm14870007pfj.148.2018.12.01.22.19.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:19:10 -0800 (PST) Date: Sun, 2 Dec 2018 11:52:55 +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 Subject: [PATCH v2 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181202062255.GA3159@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181201_221925_411873_9CD992BF X-CRM114-Status: GOOD ( 14.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Tested-by: Heiko Stuebner Acked-by: Heiko Stuebner --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index a8db758..2cb83bb 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,26 +221,10 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, struct vm_area_struct *vma) { struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); - unsigned int i, count = obj->size >> PAGE_SHIFT; unsigned long user_count = vma_pages(vma); - unsigned long uaddr = vma->vm_start; - unsigned long offset = vma->vm_pgoff; - unsigned long end = user_count + offset; - int ret; - - if (user_count == 0) - return -ENXIO; - if (end > count) - return -ENXIO; - for (i = offset; i < end; i++) { - ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]); - if (ret) - return ret; - uaddr += PAGE_SIZE; - } - - return 0; + return vm_insert_range(vma, vma->vm_start, rk_obj->pages, + user_count); } static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj,