Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp114972imu; Thu, 24 Jan 2019 22:26:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ZE/K6QavKN0b1N917Lx8qznBDPfaCOdZLCMUhLi/CR9bBWzlr7KigchSaF2l+sc1/KUea X-Received: by 2002:a63:1b58:: with SMTP id b24mr8680706pgm.247.1548397611835; Thu, 24 Jan 2019 22:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548397611; cv=none; d=google.com; s=arc-20160816; b=SnYVtlURVR0Nnt5NH/mnqEXG9Fos3UbtRMUkuH50v4j1/TBOziXWT+NqkWtSpu/489 NrHBFmaq3jbV/f1n5VFnk6XFtoaxKrKMP9d6o7sE3kpOM0AYvyE/R+nDbzUtl0tAUnh+ YimiwtjhLNlYpdNqYkA2bzGv2b+7loS9M3jRuXKLqTFy1J6/DW6wQ4nZ1nsxhqAtQrXN gyN2SxRZD7otM2lT/uhyoVVVf6mFwpqjgmCTDlfvQySSRusjOXR78iXIQ7WBRDjyGZ+/ pKZrHjZf+8nq1zsmIbXkgdXUl/UiPQnpZHb19i5AN2blO2pXgwLdEVpPfguvmLfUMNFh hVww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=w9H0PZn0OolgP7kJc7bV76uoKOIASZFoEKdhk7G9bBk=; b=LO7XLKKvKFOTa6p4vE4hqjV6D+E1MwdLrCe0u/a566O1f0ICwC8EnOpLrlsbgdgBby CfB/3FyZmBX0bMpNjedHiYdA3feC/WlmzsuvpxoHAti+0WB6j6MAK8AzC6c0s0W1C5F3 WTz7ItW9nIe7WKyXaw/MpFL3Q10my9nU/8f2jGZ1qk+BQdcn13pXFkNQ28MT2KOBGNQY N80+85MLUm8JrNOCKU+pLY6QnfC9AtHPsqEtC4L1rwNjl2/YieNeDY6D00nu8FRJAmdz U/xUOgVSQnOkryCXPtE1EfIJjWKIKKv8AeGclLFmwCgD7uTOowSHn81RbMiKwwRg/VRn 8SZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ef1pDDYS; 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 l96si24815626plb.292.2019.01.24.22.26.02; Thu, 24 Jan 2019 22:26:51 -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=ef1pDDYS; 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 S1727034AbfAYGY2 (ORCPT + 99 others); Fri, 25 Jan 2019 01:24:28 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:33833 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726021AbfAYGY1 (ORCPT ); Fri, 25 Jan 2019 01:24:27 -0500 Received: by mail-lf1-f66.google.com with SMTP id p6so6150595lfc.1 for ; Thu, 24 Jan 2019 22:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w9H0PZn0OolgP7kJc7bV76uoKOIASZFoEKdhk7G9bBk=; b=ef1pDDYSKyrj1erjXfMRwQ4zhAIgmRtb1F9M5tlxxKSVhLW29fgSSAg0cvRjSAt4eq ISzDFaYnevqUWJ44Fqp1geuq6YHoKJEiTJFxHeE3UGJ/uRMuP61YgOChbdvFwfRx90z0 J8mi/RFim70I55KL0tiFI0q657AfRlZfx/ERMWp7ZUlh6DsUY7sKpCN7nImUaWUFmoUB aM7mPzJd2AEujN1ivrlfZIwEjFW1vo2BOjqaV6IMV/1rX44n4z7w91vWS6NSaAzwEX54 X4WDAk+bXaeuyS6aU58BfbGzRmA/d+cChU0BZQEXqGGuqX6Z1y/q8Zg+tlnvgOExryY1 7yqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w9H0PZn0OolgP7kJc7bV76uoKOIASZFoEKdhk7G9bBk=; b=PhoM8d3RL1RxVJEG77EVRiGr5fhxWNztncG+PoPd28RQweErprm3s4Nz1vmqEaS28C f/9kgjPRHEXVeo3TF0r81TF/+wue5Em449ig5n5jEnOrlZMlDdzno6LK79jPdBm5lBzF ZPT1zpNBQVPenHZCVniUHEgE0O3dDqJmPeFo5VN+9dSyCJv2GXm80R82qMprUWEFiu0h 7ya0HkmtVPVVNIv04AT6qA3OS8Xh5ViiJc3cI8k4mX9tzocMsbRZVZ9Tk/C2RgauZ/pH dQMmwYPnohz7XXqWaYovnR1irLYV/y6Ibbdro6G2EeCE333rmA3aRoQXLsIpHqoQUWPL BixQ== X-Gm-Message-State: AJcUukezSUm3/kikkh+rdSlXYx0PrkGrDmtX1U3YTJTXl/EiVCj3sR9p kvZohe79ooctNhjNb37O9Lp2o9HemBUcElgPVRE= X-Received: by 2002:a19:7111:: with SMTP id m17mr7456686lfc.64.1548397465269; Thu, 24 Jan 2019 22:24:25 -0800 (PST) MIME-Version: 1.0 References: <20190111150801.GA2714@jordon-HP-15-Notebook-PC> In-Reply-To: <20190111150801.GA2714@jordon-HP-15-Notebook-PC> From: Souptick Joarder Date: Fri, 25 Jan 2019 11:54:13 +0530 Message-ID: Subject: Re: [PATCH 2/9] arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range To: Andrew Morton , Matthew Wilcox , Michal Hocko , Russell King - ARM Linux , robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, Kees Cook , Marek Szyprowski Cc: linux-kernel@vger.kernel.org, Linux-MM , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 11, 2019 at 8:33 PM Souptick Joarder wrote: > > Convert to use vm_insert_range() to map range of kernel > memory to user vma. > > Signed-off-by: Souptick Joarder Any comment on this patch ? > --- > arch/arm/mm/dma-mapping.c | 22 ++++++---------------- > 1 file changed, 6 insertions(+), 16 deletions(-) > > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c > index 78de138..5334391 100644 > --- a/arch/arm/mm/dma-mapping.c > +++ b/arch/arm/mm/dma-mapping.c > @@ -1582,31 +1582,21 @@ static int __arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma > void *cpu_addr, dma_addr_t dma_addr, size_t size, > unsigned long attrs) > { > - unsigned long uaddr = vma->vm_start; > - unsigned long usize = vma->vm_end - vma->vm_start; > struct page **pages = __iommu_get_pages(cpu_addr, attrs); > unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; > - unsigned long off = vma->vm_pgoff; > + int err; > > if (!pages) > return -ENXIO; > > - if (off >= nr_pages || (usize >> PAGE_SHIFT) > nr_pages - off) > + if (vma->vm_pgoff >= nr_pages) > return -ENXIO; > > - pages += off; > - > - do { > - int ret = vm_insert_page(vma, uaddr, *pages++); > - if (ret) { > - pr_err("Remapping memory failed: %d\n", ret); > - return ret; > - } > - uaddr += PAGE_SIZE; > - usize -= PAGE_SIZE; > - } while (usize > 0); > + err = vm_insert_range(vma, pages, nr_pages); > + if (err) > + pr_err("Remapping memory failed: %d\n", err); > > - return 0; > + return err; > } > static int arm_iommu_mmap_attrs(struct device *dev, > struct vm_area_struct *vma, void *cpu_addr, > -- > 1.9.1 >