From patchwork Mon Dec 17 20:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734271 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 3DD431399 for ; Mon, 17 Dec 2018 20:21:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 301F72A28B for ; Mon, 17 Dec 2018 20:21:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23FD72A2DB; Mon, 17 Dec 2018 20:21:00 +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 BAB9F2A28B for ; Mon, 17 Dec 2018 20:20:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 953038E0052; Mon, 17 Dec 2018 15:20:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D9D28E0033; Mon, 17 Dec 2018 15:20:58 -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 77D928E0052; Mon, 17 Dec 2018 15:20:58 -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 2FED88E0033 for ; Mon, 17 Dec 2018 15:20:58 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id 68so12868062pfr.6 for ; Mon, 17 Dec 2018 12:20:58 -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=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=pLK+CYjl7Q6ODP1SrWESJiuBaBkELT5YcmP+Z16Bjhx9XNGPKg9F2KYr4FfVxmCxzP qa6+/W4lVMwzZgpKfxCj775CjmBdxoc46uFqkrHaS2f+p0tWl1AhCOG//1hMfTL4IASG IiOhTD+sckKETHw7yY16xitH7DK8gyGjJ4RPf31tHJ+nFb9yPZNa5z2pZX7V4HU5yI0h dUIim50x+iaWUzgLxZVO/CyrgYXnKvtbi7A7KN3TbJGkICJdKkVpNJ/i+Pq+v9fiP1tu 7Q2UsVTLfL40J0bBJBXQtu5DS+dqQj3fLhA+BrzzPkev4czuS4ozQbjx3gXoeeduPBs4 G/bg== X-Gm-Message-State: AA+aEWY3EXWgcU7I/Q5yg0TaOj8EbsYNkzQJk1d0Xy4QjRt30GXk5yM8 VUzjFz49b+4GczXgWTVO9zehAYttqLcLNbyOQyvbayGb2ikzA8SYoj4EKSDSN+U+YO6/EVcZZcY wwcZj3xS52pZLiLduqHeL143lfLqTkadcfCrQp9BUPISEWIz8bNamMA857h578aSitI+3oyCtQ8 PWBby+r4YOaT6n3GLZ1c8ikyDYEsIrJlgT3NVmtA0Q6xY1hMtocNiRIGaLY3gzbFLeqCcW2BM1Z jHV2i1OFs1fAK5y3uz0Pko8lVeras8d5bUSad48hu909jwXxxbTvda9FJIGpy6o7AN7dNCEvNck 524dcozKKrMZZd4jjyEKWsL0sJoxh2vc2jzEK96Yb15uMjf2qmWJpatgc/YmXIDct3KyiPJrUHh O X-Received: by 2002:a63:b105:: with SMTP id r5mr13383978pgf.442.1545078057886; Mon, 17 Dec 2018 12:20:57 -0800 (PST) X-Received: by 2002:a63:b105:: with SMTP id r5mr13383951pgf.442.1545078057279; Mon, 17 Dec 2018 12:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078057; cv=none; d=google.com; s=arc-20160816; b=e3kBAZinEZ/EStUqgXaazaL84iFtmEUtOeDfShKY28uviJiCOx+gN0S+xJqBsJ+UzC 0a/QO7cu6lLI81Hc5rkTRhW8q5LgUTWahfURET12sqMMqRtddis+/jYALQBrQ5KyKbdK cdD0y05Oqhx6g5evdAtBR9vjTEdFTw9y+MyPcOcFmV0lhl4Rj0xKoi/toDfLLMP61pJU 4I1FCQfaZ5KEJX0YeLceeBS2IsMFtfto+mAk+WR70ISuLjDba12Fukx+/LgEQiJMFdsh LkR4TCRqpPD6g61kimpapbaJhySoZ1iii1PKDS+HhQ3DSXYJhXpmpXvcOl8cXYJrrGV/ WkhA== 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=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=O9aFXaXFdwvqFwI6/TPVL2hZm4gZxTSKlnLvb7gUr7srBQcubGq2w46ngh7Tah4WFR z3+L0YrOGP2AFd4E6gedd3j+sxI9+vW2uvPe2C4z2allR+A7QMfoNMYa00f1AmPsIrKB 2W6vALGPQM+DjWq5+XaKnuqZW0CX8LxSPmCsvN+8uQIojJI6uzsUHaebKwn2mXJ/knJc /4ZeagkmrtYXO5EPWVJR/5Gj+I/GJo3xA5bZAGjDkqT9rUCMtmPkExi8NdUD/3Owc6h4 FttmbM0oEg5XuUk0IPs471V+XMfLJDjWQnyQOhMAUs5d3B3HdFTe/DARIZiXkYpdUo5w UncA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ke/LiHKS"; 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 o19sor20237442pll.44.2018.12.17.12.20.57 for (Google Transport Security); Mon, 17 Dec 2018 12:20:57 -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="Ke/LiHKS"; 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=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=Ke/LiHKSlBGRPCDmViUv3ZjVQC7ToSk3WGpxYAQvNSOoiFY64ZvLfofYbDmlTtMW8N VrhFC+VAqb99DqoAqfPLnVh5Igr3jSmBuSkHuT3Y+FIP9LRFRKFFbZ3g/mOJlHgcn3Ef hoFG+9clCHNChY22xwtjS65BxsUZUurd6TtAJcOxCnZ91scNKXhDUncwGPzurwPgfIUs oVUMPh5ahPSsoR9ZMilGLyGH9/9sGQaG5pSQgYrJsBLTeGALcntN0PhoCdLOhqR0nOpj 2XuHj6tHM8RkjMS5+iNlCqgjWZp3elAOQEJJF7S38QFA5cuAfU49Tmezda2UVJwXTxrx XVdQ== X-Google-Smtp-Source: AFSGD/UAm7C/DlwQy7KNbcTedSMmgshhnQHT7Gj8ZcYhxLhzLnMONLAKeJaEynXEJ23NmOWnQU4npg== X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr13227751plp.19.1545078056566; Mon, 17 Dec 2018 12:20:56 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id z9sm31408044pfd.99.2018.12.17.12.20.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:20:55 -0800 (PST) Date: Tue, 18 Dec 2018 01:54:48 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, joro@8bytes.org Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181217202448.GA14918@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..de7ffd8 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 - vma->vm_pgoff); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,