From patchwork Thu Nov 15 15:49:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684665 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 BE3BC1747 for ; Thu, 15 Nov 2018 15:46:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD5932C382 for ; Thu, 15 Nov 2018 15:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0F9E2C888; Thu, 15 Nov 2018 15:46: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 78C242C510 for ; Thu, 15 Nov 2018 15:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 770706B049B; Thu, 15 Nov 2018 10:46:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7476C6B049C; Thu, 15 Nov 2018 10:46:18 -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 65F576B049D; Thu, 15 Nov 2018 10:46:18 -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 25C5D6B049B for ; Thu, 15 Nov 2018 10:46:18 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id i22-v6so15345558pfj.1 for ; Thu, 15 Nov 2018 07:46: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=d6oJZE/ChJaKaKxciGARJsnaQLdSQV2i4WCXLXIWfrQ=; b=iwY3tjel+EGg+zOyGuXPiKIgz+JhF1SYJUy4s3AyLvyrKeRWp9N1glMkf87HE4HyCn IYoOvqNAK4OC8qeOxWTuxfTpqRHiu247a0haoSL4PLOXd2Ngg+ho+IYyXK2KAI+rRfiB 6wC4JCMNL5/5IQOO+yIW95H7o9lX25uI45WaOut6BJMZaYsZ3xI/XQrw5Lw1uA1IM+1E 8ODCv+0viUUckIEgQ6DbcECrSyDHgjlHe53qbkxKIPmglFpbbZDVx5et7xX3CBXnGtej eT+VUoeDIK8srFUpQ9/DvvpHNn054M6fQJZVvOcluL7Z5ttvJ0dlI03/kspMvxTYk+BP D5/Q== X-Gm-Message-State: AGRZ1gIP4XA/xkSFHdOn3og3RdDKIQ2288sV1PsXFc3w8+krOXtuR5ss Dj0ZpsPG5/zhb9IqN6P/FPwlX02XVtD6bULayURCxzWC99ISwTpF9WPCbRnZ2lIiBqwiMxCCM9q 4SmhbYK+1lr+hhsapIPxZJcGnXSy3b5QUPqq46Ya6ANEnBT+wQBvtGOzO6U6FyggaZL9/I3q6m9 TuMCyHTV3yqOCqwbIlkbTalh8/mwcsRsj9ivMnu1ojY3YgcyMbM0GWgwQ/ZIxDaOe/jvXna35dC VPLlnHReLJEjSU7fEbrC94MYtqXsKNGpxrSFkqqZnHmtPaPUQKagE/H7AxM7dGoA7PUxtfy5Fr5 TVQCD65fgNaw80x8V+1ff0ZPrrHIxhs2mfd36li4D4W48Oflh4syB940ql1cQoqDnVLIhTGZeXh F X-Received: by 2002:a17:902:4523:: with SMTP id m32-v6mr6373925pld.276.1542296777796; Thu, 15 Nov 2018 07:46:17 -0800 (PST) X-Received: by 2002:a17:902:4523:: with SMTP id m32-v6mr6373878pld.276.1542296776963; Thu, 15 Nov 2018 07:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296776; cv=none; d=google.com; s=arc-20160816; b=xzyL1zFX7+YJdiBfSmjgvnn7US2yyRucEv4xM9I+X/gOCeuvZLsyl0NBSPuZuqf7s7 j5GtQISr/B3snH6nF+Pxrr0JwkPqYNK9tmbdbh9fsOw1R+ug3bfgsk9Dq0StTueDDH7/ jCzsmM4bZh4MSzKM6yMj8viYD4TyiQhUXdjAgtn/6gj07Ouk9TuRM8Onpdq0IoZEl8or ztNXC12iCQXOAFbaXjzr9zxgJWkIBh13iDH/tjXhtvGkXNHQ4WX6I1H7TXx7t1r6i1L2 FiTP6BmI4yWVjv5fgSSXYEKtszH8j++qlubt/nohSQ0Exm5SV9NnuvNQtDHdFd0BjVlx h8qg== 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=d6oJZE/ChJaKaKxciGARJsnaQLdSQV2i4WCXLXIWfrQ=; b=q6LRJYeGmbhG8fsRa5VPc+arnLONqL4IU8VZYDalk71DzXj/uFgrDT3/1HLpOOhXR8 GiQDLIMz1e+6YB8vAC02a8P2UKGEpZbvueyARa8tg2C0VKHuKt+j3DlYF2xocu76yGHi jkkDV/YfF6cT3siC4H7PGtiNVE2P8vthReoJDyuePUjCGdtXRql4n843oGEOxt0xeLdW FfrWMSnKivj50B5apvnWFhsDBIb1cuDOuOU60cqh/X9Ek8Lz4d5GFswXn/bGR2AzvVid dUFaFH4d6odGg7gHo1yewGq9wzEIXvJ2/o0K4SalNXH+Gf9fOkSw8ze2IYYEQ21/7UCR P0VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KDL1jXOi; 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 i128sor27134923pgc.75.2018.11.15.07.46.16 for (Google Transport Security); Thu, 15 Nov 2018 07:46:16 -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=KDL1jXOi; 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=d6oJZE/ChJaKaKxciGARJsnaQLdSQV2i4WCXLXIWfrQ=; b=KDL1jXOipi5AI9hqqrIXJb54kJnJcGHPZq2inivM6wT37owA8faKfCyFnyplVYZnJ2 WcPQLs0t0fomnazLFjvCVMXSXW45w7kASTC0eaHU48sGeSCZda4SHSCs4KipKTwwLWPe 86twXHz84aj/2VhHhjQXF5DLGpALUGDrIDAg798dFy/qS+XgbKCzqsdtUiM5jiSJB9TJ twfempieOEafBe8eLr2HyUh5+PRkuIsAp1eXaRnou8Lnt6zxuZObdya1V+OnOGPFeErR J/rmbflib7zF+roU53lBFqGQ2+A5vh0ko6q+0MkuD6c86cLmAfT2/efpTLbzC1uR2+Gt JzyQ== X-Google-Smtp-Source: AJdET5ePnd6LsBs3MvsWmND5rouZNtcp/4maXAw3ddO5kkpXTes4M9S1/JU9EhJVlMxVKMlrn5+f7g== X-Received: by 2002:a63:4a4d:: with SMTP id j13mr6356647pgl.127.1542296776069; Thu, 15 Nov 2018 07:46:16 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id p5-v6sm29750372pfb.109.2018.11.15.07.46.14 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:46:14 -0800 (PST) Date: Thu, 15 Nov 2018 21:19:50 +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 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181115154950.GA27985@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 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d1b0475..69c66b1 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -622,17 +622,9 @@ 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, count); } static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,