From patchwork Thu Dec 6 18:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716609 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 79688109C for ; Thu, 6 Dec 2018 18:37:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 694A62EBC6 for ; Thu, 6 Dec 2018 18:37:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DB222F157; Thu, 6 Dec 2018 18:37:20 +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 025AE2F115 for ; Thu, 6 Dec 2018 18:37:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CECF6B7B63; Thu, 6 Dec 2018 13:37:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 057B06B7B64; Thu, 6 Dec 2018 13:37:19 -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 E14206B7B65; Thu, 6 Dec 2018 13:37:18 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 984B16B7B63 for ; Thu, 6 Dec 2018 13:37:18 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id a9so832397pla.2 for ; Thu, 06 Dec 2018 10:37:18 -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=IM5JzKfavvtIsx/OR5jtgCRLbJCDUcOk/095YaK9toCYgP2iHto0eldWKm3BA7Y6Vs jyNmpOqJLqi+ZBG75s4JfpqjtFCeVAmdylvKIC7TmyVw/wOBy3i13opDCZenKwfU/JhJ b8drL2a2GPMquZMRcN3SXCxzM0O3m4h2tNaBQCQnCevy126dxqaZGMxZhg2b6eL7OQ1Y knA2aZlWSPyrBmWOZGXMvXfGF7xT6wUjSb9AeyWBFcVMkMYx4CeeOwR9JiZ6rHCxP28R M/Iv9wryee61+Cq5jy/pTUQurwSjmAK/JdfjkUFXbF9V8uymzZcXDzqR0eBJcemcVZpt 8Bkw== X-Gm-Message-State: AA+aEWZuehof25Rl7n7IGkFs0fiVMNIXoNmOiZgEkjJOdVktKcY4O4nh m8i/dqaZrKCwFnAv0/Iimv9sLoEJDEeR5/ySeb5alUEJBinQcTlpwHQOAdryfMcvpQwb1UjjbUZ +EfsP6WeIL+xefPOJ2OHQ71QN8IVRRkxZngFHsDzE9VRZPqFdwCe13vSCcJRwt7gDXYYUpisk/H 4kOP24X8ciwVCa2344e6Rn21OQ7wsDrRRWB7wPRIuqcZYo3ejGDqJVAfhaAyyYEdTAMgg3k3d4q 7EtPdjinGNugLTEzEvbTzoQBss99tw6SbrdhbqKtn3dxNSY3yzwU+t8v1SHUSSjy2GW1wCe599C IAnZzHf7m0pxqrITdLT2k6VlW1RrTqBnZqVeUK3acVyZMCtuYe2k98jqxOnxp3pMCTO/NxzmVrL Q X-Received: by 2002:a63:d157:: with SMTP id c23mr24819460pgj.170.1544121438274; Thu, 06 Dec 2018 10:37:18 -0800 (PST) X-Received: by 2002:a63:d157:: with SMTP id c23mr24819431pgj.170.1544121437569; Thu, 06 Dec 2018 10:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121437; cv=none; d=google.com; s=arc-20160816; b=lc6XzkMkrIvh/edFG8t0bfbhujiFrrDctBZUeAjkPt20yxLpFVMzudaa5B03+fppNp p2UfALz1rHjyYFc76behH/4eVbZEbAewoN56ifQh/emkk42U+5PBC80jKtrogpxWU0Nb N/o2QSkUtoDp77r3Ng3TlAQFWGtbyXsfck/oj5hkwnuswnnbNnuFXQHr6AOnlFJFQ611 BQrNDUSYlOhwJBQbEcM7i5MJ1FkWw7fDq61BrQKmrZrmPgNQc0J1KbXAn30Py32Qgv+8 TH9M3oRDeIRQLwY8CwwSYZrYGf5wK+jZ2CueAqNOPAE+9r+9GGDEyYIL6aTyTjO90ANz uKJQ== 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=h1+a0QT5HMcZJcl3ONQG4Gxg0dBx15XTbcRSgJeLSr57yauYf4pbbV1WvbnnAcbAIO pa0y9DGVM2uzlQWim+pMAV4bLUeq55elfHctRn8aMAB4zB+Km0L4/8zpm0YO3BZNXapg QgbdcK3p2m69bCksdJL716xfPX3YTDwnu89uSe9syq8IqbhWhgHQ6EiscC6TN5AWOF+F D4f+GEy4KbDLZDWSwmk49vNZYyY7j/Rz2oPYDs4ja0rxtIDfartHEc46Gqn2USMAuxt3 IahFAb6N6A4vS83cDwyNyX0Cs3I+SP/lIAco+mJvPPDpq7+EHdoOkymDwIsxxbwCiv0o XCOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="jQdYEmv/"; 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 u6sor1948588pgu.43.2018.12.06.10.37.17 for (Google Transport Security); Thu, 06 Dec 2018 10:37:17 -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="jQdYEmv/"; 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=jQdYEmv/c31kkxNf63DO2hDppf2yyeLJmKw6Ll2SJ/lUFEj87Ru6+xfE3lKIfctczi 8ZbadMqzX3u4nD/kPuuo5FTDsAsBFI8Ica4ERuDuRDBeSZYaRW+qebFFg1LWFvnsI++k MP6iVmmy3D44dFT9yBmdq4IPLjCpp/2yOZUh93d29NzVG2QDnxm4vPTpZo0UYpNJWOgm cuJ4s1duczRJmygZdRUaSnFePvExxPYFUdNMrtwXEle4l04GSONHvunsQ2k+atUkoSOP OUpXiJJsaBLM4RVh52ZhX9s5lYy25JjRE8z2bZKooZryBibA6lnE5g5v8EhgIFTtZHBP ShLw== X-Google-Smtp-Source: AFSGD/X8vL0xWSmYdOfWCYDwSxgcM4w7QeNvIJM2oEJ88aXzCt2cszDLSX+lbehOI7LOGmWx4fpNaA== X-Received: by 2002:a63:68c4:: with SMTP id d187mr24796460pgc.11.1544121437220; Thu, 06 Dec 2018 10:37:17 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id n66sm1517646pfk.19.2018.12.06.10.37.15 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:37:16 -0800 (PST) Date: Fri, 7 Dec 2018 00:11:03 +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 v3 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range Message-ID: <20181206184103.GA25872@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,