From patchwork Fri Jan 11 15:08:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10758195 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 42674746 for ; Fri, 11 Jan 2019 15:04:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2571281D2 for ; Fri, 11 Jan 2019 15:04:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5E162837D; Fri, 11 Jan 2019 15:04:03 +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 77A1F281D2 for ; Fri, 11 Jan 2019 15:04:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 818058E0003; Fri, 11 Jan 2019 10:04:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7ED778E0001; Fri, 11 Jan 2019 10:04:02 -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 6DC688E0003; Fri, 11 Jan 2019 10:04:02 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 294038E0001 for ; Fri, 11 Jan 2019 10:04:02 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id e89so10473611pfb.17 for ; Fri, 11 Jan 2019 07:04:02 -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=WzAQwD4CMcNjfYojTjRfy8sqfmAAp9apVnphS+7qE5M=; b=nYMbvfHjYLJrnZGWiQfIxptkoOthzVAmIIgYkS7ScaSHYISTpjleHO1uHVkRt2Z8eY XqEp608BULQSethR6U+WsejGzxKrIyw/ArtW+HzMGDtcq3QOBepSx+zqVOtKNRbUFAv6 PID4stU+tkhTqYc/reeYTn2XgsKBJT1Y/08FCeKCsa+F03gi4al0vH1athe9OAEBtc22 KDeu4OMv7m0pbuojATsLpiClUGyuYNJk6Hus2fMfppTwSBMX0I4IR3G2MqrtEQlk8H5l S4uwvj9JwCRKVyBsyOaBYaD7YxOkCgminxo88Rr0PLRcpr9m5BNjw8azaUrxQtEVK8lx oNvQ== X-Gm-Message-State: AJcUukfmBFCh3Bbw/r+ANlZqgOFb/vy0+KPf6Df4hSmGCGChnlCSENzR FKC09XHe9UbYlP9RfQKw17xOTBoGdqxEmG/rt+hS4Ls8YkkPeCx4CbJZM9kEtEE0b6xIHUV3vM9 9j59fsjhSWbr47pLsFgpuI4QC58ZiAcAWmBXqgT4J1aQxjLo5jpf7+7ZcoU3kZ3ukzMIA6V4qTl +xevpf7zmHUWYOviBq7JzdOxZQMa/tH9b32+gCdzouVzf+IuTKaUJB3W/qa5oZIJ4BkMsKvyuYl 6zw34/Q04g3tSwiJOQE8zlyB23z+n9no/m1eIyog23JxQoH6EB4d9RgJOuMwIsfBA1GL5s1QFQK wVJUNd1wkmy8LtywI5oM8VpvS4blKUIE30e6uYkYWDpBmnZfqpWBoLXA0RnswmhjAfHDvdhKQ+E y X-Received: by 2002:a17:902:24a2:: with SMTP id w31mr14723539pla.216.1547219041848; Fri, 11 Jan 2019 07:04:01 -0800 (PST) X-Received: by 2002:a17:902:24a2:: with SMTP id w31mr14723493pla.216.1547219041147; Fri, 11 Jan 2019 07:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547219041; cv=none; d=google.com; s=arc-20160816; b=Kb0CI4ElM3xqcYRuQoJTXtoIScizcXw4y6HBW4LGO6y0dOMlnAl+O7cbZfBmuLwvdN lwUl4v4eyj4qCEK15KSwcU4nvW7UrIRzp9jljzD3zo1Ic1k9XcTKBXpbjTpQAW/KLE20 J4YxaxCBXTvhMMmMXLkhh38AG+UjkdV1l6OyyBaUZU+D2pnEkwAQRbz8keeoDLIHIL3D xecHWJxKGrP7K4E4UcuUW8etcBC7uSHO9HWiJF7rBYaA61HU2vTd36VmOFvQQj6fXLuR Yjrqs8K4Z/L8SzJR1GabkKFqgdGl8KHFRwbE+IIpeFFIZ3ucQ+JNxdWmCv0aTcYfqEou 5C0g== 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=WzAQwD4CMcNjfYojTjRfy8sqfmAAp9apVnphS+7qE5M=; b=L3z/P1NrT1FzUsKDIjz6V/Eq2Qugl4Ee+ToMCachGsT9ru8ey3dghDUfh1Y+igjkfB 8L6ZWNCoCsbHq7rWZ70gwvUohHUFZWGZaWqFsuViDRxgfIjI94LsrFi8UnJMM4XGPwSo kmLRo/4Ql0X65G6e7VF9zMERXV+/DXD+1K/9wlVEqN934sHrjGkxGy1VdpRnC4L9LMqe B/+Qr+nIa63M3KTE4oxA4bBW645MpY8jsTUXZ3wLXk/FwSB6QQuKL51qeaJdLJ84X1v6 YwEDc2nioqAeew2nagL3GHo+ZMlcwAr2gSJJDuJE6cOcyqIwbHV3/1O+FBqKKWrsVvvc YK7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HQ9gfhsp; 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 k20sor3786788pfb.26.2019.01.11.07.04.01 for (Google Transport Security); Fri, 11 Jan 2019 07:04:01 -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=HQ9gfhsp; 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=WzAQwD4CMcNjfYojTjRfy8sqfmAAp9apVnphS+7qE5M=; b=HQ9gfhspvagPH29Me3BRhdtcdpJ1ppAkZvxlrEmPYgRip1IdthcKcOCiWAVY5Z895Z PTA3IoN+JoobjwcMS/8b83st4Y+6eHz3yTWfKmWq6hBWZF2NZmmXzgF2mJsADBChdpWa BlzbeMjQsitVUoC0lUosclfzkAMgMA1uWDH4Q+jXZ0a8BMEvbSD4/3aYiYIx2RYsqrV/ uREttfKnl7dDB92r8GsoONQTcYXgxNyBsHnbW/433SZk5GGTnHZxA7gQrkXu0wYSvHer Vv27TCONFgJ3EJ2dLRQBnpmyzs3Y3diG7h3yFHd0GF6Ho2Vfd1jpkcOJiHFErnXjtg9V WdNw== X-Google-Smtp-Source: ALg8bN4zxdDRP2GvwoCa51Ol8AZWOsPmTHbzznH1GTkRyiMejwb4Tfr2KDpSzH8Z6TaZw/NFHZFS/w== 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-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 | 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,