Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6620178imu; Wed, 30 Jan 2019 19:06:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Yx+Y3dWWQoId1fis7RgPh+ZGPV+hkcu5jTaE7+qkLr+Q6QNEkDm/pCEni4j0IMZeFV0hL X-Received: by 2002:a63:ba4d:: with SMTP id l13mr29731277pgu.194.1548904014603; Wed, 30 Jan 2019 19:06:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548904014; cv=none; d=google.com; s=arc-20160816; b=vgg41PmSx/jm45bNmeT5ZWexp04OVavhoeBlYZT2AOYY/S1ou3YIX9/1hktK1vPvTj yTXqiOfuZKALoroF5kKMVoneEEEVppP89XxTrc2q3MXiqZerEMzAHjLBL/nqsWen+SzK 7dlbwnDelAaktYp2/qodflBDjy9ft1/vFjwINhttGGetsV63Mc1KpJ0NM7kuQKAjltO9 aVtSUMjoIJAhPaUwt5hvSg+YoJ3ZKuvkGS98iP37dkYvQ0sp2Do1CXnAvt7jhNBURsuG obYF+etok18sUBdb0GkwVgCwGMc2SVAFMQ2CvzXAKplCMlTcPS6dg/+dbLuie51uNST3 QPow== 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=9UKheLNLSM7085+hYajJxzL+Wpldb3TOma8RXX0hjL4=; b=BAjZTZ55AWxlueK/iDLLFEWTxfzrXO0ijbLUwgkK004wYIH1sYfbMqPv/Gc7jOmN4F 90PGEaTWxQoFouKaqcvvTUHw+aaY7H9OgxxiDeyZtKWFKvzAKZlTN5Ev3MXq3g+xznxx H8VfiJCQRKqrkHkLhJtTrzKxE82mCThflJkQJNbwYqQyj/MD9zaVgkIRaoxhMEm6UwVg AdszZR3Xnvs40zs3OdaSPTiEgM52TXrlnhgbHxDkzpoT6AzwjeTgcDIdXiPu0yxkWlu2 PvgMr39INuPZaZ4Dtlre5CyE2cqN0bZ1DoqvDODhGVWx8G8ljP+mldHOlcZhDcWGU2Jl +p+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tSgjerC4; 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 r14si3043269pgk.75.2019.01.30.19.06.39; Wed, 30 Jan 2019 19:06:54 -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=tSgjerC4; 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 S1729343AbfAaDEs (ORCPT + 99 others); Wed, 30 Jan 2019 22:04:48 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45502 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbfAaDEs (ORCPT ); Wed, 30 Jan 2019 22:04:48 -0500 Received: by mail-pf1-f194.google.com with SMTP id g62so782025pfd.12 for ; Wed, 30 Jan 2019 19:04: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=9UKheLNLSM7085+hYajJxzL+Wpldb3TOma8RXX0hjL4=; b=tSgjerC4dK44S06W0OSTr53cNg28+6cUTE4HzPUKTdkevWVpDJ97JFTp+cPosrPNEV D8rphH0u8PJiDjdQsW2TNjafYIBoOsL1lTpSoOkAZyJOLs4Vo+jTdmYEwU7Jl7hXgk8u bhAoeiu1BDGFLMWPAWbdszIxVsMvwVSrmn9/NbkQyumWfBx94sOwPfkrdncoz+vMpmLN GvJIbeBoL5m3lTrGsdAHY7E5Ffo5FQtSCX5JwL9a+t7uCBTkj1fO/HsLuTpU2zXaDEU3 Ob05VCxwKCGE7QtPagY4Sd1s9LT8xNY41xJLt1okURF5K+hRbPJY9tnqbjP0VDuMbxqy h/+Q== 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=9UKheLNLSM7085+hYajJxzL+Wpldb3TOma8RXX0hjL4=; b=VFzEyDC9YVQHs8erKH/zvRa21Y+8oAtk5N/n4m/lwvI+1RZSjGWDdAfo+Tqyqq4Qfy A7xqOOQGvmpz78ZKCvuiQ0j/1aLgGJq/O4IWvCbu/arJYDSTa2QtRBziv9c6sDgwFIEm tTM45mr8nIzROW3PhQgCj/mfH+tr9yYOmoeY7Cz85IpxnPSBvij2ncMoPlC5PldrrcbJ heebQUoWry1uMix4G4rxHJP7AJsci2eBlqjkycrcx5sMIpD81epfo6Z55qu5qy6JwLgZ fhRuve1IxhrF3J1Hq53JslsQ4dzmnT+o/R0JFwqsuXq5tvHREhUndUqLnODcdzGkKUG/ 7Ewg== X-Gm-Message-State: AJcUukcBbjHWRsjBvx8QhebJC/KRmRgBkEW92RcHYckT64cR1X59lbSM UFXk5qHmYGdAZFot2wnE8LI= X-Received: by 2002:a63:7c6:: with SMTP id 189mr30429168pgh.129.1548903887364; Wed, 30 Jan 2019 19:04:47 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.20.103]) by smtp.gmail.com with ESMTPSA id o13sm4055072pfk.57.2019.01.30.19.04.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Jan 2019 19:04:46 -0800 (PST) Date: Thu, 31 Jan 2019 08:39:00 +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: [PATCHv2 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20190131030900.GA2284@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 f1e2922..915f701 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_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