From patchwork Thu Dec 6 18:43:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10716625 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 974E317DB for ; Thu, 6 Dec 2018 18:40:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 842162F11C for ; Thu, 6 Dec 2018 18:40:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7221C2F129; Thu, 6 Dec 2018 18:40: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 1288A2F11C for ; Thu, 6 Dec 2018 18:40:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44D816B7B61; Thu, 6 Dec 2018 13:39:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3FD4B6B7B64; Thu, 6 Dec 2018 13:39:59 -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 2A1A36B7B66; Thu, 6 Dec 2018 13:39:59 -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 DC36E6B7B61 for ; Thu, 6 Dec 2018 13:39:58 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id u20so1027605pfa.1 for ; Thu, 06 Dec 2018 10:39: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=sjptjlxh1owWZKhohVrkOEeOt6dJ2dnRERAUBGGJRzo=; b=X7KqhAZTHCYzf/A35VbHiadxsqpmi/tUjRwcOyErj2XmS5T/qeZIb0Hg34/WtZF4xs Sh7jjf0qcxKSXAOEw+VMW2bBPh8lDio8XIhccCIWqhcRu/+MZiymGbS8suejEOyikRGh IEIDZxaJha+l/PckIc4CJc7YUKlhxklTJHGK969gd8v5DuyPyUUUfZJeCXy2w7MJIQxt PCPMj/gZQ6/jAEQC7NtgBgRPwCR+AzXDORqeqBciR4RuaakIvCtpVOuPesvFzeXZdJWa YH2wHaBs1I/eNaDbQVRAm+7cb+jYxIEHhIEKLRhYlIp9dWl/KPyggk40DiO59yZ8/CR5 +NbA== X-Gm-Message-State: AA+aEWb8VTwARwyOrD3u0orqUsc4MXa8k/BxeJ0CcaVJHvFV3qrLLCro OSwb8j8a2B9hXvoRvDNeZfsTAC3I72sFPLB/+mMd4++CngYJMh7TgLNo7Dz3p6v2dkhNdZDbLY1 vTsLjVbf4xaLIe3YqJvaf3kUKi7nB/2+71My0cMJd6Hho4zvdWK5kRR9OX9tAoYh1rcwIAb6Smk n0v0Djo5UUKDuquR2wGIVTCrJO/sOHssRhd1h1dc4rdIdhxxd2YEJU/cYVQeD6lXfLUqCZYtr1w JJ0FgnA/PtG33wFI04b6FS+yTBaGxDuUeGOSV+nfIzDreGo/HJHYJQnFzM5y6eKlxQd0MT03pBc A+g3G6vP/b3np/NmLK/0qILIqAxkVqQN5/WVT4rsaC9Ole5it2z5FebmfDNa5X7LrOoXYOKugdJ f X-Received: by 2002:a63:6205:: with SMTP id w5mr24992189pgb.53.1544121598537; Thu, 06 Dec 2018 10:39:58 -0800 (PST) X-Received: by 2002:a63:6205:: with SMTP id w5mr24992130pgb.53.1544121597277; Thu, 06 Dec 2018 10:39:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544121597; cv=none; d=google.com; s=arc-20160816; b=xPudNoH3EfNwgn5JmJjtGe6ovjJeMsxMPB10kklawIUHGKwRLtJR4z5d1MxUCoBBKX ZaG6T8CpVWr/+IRfpLXko0kf8jHXsUW7nYQJvMcELwQSJm26TdrckZyxm1uzpwL0DlSb 00ufhIm+yjIteoyisvVdYSuCM/fMn2K7+9PjNN/K7/oyeASqD9nW02dD/9XIZ5haC+4j BGvsPNWO1avVD8b9xbzFkvCTrKiXVwNm4ZLHnuN4xMa01pOxJX6v2R3hvmbq+aItaLXJ M9z6HG1bZOzjJB1Ocb4Wtr1DTB821mrvGaZWn0LeXri784bR0npG4knAC6y6fy5aeFHq M0pA== 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=cc0fmiTWTyTWfE8rtMcADknkWo+BdxDE0og4JJmUVIcv/+FoTeXKym60JyjcARasDD eYZ/34zNkG/1+Wwt9vAGKe9/qSKfAz3CWu2MgbefpTnyMam/haVSRrAV6K3vgRFRrHyI E+CyPObFV48QpVfndY7ytIf8fmNzUkBtEt/hcQGPqtPYBnc4+bPvIcWn+sEKUvu7i7AO 0I78AgTja1dZvtf9uUadFro6twM79bLl+tjt0A9YiYysn4/auXVtYcuZOVxnad2MvhgB FgKN6sqzFBAAi1n8j5pPfBgK8uqk9xEcYcIOY884RNYluUCp2Rpd9l9GlseTWXrcbJzL oz0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XJVbo1mV; 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 y21sor1842876plp.22.2018.12.06.10.39.57 for (Google Transport Security); Thu, 06 Dec 2018 10:39: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=XJVbo1mV; 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=XJVbo1mVNUPsRUa49x9iPWHWzpgb6rsqCpilpKc5Erku9gr23F/8jGJclplfZqouIu 9W2iKcRBb+uYGakLbYF26F0BYeTb0IZw6x1uOISBC4U34diG7gWmvVXPxYEYd4ehI42R sPavmw6/0rbWcUBjbdDwcAtBRyw67HR9rhg7saq9lfh9GWMOQwbTD8w9JB5e/ynwaCfp /1gI0Vlri11+t5gHus826QWCn4A/XQPpqrjX/cDcakpAVOcdMg53iKxcbyMiF5Sn+nO1 U9r7/tfyqR0qNIOw1/H2SB2ZTMP/8OHu1FrDQjrGvr6bgHN06ozJo7a9GQ81GrHSsQkK Cbow== X-Google-Smtp-Source: AFSGD/VNnI3Z5UaH7h9TyFGXwiDnq2+6sodXbwQm7ri9n8PQRYJ402gtVTtYmhUEYvPgUZVzoKVTsQ== X-Received: by 2002:a17:902:2dc3:: with SMTP id p61mr28602536plb.166.1544121596529; Thu, 06 Dec 2018 10:39:56 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.39]) by smtp.gmail.com with ESMTPSA id 4sm3051359pfq.10.2018.12.06.10.39.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 10:39:55 -0800 (PST) Date: Fri, 7 Dec 2018 00:13:43 +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 v3 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181206184343.GA30569@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,