From patchwork Sun Dec 2 06:25:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707865 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 65CF41579 for ; Sun, 2 Dec 2018 06:22:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DEB82AE91 for ; Sun, 2 Dec 2018 06:22:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B99C2B4FA; Sun, 2 Dec 2018 06:22:12 +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 8471B2AE91 for ; Sun, 2 Dec 2018 06:22:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B25AE6B61FE; Sun, 2 Dec 2018 01:22:10 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AD3146B61FF; Sun, 2 Dec 2018 01:22:10 -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 99B926B6200; Sun, 2 Dec 2018 01:22:10 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 594F86B61FE for ; Sun, 2 Dec 2018 01:22:10 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id d23so7468107plj.22 for ; Sat, 01 Dec 2018 22:22:10 -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=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=QNpvV4dh1IbRI2o2JXLxQlnUyXLVPlEyUySO6vgmdhTmSSbeCgdpUzO6+IJG49Zpkb inoUlZFEJb79Yhw6wilfOoCfttAxf4OsAxFa3BUU5Pgy/M7ydEleqf3EIb4kyseL3Po0 zaWJYDubpJy/7ls8rClvM8ED7jOe7Xe0uuRFzt1g+JEV6RCgZcpJ6wFNr1AiaoIdZLph jNCXwmGILYYtZtCmPWCQObr6GLUkqCbN5rAJdL9pPYol4802tkWlqOhvME1mx7oDAjyw +nHCsoKKO2g7uoDkJkCn0kBmdXhq6BNFqydfbZrKM65fkT5jWiVkWa4Xxa+zgxBLq/nW p0pg== X-Gm-Message-State: AA+aEWbW0Si/J4weouPz0enBTpznbfMuTiNZk4yiyJKu1GHbfEi2lopE rXQsiVLt71M131aDAhdSIwjPZUAt8m/bYKG6AMVctfnIeGpSbZIvq4gBLmxr7QaQS3ujZyOzBEP aGr13kw41Y9O9/HljhndJxnpmnMHFf/7R+dfyfQMt2MO1aD26DsorVwtK1gimcaRwsGhQxVGuyd 8M5INPOh8nEDUB3o9so72qod+Z3cVz2L6jpGFeprsNfF8h8Tp9B8923LGIH90wadDsKkkQdE4oE mkAK7I7mzOhdxB+lHqb68wqUqpWP8jhMAHkh8jG0Nz/FR3Y+tv2Tj9z+7grKHoiKlWPXfS8Iikk gKemcAQ83sMnemdh31bF9Q6ut9zrLR78VerZy0/t9tCutZxRycZ77+FFaHG+64RRBZ1L/MmLSo5 5 X-Received: by 2002:a17:902:b118:: with SMTP id q24mr11649598plr.209.1543731730032; Sat, 01 Dec 2018 22:22:10 -0800 (PST) X-Received: by 2002:a17:902:b118:: with SMTP id q24mr11649588plr.209.1543731729400; Sat, 01 Dec 2018 22:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731729; cv=none; d=google.com; s=arc-20160816; b=XPYkyoTzU8joLjkmWVwjf3d3C804pgJMt8iRW+nvkDZ8igqqfc+YB376tWhy+WYTxK IP1FkPF18K6dNmavm8AHxIVpluW4YntBToPifwNhSdZfXp3lcg3WfpaqOBJNQAJ8HbdW x4GankHIDQlKOYL3z9qIq9Xbobttl/0B4vt6jpZkCA+EsHYcwMS/dI1R6+xD1sCTTedp uv1+GB2Te+FCTd7ll2m7QRlTiGOeEVzsAYVMjL/Xpz4KJrM9pI4dsQgmSnM98IdySshf Btcxhq1LdeRS38OhNDjLyrFFIIySdc2ZOpXkYf6nbWOY3kuN6t1GwbX0I/BIo/aOBlLS 2XxQ== 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=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=w0+QV+pe3P2tG4D0zgVLmuqRawDdlMnSmzB6g/0KJI+tREnB9Rih7Z4Wj7/JayD+jS 29VGBlxUsKQlxDp3q1ihvnKqp6T0/tm5g+2JdJffaRcb+Ao1YrM50ZTcxoRMqn1icc5T rFJ9QZ02KqDlxeRB8t533ZFMTVJBmjrZBFrcgiTSgnRgonTb+ohOEBbdPItAn816zmOU 9Qb1QQNCbn/+F8t1Xxqmpf11w4kDgNNeK2bW8ofqTqmquOv6+tiWhhZMKGYDzv4Bowwu SKMUXt1ExiGde2NMPGf4jyyCYatQLEkpRycAfGVbqVv5innxao305a0dWGHbaQ+LxLFz v46g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E66PxSJO; 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 f15sor13098130pgh.59.2018.12.01.22.22.09 for (Google Transport Security); Sat, 01 Dec 2018 22:22:09 -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=E66PxSJO; 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=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=E66PxSJOATRlRyxk80lKrd/PPERGyhxxszoqxynYdKqGN1haLtgsOzfQHtEPslbiXw zHl6PkrOjijeS+cspvZr3/fA8QDseQINb50rdwUAuvynH0g6GT4769OS/CfE70NJPBaG nBA+3dbYlNmgu2fEtkS1MVZoHusgbAM5dFPoy5sB/YutBrMjHmJcJefDPs1l5UFK7dS9 jBjnbTK13hVAtILMaN0Pwp045AxBkzPu91quj8BNW9kETTmtvOAplbxqaTZM6hzwBATp dsB91BjVz8U5yyOYWalhuzheuQNNkg2AbUO7ufjZj78Mo3bk32QN+p1Ysv8QnAW2gSBR NpVw== X-Google-Smtp-Source: AFSGD/V4MrGOvLQK8YAEdmVrkPOOILIeEIqHAzxQJv0N2ksWP4eVZ+yeiaMJNltR2QCz0j3pP/BOVQ== X-Received: by 2002:a63:61c8:: with SMTP id v191mr9746466pgb.242.1543731728624; Sat, 01 Dec 2018 22:22:08 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id a9sm9909585pgq.20.2018.12.01.22.22.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:22:07 -0800 (PST) Date: Sun, 2 Dec 2018 11:55:53 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, joro@8bytes.org, robin.murphy@arm.com Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181202062552.GA3203@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 Reviewed-by: Matthew Wilcox --- drivers/iommu/dma-iommu.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d1b0475..a2c65e2 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -622,17 +622,10 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, int iommu_dma_mmap(struct page **pages, size_t size, struct vm_area_struct *vma) { - unsigned long uaddr = vma->vm_start; - unsigned int i, count = PAGE_ALIGN(size) >> PAGE_SHIFT; - int ret = -ENXIO; + unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; - for (i = vma->vm_pgoff; i < count && uaddr < vma->vm_end; i++) { - ret = vm_insert_page(vma, uaddr, pages[i]); - if (ret) - break; - uaddr += PAGE_SIZE; - } - return ret; + return vm_insert_range(vma, vma->vm_start, + pages + vma->vm_pgoff, count); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,