From patchwork Wed Feb 13 14:02:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10809979 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 A6021922 for ; Wed, 13 Feb 2019 13:58:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9105A2D048 for ; Wed, 13 Feb 2019 13:58:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8593E2D0CE; Wed, 13 Feb 2019 13:58:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 37C082D048 for ; Wed, 13 Feb 2019 13:58:43 +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=LacHrzkRLThnLynaaORXfyuuDEOnTOpBIdlX8qgBqyM=; b=SYlfkjtwqEyPti DsmQhZr+h5kuRzq/4wrIA5kQ8vjb+ddg9kU4MvTyWbOXnmTdPcjU6Z/vspDmFNPz9HG5tROiXWLHh ZGv5jeaXWfCJ2+keRoxeNkhV0kHw+5qn820b2CYqflMJP4Vi3BBlbOzKQDS+f1HrXV5ZoAQjIfuCk bSK2oCEpDoD9DEh43hu11tlaYSQbByk4YWkgjhDwX7t2upQjMPB3rCESazxfxs07GmtuMhYXsxBN3 c0u3ZjDWPUzmYsTK2tFrou/XlGtXhwRSRaLwuYyvF30lzfHBcwWAKDWADWNd6MiyW7Xen9Pdqt6RL vwoFj+qYyuKRBcU+SiJQ==; 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 1gtv3i-0005rf-GU; Wed, 13 Feb 2019 13:58:42 +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 1gtv3f-0005qY-MG for linux-arm-kernel@lists.infradead.org; Wed, 13 Feb 2019 13:58:41 +0000 Received: by mail-pl1-x644.google.com with SMTP id e5so1208702plb.5 for ; Wed, 13 Feb 2019 05:58:39 -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=cNyFM0J2DfW9voxw9FzV7E7Y/LrzsWkGDKLqwe0d5pk=; b=pbigDwG3xTm4YxvGqJgLG5mkUt5O5OB6iH/4JOZPoXunwWHE5QfP4W9AElQvSudJa3 oftivCtQcvYNS8YSZXakLgY/n/6uMXhgwbuZgbrYOMW2A6d9qxKamu6y4VDWZG9hKIXJ Ozs0l8wXg2IVBGQ5Lx1acSQcHqvuaQpFa+H5Y1d0IpRM9leug/xYa7/aLNdDjG8Ibi0w 4YGogL/vRIFJoYsg51t1pmC4flEIvAwvnxiLzYGzdVd4eEsIiXYF+OFdhEXjta13phln wgXDc3SFMpLh8t92NQ4l/buWitqvWvWgjk6iHFgB8KwSjqoqS1sBA9XRvXu1Nzpx0Uuh rkog== 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=cNyFM0J2DfW9voxw9FzV7E7Y/LrzsWkGDKLqwe0d5pk=; b=M4Hzp8EDHUlGbVQG2TUaEmLMmMIslyl9927JyxlVBu9YqPU9kiORUxsfKspCuvGHGN 8sV+lC1bb3WxALY5MV+StFI51bGmd73ogk0Mr/QzPk+cxaQwy66e4/4FHGy9Pk3hypmi b0C2LTy08jktOD5RG0s+kXSLtHlyYpWkis35LFBV7Q5f9S9wiTo8jP2fGI8P08N34XO9 umAGmVtdxj6qYqWxotyUtoZqDmNelh6qpGQp4TUwX0zNu4P8e+s5otzKEmbyiFlMDV4z kz3NV0mr0fuo/gDbL2sVKxY9bQl8WUkhfEiIFqEj49gxU6j0pEOI1010duecZLOSbxB0 2+vw== X-Gm-Message-State: AHQUAuY1hzFeGzqZ89sWJnTv12fl1EwAXXYDvNrQR4YW4vi5u8W3mQKc JhU1rTUY/RGhPDE3QhRFoAvfNJxE X-Google-Smtp-Source: AHgI3IabBr7i0UINT5tZChzG9mkUSIkz97ziRf+i4G4ZGRQ2Pfd1KkCHgUpEt1D+OFFkb4bWmp/4Cw== X-Received: by 2002:a17:902:20e2:: with SMTP id v31mr640198plg.307.1550066318585; Wed, 13 Feb 2019 05:58:38 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id f67sm30721286pfc.141.2019.02.13.05.58.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 05:58:37 -0800 (PST) Date: Wed, 13 Feb 2019 19:32:56 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com Subject: [PATCH v3 2/9] arm: mm: dma-mapping: Convert to use vm_map_pages() Message-ID: <20190213140256.GA21977@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190213_055839_724825_4A5DCF80 X-CRM114-Status: GOOD ( 14.63 ) 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_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,