Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3606911imu; Mon, 24 Dec 2018 05:24:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN4KBD22758FkjGdSZG/U1YlFJqed+XU4FgGZ8nZShWXMxEzQUSsXKqVqpN9EhN5YuQirG+i X-Received: by 2002:a17:902:8ec9:: with SMTP id x9mr13087774plo.27.1545657865704; Mon, 24 Dec 2018 05:24:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545657865; cv=none; d=google.com; s=arc-20160816; b=pfNJYx+PxiNapSj4bOhXvR8z4ag8lnuxd/iOj1eDI8uhRyCrIAQUbAwETgJaHDI8yq jxzwP8yDaJ06YJo9jcnn7HfE59/6HgDB8lQqHa/dQt6mx2epnAetCqK6pggTqsQdEqTV RVDU/nindviZXqJ/C+QQAlu27rg1PrrlgkpTNPF1mUAQ6RyyxIFhuBy+zVqMdWhLaZL5 3HBLnZ01GZNCa5uoMi5A81Tixu7e7k/rK0ktLO1SK3SklHelsgkup3vH407ky1o5NARO c6+JlnPtv03AUqhG5YInUyBRBD2fC7yA6APhjdcsSZJfhjsCo7+EkAPLLavbApD6O2Y+ N1ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=lw4UQu3LauYyUiG1jdETqI6hV1PwymoaIfaZJDM/20IHYtPug+dAJ+HqDkfSXFuZ+j 1VUN5lu2l+IFbgaR2oeDrWZ2P4wP6etxfuov19zNwb58/7ZhA4WH3XmqN/mlrIcedVf3 SChBUpBA72IsQ0M485NDaE8ZcsvCl7EWzioxo6UX7qPXQGp4LPvurfKygP8wiymv6RS3 ar7eYaZlgiyggbCb0RU0A7xZ53YaNzoPNbLn276I2mJqeCZVQXeLJvWyuG4aOcLKSvKu GIazQ0XZPmLnHBJEeuFSMv/OHgw2vcJ9+YFqOvfMOtzYk4v+MuCEfH0F6yWmjbnDehg/ xdQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CEHFTcrB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g25si24706584pgm.14.2018.12.24.05.24.10; Mon, 24 Dec 2018 05:24:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CEHFTcrB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725990AbeLXNVk (ORCPT + 99 others); Mon, 24 Dec 2018 08:21:40 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46618 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbeLXNVj (ORCPT ); Mon, 24 Dec 2018 08:21:39 -0500 Received: by mail-pg1-f193.google.com with SMTP id w7so5576943pgp.13 for ; Mon, 24 Dec 2018 05:21:39 -0800 (PST) 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=CEHFTcrBkyeCWeCmPrwn2688YXOdYONJIrN0FDYedH3wOLlUMBEllDzlhZcd34fVTK PVN/K5qsz/SDWgrxoU447eNOJ+Uwup96nxoNgOgUlQOQ13YmehCBt15uIzwDcL834WB+ 1V2D5GZRCpWh5bWe3K+7fli2aLbfN7muPdbKp+K5klF2OAEPz3Omo3WxJVWH+iE0KYW+ WRM7Y7bB/2Q4e7scf8d2tc9sHWt7qho4T1VtjVba0K8NyB9RvGQ16XNaDLKLohjtuJ7W M/GFEzgPI0wWXk5qZ9aQAs0zJHqCzO/cRE/cf/TYZf3+d4QEtZJUwwgpGUr3zwext/hT 2vgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=hyvE++JUAtEdBgl01+ceVDX4NOixn/zsoYEYg/CvJYk=; b=CHLnHy2iRjUNtNjgi6a/09KNMHnwt9w6oktX7u+yVoB6sR8qhsjZ1W1NNJl9/hm2JG u8QUlQDIOBKMjWZoVXhNwv3J//uVXLU06OHuOiseK3SBuktjdSCSSvPsFqXjFjDOL17B L67pn/mzb6paNDY6430KnEdj9jINzJayVbyFeMl3rXU57YJI1F1OSDacD3Vg32b+qSR9 fsBJuFhPApNbdM5gDCb5pkpGU4U6XInLSfl/hoIm2paf7yndxJALoiMwrp1fpWqHnIFv PTDLC2uNn6dT2A/tdEy0rkf7/ucxrKPU0L/+b8OUZ++wKLRhU8W0cSztunYccND9ooW2 7g8w== X-Gm-Message-State: AJcUukf7th3rdd2Arzy5jZ3ijdOxPhoJ402DAczJ4x+++L0p4ySmIF2Q /8A6ayZuEKofXcDuSxqoSSg4b5h4 X-Received: by 2002:a63:9712:: with SMTP id n18mr12115990pge.295.1545657699357; Mon, 24 Dec 2018 05:21:39 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id x3sm101389647pgt.45.2018.12.24.05.21.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:21:38 -0800 (PST) Date: Mon, 24 Dec 2018 18:55:31 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, joro@8bytes.org, linux@armlinux.org.uk, robin.murphy@arm.com Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v5 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range Message-ID: <20181224132531.GA22150@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 1.9.1