From patchwork Thu Nov 15 15:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684649 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 29E481747 for ; Thu, 15 Nov 2018 15:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17D1B2CB54 for ; Thu, 15 Nov 2018 15:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BAA72CB70; Thu, 15 Nov 2018 15:42:21 +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.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 6EB952CB78 for ; Thu, 15 Nov 2018 15:42:20 +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=rWey9xOuu/0Yo1Se8ck4YXCZXSLI+pUqkkQcG1YqsMU=; b=JzZWoVmbHN+RCB SLGxfITzzpPK1WpYU1H31dOI2xnu6SQEPd3aAUz3USt7YM44IlPE1fnYu1NUdGIM1MIQ/rk0ZGS2Z mEdzzeZEQedEPhZS//Ml6pcx3HXVpx7hTpat5NosyiE+aVkvIZgrvGLZqjwTgmQ9iu8wBdgtKK5Dv fPhRCX98ctFIkVlwQeLKnm9XwhTzPhcO5rxrz3eUJGBYpAtVUMxe+3IVTg1tHlnkU/J0xTlcShAIK cbMfCPK6fUSlQynGchqradiG9DHZjhVjpK+aD9LzVj/JN7i1L4RQiPcOLhXcG+2CAczyg4BTTG+wM W7XdvBEC3TFdAUKpL9gw==; 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 1gNJmW-0005I4-2z; Thu, 15 Nov 2018 15:42:12 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNJmP-0005Dg-Bw; Thu, 15 Nov 2018 15:42:10 +0000 Received: by mail-pf1-x444.google.com with SMTP id h3so3331103pfg.1; Thu, 15 Nov 2018 07:41:55 -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=Cg6brz7mYbLRhNFEJEtQAETpRuMNOqibtuUBxg6orP4=; b=Eh6N6bxmBaJCmbCwKW3nWNFuf4BU086XyvkfRs4vTvK36lWMY6cUN0FJX1PSYvywPA imnNfFW8NM5MhtB/HlVZZcHG+VZLG6fwdGA8wfvH3nTVvJ65/UEg8XF5sPJgwcMQ+Hcp 24J7dBDK4YuAeDF1ME0tMs/isqPAtODXkGF+EuEklxGHrwSqW6x5O9XLDxpRfHpmSSvk Sm1Rl+EzeIHqJmV2GbHPGqlz3EsJ6NJzstXHM7D/kaiWLp1iZCgeJ7SAzbxnhLcdmVAD NANa4oTHJ5p9uJkn4VOq7tq40IfMMMlfkFxDrYrG6YazkS00ehOYAi289jFYFozTT7r6 m7Pg== 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=Cg6brz7mYbLRhNFEJEtQAETpRuMNOqibtuUBxg6orP4=; b=H4YsW5tEkExmVCox4+6EI8wpwosy3AZl7t6KLmVZDt4QxSzX/7W9VSYU00CXXYLj4K gSOTi8+RAss7NAcVHDnuqTEOjQCMRTPrS7nErsT2EnmXRP3KgEhF13TujzfJTIlrGc8o 16Lb7Z3DIeh2Xd2I+92PgBOCOEa2DamctcdvnSGxa7MNAw78Qa9gnB3roQb4V49vFrny JdJ9LKBEwbHtL5SN5siDHG3P30cVtFnIKRk4W3Re4p86zNp+qO1SpEwIv65W7Dtbung5 yV3ndsVAy1KbeOygZ17nVbonKbPL06juwZKU79bIw3ryV5DoYgRWRSdfErQ22UPVNuw6 QlVQ== X-Gm-Message-State: AGRZ1gIORXQjdr3nYoAzMfN5Vmu+O6dsvCzcPUEdLEyZvBsvZ5D8xmEV 7yzWVvSza+FpaZAm3M+YbJY= X-Google-Smtp-Source: AJdET5c/4IUsmJbAFLjrppekHCGzB7YBq4feZP6VdbGvFFyn78AfrEs+pTt1JsSRVIRjujxms+LN6A== X-Received: by 2002:a63:5153:: with SMTP id r19mr6195032pgl.281.1542296514745; Thu, 15 Nov 2018 07:41:54 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id u127-v6sm28519773pfb.47.2018.11.15.07.41.52 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:41:53 -0800 (PST) Date: Thu, 15 Nov 2018 21:15:30 +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 1/9] mm: Introduce new vm_insert_range API Message-ID: <20181115154530.GA27872@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-20181115_074205_422330_2A3F7762 X-CRM114-Status: GOOD ( 15.83 ) 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. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Tested-by: Heiko Stuebner --- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 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..da904ed 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1478,6 +1478,34 @@ 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: no. 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. + */ +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; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page diff --git a/mm/nommu.c b/mm/nommu.c index 749276b..d6ef5c7 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, + struct page **pages, unsigned long page_count) +{ + return -EINVAL; +} +EXPORT_SYMBOL(vm_insert_range); + /* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty From patchwork Thu Nov 15 15:46:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684651 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 5E92C14DB for ; Thu, 15 Nov 2018 15:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C6BF2C8A4 for ; Thu, 15 Nov 2018 15:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40FAC2CB88; Thu, 15 Nov 2018 15:43:32 +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.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 D6C9C2C8A4 for ; Thu, 15 Nov 2018 15:43: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=yDs4Xms5Ue56josWB+LHsRMfigi+c1rAhzGbOMhld0k=; b=ZmPremPmRm8reA 2861KcoVujpcLBWw3hypE1j8vOAbEXMvi408B+4OTwlWBXfNZylBtXRAw/+23YUDV9Vbp18iFFZ0F wjPTJWjq9fPgADiP3hiOCVrPsMU/VNXDdl+XAvcpZQ8fttJnuJP5mBlkSZR6hehQumTEE3amuPk4C znve2nGl9AMIrGomqPhhXKKuF6Nb1Yk9bi82L7cDf85JdvyRNX8Vyi8zHCS7G++LJvah9DfNn4o3S IRUpYes/NDeRqwkeO4gGIfsgfTCNMqjT8V87b+mIxl04I9bpdhuDcsnenBf7qj//didz219woyjli +ViSb7zNzIxCxoCN/Jyw==; 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 1gNJng-0005kQ-4q; Thu, 15 Nov 2018 15:43:24 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNJnc-0005j9-U8 for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2018 15:43:22 +0000 Received: by mail-pl1-x642.google.com with SMTP id b5so3247781plr.4 for ; Thu, 15 Nov 2018 07:43:10 -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=pCfJfGGRC2UtHAm9HA9aL0m7FenKYdHmKJW2cNiCT4fbUX8KyYAZol4NGubhwf4ix2 JcfsHY3HzR+LD2Gb35qfzVgY1IXhMHnzM33c4dii6hjPbeplvdrBBjf/idYXgOa4HeF4 YqSlCdyPQleDOp9Ofz01vlgd2gfpDL0AyrbT2kWZkpPS2R8a+EQgE0qAz3f8ONGz2wIA cW5Mm2FkhkWKiXO2vC9eyC8WDTsRmUeEmiaMGbYoGFmo2djVIibp1dvUH2JzxD51uN50 IxGo0q4UVc0QPq9Uc2pBekL4kOycmBRKdiAhHeUHyXMzaxqZqXdWAFSq0E2f664geFlm qyEA== 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=AkP/EFE7Sabp+I+MfVDLQ3HL+7ppUkH0lU7pQWS6w5E+6Q/rcBkZwBTRhPkMh1UnF3 M6P04gLRHysMrwjTHlT3xtRMXC4/O3teNcZzPPzzUY9a4PKTqkr0Zc52us0I+BUb6zQm rJuDs+u0JOgovNrVpw0XklCKKSXiQd8jp/X9whQAJvfrlsjD7NluAijB9xidFw1f5e/5 7pEPtoc8KskSS6hSP4CRJC8plvKF7sd5jdUqHY9rNQzUhCA10Dxu2VB2UlQtxZO0r2q0 yzdcEK8JyHZtbsL4lrkN5oZ3lujXEs4dv34nJTQ3+hki8jjXreXFzLfSR8fRaGqkQc4h +nCw== X-Gm-Message-State: AGRZ1gL2sZj5CzO0ftEmvSh+/K8nYiDrOE+xRB7ZzOrp+wJNstBkVK/m lnpqycirwuBxMadZ6UBPT8rB2oAW X-Google-Smtp-Source: AJdET5f1R8LoBMhkPMKCZQSqkbiD6+/xv1S3DM7BTCxxtIUioUmrA+uSzrT7vwaK3JvVIPNypMhWlQ== X-Received: by 2002:a17:902:ab83:: with SMTP id f3-v6mr6507758plr.122.1542296589903; Thu, 15 Nov 2018 07:43:09 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id 4sm25997357pfq.10.2018.11.15.07.43.08 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:43:08 -0800 (PST) Date: Thu, 15 Nov 2018 21:16:46 +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 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181115154645.GA27912@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-20181115_074320_966729_1EFEEA92 X-CRM114-Status: GOOD ( 15.64 ) 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 Thu Nov 15 15:47:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684655 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 AD9AB1747 for ; Thu, 15 Nov 2018 15:44:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97B062CBA8 for ; Thu, 15 Nov 2018 15:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C0052CB99; Thu, 15 Nov 2018 15:44:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 39C822CBAD for ; Thu, 15 Nov 2018 15:44: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=RwAPS6Dqf3rRwx FVKEmUhs3tx5jCS3kRUDRJodLzhI39c012CFk+uhK1o+2AqKxdrBxixcnz+7wMmkkrlzFNNEki9sE veRlfOkIl0JGO/pupQnrRy+Ttr2tUzXAw42wdbs37ptsRXC2ddwFnXeYRu6zI/eINrwxkvRcUgvZr aHbw2V6YMX1RqtKTfvFzqZAFMyjxCVHWxXb1eoNEtOS7m7zYd5SoZIhp0oKSlpU8Fy4lXlbHBaxaQ jFBxT9qggV1unXBkBJb/40x1isWKA3QX36KhV0lxTOWnTc4EEfeRrXPBuVw7kU7H1yp09HsGlG4AD NqID3OLsmVm5EgFthRDg==; 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 1gNJoV-00067H-GG; Thu, 15 Nov 2018 15:44:15 +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 1gNJoS-00065G-Tn for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2018 15:44:14 +0000 Received: by mail-pl1-x644.google.com with SMTP id s5-v6so9653383plq.11 for ; Thu, 15 Nov 2018 07:44:02 -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=epRwUqy7htlLmwiI24Igzw3C2oNh3YVt5/KrBuU7kZgm/q5KyELQgGneXGQT7KYl56 a3RPp7G+9jGSYocoRz61BXFqCxjj5kjQ3gfSEKVVQLgHz/flWOteAimfOtCvbbgEYkG8 CcSujgQPd2yZZI23W0wET8wDeoaj8n3Nf2JZsVNdKJhDeJv6vb3FP/jiMdHqHt2CJln6 mAZJudFpETbCbNZLF7yseNL0Tskx0lPoRljbm4WuBW6I61un7FVqA0Tgcq3pBkkrXTrA xkOW8ZMIMv2ZW/Lf/Exdd1gaUYmfX8+qHWP7IGSrnJsyltqvS2md833QBVWTLl2eXkdi kXDQ== 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=ka1bBXi02/FqB6YrcayQKhKRUh83ECLoKU3lJ8v3EkuIkYWm5b9bQc+xIJKE9VQ2p4 G5w/wChdS26ILUbxkjjys22NtVNNI2YC0hMVcRXEotKoHUYSGbFdYnVzd50xPyhiEC9l EMAJDS0O0CP98j5W/xiMRuWHss0uIjOllfFRGPpgb4YGybSC+aXe6Bplb6RJWi9E6y+b FmzVBva8cIpZaQy2B6E5UGWDSJj+HNmbb+P+33gw1Bf42ka/Ljps4LuRVqu2tlgTsgkI LPZYs+6dZv2Wte7imYXK/shTm7If4kufbk9VVbaKqIz8iigbYNlGjqgOojWIFwTHX1Xi uhMg== X-Gm-Message-State: AGRZ1gLH6J2YiJEjyvgsM1osrEFyD5l3slokLrEJUB7sUcfb8f6jYHyc HEAtgRUDO1kJe/BbPHi5GUkonZPM X-Google-Smtp-Source: AJdET5e2nV1ILwV25QmCQEcQZKLe372AfAKrda1ioGmmzBYIfWQwY2V+kpm1Wxo55YOkrsox1AToPQ== X-Received: by 2002:a17:902:560f:: with SMTP id h15-v6mr6963057pli.160.1542296642414; Thu, 15 Nov 2018 07:44:02 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id x23-v6sm27487376pfm.126.2018.11.15.07.44.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:44:01 -0800 (PST) Date: Thu, 15 Nov 2018 21:17:38 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, stefanr@s5r6.in-berlin.de Subject: [PATCH 3/9] drivers/firewire/core-iso.c: Convert to use vm_insert_range Message-ID: <20181115154738.GA27932@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-20181115_074412_954631_B3CF0538 X-CRM114-Status: GOOD ( 13.23 ) 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 Thu Nov 15 15:48:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684661 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 91873109C for ; Thu, 15 Nov 2018 15:45:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80BD72CB45 for ; Thu, 15 Nov 2018 15:45:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E2732CBB2; Thu, 15 Nov 2018 15:45:15 +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.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 1E2D42CBA8 for ; Thu, 15 Nov 2018 15:45:15 +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=LCO9basvgg0z3gJ22bIEeGUXXJZ4BrnWwC3wmTbxMkk=; b=bGq5umxPtoBM2V e6Jdi9TVQJU/kT/pYg75nnCwF5GStkpHuvPn77T5YQet7FvRaBzJ9EDW9uQcwRe7rHzMgq3coczHl UGlZsABudVnQpr7+zFQ3yDYu2JzQAho6Q88FKV1S5ALywAPFXXNoP7W9IT7Sip6MKl3a60YFrBNL4 2e7raqhuvnflkG9pXGP1yvffXes5siP2Ta0jAaV700+6ZCvpNLeS6mJKiar/VjIL7Q+aO1FMl0KCh nf/8b/2S+HFjh9xdspU66IzcCntQSQMvd25LTNIdIbsAz+f66K7oB/MmJ7/jdDFR8ng59HW/PjH8O 2DOT+sgEzNvH4eEFKT5A==; 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 1gNJpL-0007AH-I1; Thu, 15 Nov 2018 15:45:07 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNJpG-0006eA-4Z; Thu, 15 Nov 2018 15:45:04 +0000 Received: by mail-pg1-x541.google.com with SMTP id t13so525570pgr.11; Thu, 15 Nov 2018 07:44:52 -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=aM1C42m8xdOqFETa7vpI1nSS13dxTXWD/5chbQoQBa8=; b=WPUlk2x5CRHbvpM1bKX0kitApnk9BOX9wd6CvD1uXCrRKIH6tLEay2hxykg+jfsOB5 J3wKWSBsuJ6udvfS4G6bvMcO6ox+2kzBEBlokR74eBZjoMw6d8x1PN71smAmcbb6mBup OdgkIHjtmqbhHbuOLy/q3SSyLzA2k+Xpsv24H8M3CFunfT0Vso70i7cPyZZzP0niaf+O JGIryGQnwC1aAak8kAS+Qx8SqdiY8zDRVlIBvvktT+IuNNm53fGMh6V+fHDKJ1kl3EAv aNkn5Ps0QTpVVhzhG4tLFaxNej9aYPChR96QL/bg7V+spivBI26bw5QPRPmo5pwul8kV BkFg== 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=aM1C42m8xdOqFETa7vpI1nSS13dxTXWD/5chbQoQBa8=; b=XFONmt3p/Pip87BCUhBYTpsiDIwwn01dBXkarDNq62Y5HgJp+5NEUE6sRkLRFxk3sn 64qbfmRkF/FcGM+IEmHSlokuNMs9SExhT7CV1Dnd32KnlDjuH7vLzf38JnJshnephQK/ 05ZIskW8J0JGD5WX/nrUuf5BEZogstcWikkiBqCErYgCTg4iRoHVT8ezWxF5rW1cfwJu okr+6Scr6/0ripkhjbgZDLh1wpoGvooz75mJB+TlML71rJtwtjUkF8Z9qgJUNAx1fbTe iwcK054txopKksC9XW19JyGNBEGJTggITYgZ8VHJzgUTqHuseOJG/goT6ycsM5X/ato8 T9/w== X-Gm-Message-State: AGRZ1gKTHlfzLRQyKRjWyO4A9P6gPpkKYPfcHqQQU+KtszvkTBa/o5f8 CeZDCRvYCeQCDk8esItUMW1X6Ao/ X-Google-Smtp-Source: AJdET5e7n4pF+rhd6dDpXXTPWo1Rru/vt9norA53b2YS+zYvPSJKdhFnnXdL8xxj4jhF0QHgnmIpvw== X-Received: by 2002:a62:6241:: with SMTP id w62-v6mr6901975pfb.69.1542296690923; Thu, 15 Nov 2018 07:44:50 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id z127-v6sm32794856pfz.135.2018.11.15.07.44.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:44:49 -0800 (PST) Date: Thu, 15 Nov 2018 21:18:26 +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 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181115154826.GA27948@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-20181115_074502_197634_92072F07 X-CRM114-Status: GOOD ( 13.02 ) 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,