From patchwork Sun Dec 2 06:21:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707849 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 6BBDB1579 for ; Sun, 2 Dec 2018 06:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5670C2B11D for ; Sun, 2 Dec 2018 06:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 466D32B12A; Sun, 2 Dec 2018 06:17:28 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA27D2B11D for ; Sun, 2 Dec 2018 06:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07CA66B61F8; Sun, 2 Dec 2018 01:17:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 000936B61FA; Sun, 2 Dec 2018 01:17:26 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE51C6B61FB; Sun, 2 Dec 2018 01:17:26 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 99DC66B61F8 for ; Sun, 2 Dec 2018 01:17:26 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id bj3so7475911plb.17 for ; Sat, 01 Dec 2018 22:17:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=M5GVk7+Gz+2YNymxj7d3XB1f3E675vsSass40DGnlxojzPMb32f0yBwucmoJYGLNM/ mBGbZ+K9DJWhqgxycRcPYsj4ZI90EGX+8fAlIOYiPTtlSAsOz4cKIGGUvnad0VMPr746 GlCSK/gRzdS20gELakE0gyg0xYvLWSM1zr8Msu7knjWIg7yiHAccT/f5WjuS6gilnYqH JLx80iYRBOhTAX2+G/9/3agKGkplEgSatgXXiRB65bDHUl2uh2kXD2YglYdcFi+MBbiX EOv7K4eDUhQpolPb6dXZ2mJereFXzRJ5jxOSqRzpSIqK/YtNnsrNV8R/pQhImqmrk7j2 cvFQ== X-Gm-Message-State: AA+aEWZziRge2P9RR7RrqtNn1slkQyh2dEkXPvWKkgtdZIGs+ZCPJ9On 1CM2w/W772LQxRdZ6jKZ94MQ1j81rThxXkfCKQTeOhBJymKQri5EFQ/4YFq9tvNhHWpMq9yKiH7 SY8CpzshybUFEjWZHsuJXZ1b+W1QAOHQbMc4yJooT6PbqTCGYyWpLL4omTt5iR1uAWtIHEZzbyn m4KWQawMyjIqrReQ/PiCxtW6G9lC1OuMoG70KEkwF2fdjrgXnSODb5jrVcxQITetAn6YMV/CkoD jchhCdHN3bUJ580COSjhSpWrGil1lUTFdA5BcVp6w6EhaTyftu5rhZSh6+23Kg5SLRqcxuPo2Ga ORjpGZ/rB6UO+17Kx18lQWyh5twpyfIevxoPQ0NmP5OJ/QXPnsVAoND4lGto6DUo6+HLLtd0gZn f X-Received: by 2002:a62:109b:: with SMTP id 27mr11154388pfq.227.1543731446299; Sat, 01 Dec 2018 22:17:26 -0800 (PST) X-Received: by 2002:a62:109b:: with SMTP id 27mr11154375pfq.227.1543731445560; Sat, 01 Dec 2018 22:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731445; cv=none; d=google.com; s=arc-20160816; b=U+MxFcWEDydk0S1YPvsSPThecRUwCGMFtlOPv2sHKlwx6MWN9eg8LT8b9TA7t0PZdG fwfyGp3HHHekhGhE5zCeZTu7jG22DosyiHW4un+7uUdUS/ZuFsFjAgFrRhyGWemHVTT9 sw9MRHnfTs1h+gER3RFSv2r9R1vq4ZAfVZvRCc+KH5VPRxXFbDHekue7eZQAdsLkesWX dC9k3Ww72/28ymc7JMc/XQalc6mnDpjpVvfI1jJBh6MrdQd5qN5ypFvODw/7qe+HWA3G mXccTIjseVXnAwsm2jBeRttxTnWNzETu3CUq/jDJWAL/jBD4To9zh4muDRJRHMngXFtS h0XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=FLGQX568wfjz98hLen7c6N4w08HujBrDvMbCuyaevEfnHfZUwX+4zU6Sj5Vhk1cLQb xQO4oC81dXkXlznW7jvjxNTCog7n140hY7tWI7dT/phrMDA3AhIAkzNHpmRhXQmTCRFZ 5iWKh2I3t80+tv5BnBf0Ysy5JKW5LNl08MuUOzo3W2eDKPxIt48HXC4/LOQubDuLVZhZ /3e4I0xkQEATV9iz4Vm40An0o8Pu7SmSYd2D64+kuwvQIizjjL6zoSdlH+va6Hj2PTQT azmbk1v/uyCNNiNpWjIC44eUSOEKxmJnd09tLqrB9UOuBoCJCSyalHbR+SmOqU7gIKeO f1kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mBs4dq/T"; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v13sor12744528pgn.66.2018.12.01.22.17.25 for (Google Transport Security); Sat, 01 Dec 2018 22:17:25 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mBs4dq/T"; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=8CQaNbWYfH4rrtr7y1L1OPdwNgqhGo43ZWeJVCZSPio=; b=mBs4dq/TeqPHUFL3AVrh3JJ/g+dMhVdSUtuuYiWThyelgCPlvamNLncj9Z0m9wretJ dHQvALWfWyfZ+7pRKHCJ8GadHqubftSlzYY9F1kU9Q42HBarg2E2uV5mDeQzLVNSb048 gv8GxLTCIgRIx432n2ija9tH3s8sgqauV6Ulm8WtyP7po08V3uPqb5C6Xs5u3x4KCpZC GAXsbgqClWr3kUjmQtErJtDmoLutvnGAy293IObP4qojbp3bkmwLacBfB9qkW4bQdN86 hJ62U470REpyHVCTaNKFe5GJyUfNQi/0Px/7/+s0OfcUYwyXdeauPqvC1Q2BEUbrPjW7 CDmw== X-Google-Smtp-Source: AFSGD/XskkVCLMV56P5G6hSJkQEj8Bb7420tD78vrgpfyz80/Ofs70Y80gJpaUlH3MXPhcU17HkqjA== X-Received: by 2002:a65:63d3:: with SMTP id n19mr9785026pgv.179.1543731445240; Sat, 01 Dec 2018 22:17:25 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id q1sm12648437pfb.96.2018.12.01.22.17.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:17:24 -0800 (PST) Date: Sun, 2 Dec 2018 11:51:09 +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 v2 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181202062109.GA3111@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 661fe48..4eec323 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1582,31 +1582,24 @@ 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; - if (off >= nr_pages || (usize >> PAGE_SHIFT) > nr_pages - off) + if (off >= nr_pages || page_count > nr_pages - off) 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,