Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp989152imu; Fri, 11 Jan 2019 12:48:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN5mkhfnA47mTgv5vdXVfL4jETyE+HRi6lsFF4O6yqpY4ZOPV6AY/aV/UCAfDsi1LZXr1CFF X-Received: by 2002:a62:18ce:: with SMTP id 197mr16605929pfy.88.1547239733213; Fri, 11 Jan 2019 12:48:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547239733; cv=none; d=google.com; s=arc-20160816; b=rM/i4+3f6SVaWtVX852pinGQ1IFaj31nL2AW5WgoMN28hwn7NqnQzs5IM4QUNkAMW0 XRf7NRX88wAInzBeb4mA74WJ9bR4zlJFXLDMdeCeO+M5n1CHgwc2X6fksILxgDvl0TAp EzKv1CFXEElsQBYpdxUXkxox3z+H3xBA8Hec/upUBBGZsSvUR65kTsRKpgrWjL2Nz9/n mq80KcpPFahTixj3R1xbRof5Mvsm7cEd0tdM3Ak/Y6S0+uztd0KlQoH/Vtd6+mJ4rjBF DtIvdmuz1S9TuSZnjNckflvW7tkyTqS+SzWc19eF5DFXhWvoDZn8zKPy74ptpNb5UJlx qbQQ== 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=WzAQwD4CMcNjfYojTjRfy8sqfmAAp9apVnphS+7qE5M=; b=qqC9rWAib1IpsBl8Z0BK8rzDXCvukSaxRBPrGao3REWXoXdOVdk+xlmgY1jG4OApO6 D0193blt6AHJvKnJHh/9JMs3LOXkSHQvcSHY28hhrk0jnNrXT5+6+l48cg6BDpD++Os5 wKU3jegKTZgB/4QX82/6mO2E8reRRc1JmhGNnORvPptlM5bcH3XPoOLDscSixq+SkJT0 UKgdYtdA5iHfBpz96E9iFdHwwqJl0haGiwX6i5J6fPvIoK8p+ljNZ/QhV7g9KPHsQ1JB /3tYJX24XbofIf5Ld+wYaqSWKpLpE2CZ0+I2dY+REKj1ioJyPXQ1WRxI0UvyqWMIvxWz UDwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HQ9gfhsp; 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 x1si20219438plb.366.2019.01.11.12.48.38; Fri, 11 Jan 2019 12:48:53 -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=HQ9gfhsp; 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 S2389911AbfAKPEE (ORCPT + 99 others); Fri, 11 Jan 2019 10:04:04 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36822 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389000AbfAKPEC (ORCPT ); Fri, 11 Jan 2019 10:04:02 -0500 Received: by mail-pg1-f193.google.com with SMTP id n2so6422981pgm.3 for ; Fri, 11 Jan 2019 07:04: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=WzAQwD4CMcNjfYojTjRfy8sqfmAAp9apVnphS+7qE5M=; b=HQ9gfhspvagPH29Me3BRhdtcdpJ1ppAkZvxlrEmPYgRip1IdthcKcOCiWAVY5Z895Z PTA3IoN+JoobjwcMS/8b83st4Y+6eHz3yTWfKmWq6hBWZF2NZmmXzgF2mJsADBChdpWa BlzbeMjQsitVUoC0lUosclfzkAMgMA1uWDH4Q+jXZ0a8BMEvbSD4/3aYiYIx2RYsqrV/ uREttfKnl7dDB92r8GsoONQTcYXgxNyBsHnbW/433SZk5GGTnHZxA7gQrkXu0wYSvHer Vv27TCONFgJ3EJ2dLRQBnpmyzs3Y3diG7h3yFHd0GF6Ho2Vfd1jpkcOJiHFErnXjtg9V WdNw== 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=WzAQwD4CMcNjfYojTjRfy8sqfmAAp9apVnphS+7qE5M=; b=otzgPlZhcHZI+8WQ23axDco7iONhcs3IafdZm5151MphLHh6EqjGEmf4HMtY/jmxlf IJy+ga6tDfRveVJvSQGSSVfnJ5kJk0c0d4ku/zq7p11G9nx6vDld3BjB1G1joHKP+Z37 7xqcwc8oG/X0aH1X1TNQ5zZ76xRXOS1Fkho0r8WqF05JkijxE4Dx92AbAss0cpnoeyAB AbSZJZabX5xjkUm20nZxqalBRLRaCsy/oKubpYP/FlMP36KtSWk6hFrBDyU089iOQ5ZV DkBLM8QPpQOEMPsI60RgUzztziErxMfXMT9PhX0W9DcY+T8gtW8QRqiydTSrxdlRON1J Eg9g== X-Gm-Message-State: AJcUukdGBU9zqcQ0/Xq2TnJmdqTx33Bt8zWJ8PKmxcwd9NkoU6a0KJDM CLAtFlk9X7anQD00GKu8ePE= X-Received: by 2002:a62:1c86:: with SMTP id c128mr15538564pfc.54.1547219040807; Fri, 11 Jan 2019 07:04:00 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.52.190]) by smtp.gmail.com with ESMTPSA id i62sm92403752pge.44.2019.01.11.07.03.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Jan 2019 07:03:59 -0800 (PST) Date: Fri, 11 Jan 2019 20:38:01 +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 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20190111150801.GA2714@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_insert_range() 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 78de138..5334391 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,31 +1582,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_insert_range(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