Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3601703imu; Mon, 24 Dec 2018 05:18:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7kTfn7nRadQ62FPtx79f7okrN+OCyVd4lEek8Q9l/1KDlluKerD1NWj8A4kYYRRlKsaVo9 X-Received: by 2002:a17:902:7687:: with SMTP id m7mr12829076pll.187.1545657539616; Mon, 24 Dec 2018 05:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657539; cv=none; d=google.com; s=arc-20160816; b=A4SIWKziqc7Q2mzy8vMwElh3EAErFMEyHJIUE07YWSygTAxtnEfPVsZ86r2tfGm77c VXPhQSzISmDNQ6jut1nuS7350zFO6G34oTCUsZWD6BgD9xaySlASNrqMisePmKWmDEFX OhzZ9fF3cGnwxhZly4yFkBiCcHJ8RzvK+9xa4SUjHl0IUw7okjJY8BvWKbgePCZiQDu9 4ml5zPHQmpRrfpbwRBI3d1Wve+Ybx7G6E+3JWdG4AVhyQ/DFZiIlFotr7/J5x3ej8q8t i8jt4Mk1v/P5ibVV2nlKry+rPNW+NR/pMrM08/e7tSmogMdqFYdVzf/EzblUvyocQWBC jBkg== 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=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=CHyZlsRMcFQfckFPTjc+NPds1YYmcJ/JnPY1Jzbf8v3L53Hf56Pu3YILYs1XAysLar Dk/faMZcyWsadO59iR/FidqoeaPgQ4JVfI/Uj/Ftf0bcmAB1kdUp0pjZMp1/YhmB2fbp OzzNB1tkC3U2SGs8C7uoXjXGnjB5/auboNUVWHNiE+ckhmAuGXpLBYt6UECOi5JTwYNw rKhfVod4zQmmgeYKZtMiAH/XU9XznQPJ2HEDlRnFr0gDzg3b9udu0IY3+Znr9S4XhZIu 7BDMYoPEXtc5njJLZvDotNcSVYtOC5fc1OZ1e5XrI6HEaERBzAV0zK7cY95MLtzJg6cY WI+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i2KO5MMx; 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 r12si26965647pgl.350.2018.12.24.05.18.44; Mon, 24 Dec 2018 05:18:59 -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=i2KO5MMx; 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 S1725934AbeLXNRr (ORCPT + 99 others); Mon, 24 Dec 2018 08:17:47 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35646 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725497AbeLXNRr (ORCPT ); Mon, 24 Dec 2018 08:17:47 -0500 Received: by mail-pg1-f195.google.com with SMTP id s198so5596983pgs.2 for ; Mon, 24 Dec 2018 05:17:47 -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=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=i2KO5MMxJo3/5LWrPLeNLGeva3Ne1DqGYNQmkVfffqJy/7Blwc1ZQTxF5q7/4cdbVK vIexInnWRoT/V11j7MMRf8p2pNk7N6+FKaVdWJPsVT0PJ7MRGJWCmKDRYYVgzm9PVFZR 7Kz4JADaRzoTvV+K+ajZHPtgb0txgVU5jA3CliuIeqyf9MC+6XxOOcepTV0uLQH9GDeU B5bw7Mj0iLy6LrkPqE9j4pev1wfm6d67jrKNbReUFngf1M0upuqrGUYdICcRDO0tsAEw f+JmsDBaFgTBiSI+JannbW3PzQBDJacAB8VRitF1ub03PgJ8p0gttKrXb8wKIRMKAK35 /Ikg== 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=MMGJzHhmNthI9sRZkbXZ1iYyH2jshJ0o/VQkgO88tcs=; b=SQbbtGfJtUPYX/Qh6qODbCGsbrCQ/i5SSCBukcktt/uony4f0dcE6+WbunzCjlg6Ne wlvIsb1TYFL2ShQykYAB68ofrEapkKGaLnRJBi0OV1PaE5bSd9c+spItNdpP/snx4Wnl EYq3qyo13p6tGGAbRDsm9Ahf8GGkcntm8YyuiPwNjOcmPEX+YpoLrZfjc94ZNeaaUw0v MKa0TwIm+gV13jeaDOuLD65Bxwa3RRQ9LyubIRLmE/vwHCbA4IpeebHCVdcoVjZ88gt2 oBQQeRJXwu7ZaopkGJ2boTMBuzxAyEQfYzxJr+tfInjC1gWhXn6mdJA0ZEVA4r/kZz41 1AyQ== X-Gm-Message-State: AA+aEWbCjZdkdNjO1P1TpcA1iXYeFJ7+XGOt63tgYuCwrQFIZF5bE55r I9I0FYv8dd78C7agAqdAk8A= X-Received: by 2002:a62:e0d8:: with SMTP id d85mr12901342pfm.214.1545657466691; Mon, 24 Dec 2018 05:17:46 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id c23sm39254231pfi.83.2018.12.24.05.17.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:17:45 -0800 (PST) Date: Mon, 24 Dec 2018 18:51:42 +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 v5 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181224132142.GA22070@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 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 661fe48..63467b6 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,11 +1582,12 @@ 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; @@ -1595,18 +1596,11 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma 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, -- 1.9.1