Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp211908imj; Wed, 13 Feb 2019 07:09:07 -0800 (PST) X-Google-Smtp-Source: AHgI3IYYsf/k/ViSgjIQqjsZRISA7QA+LytuvcKYGMjpWbEuwVvXItVBogph9W8U6MI5r4csFTMF X-Received: by 2002:a63:d005:: with SMTP id z5mr921032pgf.64.1550070547712; Wed, 13 Feb 2019 07:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550070547; cv=none; d=google.com; s=arc-20160816; b=DHuAHWyKJJkyGDvhAG3lpvBvT5Nb6wKsBxdBY58G14qQ9eXOuQ/XwjnJm8teQg8i6W 6s+kCoIfjIvy/Objcz7aD+LYqglYAU7n1FTKIJuOgJxmXhyz7NgtW2lesAvpKiDG0JJN RTu6Km/DouYWtY9RDAKSybAyTjfOAJO3H4spCzP3B11uSHgC5TT9NrGa/8Knr7lbvKId zvZlzKtvfbNJhzHSZm7ARRFQ2PuC/JKxznb3NeGNVDzHC+zjecUfvB2mYEB0oWPFyRU+ o+DN9k1HhvzBT+x/Ev6xYG0pjW6CZGqZArMrAZBZ4Uc5tfecvxTBFvXyp2UbYhxBQC5o JPBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=cNyFM0J2DfW9voxw9FzV7E7Y/LrzsWkGDKLqwe0d5pk=; b=sF4w1X9YJEkPKkzJcTh16boOpwf6+RsEuDvpjboNLANCykbn4nQWEdjfZ6mKRxyQAq 3pj3MVcKxJ8IT9cH8bDOqSa5Jr4D1NpVhPbdsLLvQmiLG9M/d6FpaJ3YG1FFIFhOvK2A HrJkh+BiEmFbRUz9WOYnExd764KunY8IytHsWsW+1Nj2DDbwQrQAhgZ0dA6TTYzaBH5d TVvPGEZjvScwVQ+oG3MtXffhTncSXJycte+1Pe9gNpWk9BfU4b8hQwMzlfgn9r3TijLB 01bQ842GDn4R4OYdLKVZUxfY9lrAPMJu/wNWAqfYodZV9XbM0NSn1FA8GaF6UhOf/SB9 N61Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pbigDwG3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si1097731pgv.125.2019.02.13.07.08.50; Wed, 13 Feb 2019 07:09:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pbigDwG3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388912AbfBMN6k (ORCPT + 99 others); Wed, 13 Feb 2019 08:58:40 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39945 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730685AbfBMN6j (ORCPT ); Wed, 13 Feb 2019 08:58:39 -0500 Received: by mail-pl1-f193.google.com with SMTP id bj4so1199408plb.7 for ; Wed, 13 Feb 2019 05:58:38 -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=E//Ud6Z1DZNvdATKTtL2Y/CooqA8udszITDd4cYzzln94pXxIDTyN1UGIvricHoE3P d/9O2vPH1QHJLvVxe3Wk27sESDJNWS65p9situAJfc2uQtC36GSnSvHUevuw6dTb5Ekl ASDgYqxZwQF3kdRDVuUS9Qf4GoSmpLwjHOYHZ5gIFd4HyVgoTH+Sw9tkfUnGa0dY4Vep gvQoetbWTCK0Uf/lNzR4BAq2rfMAMCn9wkUQgYB7BYein1qv8bKOGHxXDALdERiZulQ1 7PDFtdAbI+1zteiyE0u5LWrWH1DDJjntGNNUEt+E3KRO1BeRvErpRAfPXk9MD5wq+MPr dZjA== X-Gm-Message-State: AHQUAuaY9wzTM0Z8IcvT1w4msp06ND+u8I0mHNA9UE25leLzYgN0jxZj TblCPZIoxxup5AmahXKb7ik= X-Received: by 2002:a17:902:20e2:: with SMTP id v31mr640198plg.307.1550066318585; Wed, 13 Feb 2019 05:58:38 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.48.54]) by smtp.gmail.com with ESMTPSA id f67sm30721286pfc.141.2019.02.13.05.58.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Feb 2019 05:58:37 -0800 (PST) Date: Wed, 13 Feb 2019 19:32:56 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, keescook@chromium.org, m.szyprowski@samsung.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/9] arm: mm: dma-mapping: Convert to use vm_map_pages() Message-ID: <20190213140256.GA21977@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 1.9.1