Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2657053ima; Sun, 3 Feb 2019 04:19:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IbNXdyYfV88KZ/CbS0ao1TH9OFL1S0Hf+YTUGcaoSU08ssegvm1Hzn9euJF7lGuB9iT2WMh X-Received: by 2002:a63:2643:: with SMTP id m64mr9169079pgm.35.1549196365099; Sun, 03 Feb 2019 04:19:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549196365; cv=none; d=google.com; s=arc-20160816; b=ZA+3dJKTYwsUFzPYf3/EKrH79UnPouvqFGYzzibxvp2GINWjmkHCrjDQivJdtb4v5x yog70yZjhyAmYy4XEShrGssvJLmAjZkVZR8LlHYGoZLDugatUmOAfhrjvzMQQivh2j3H 0JUihHYkFdz+T6whO5WHbx1T3pN4QwjgrJ4ZOLLCaQSW2eiGqFWA37Fn3YspzNy98EXn vdg1QNIapXxCfWTLdEJi+IAbQKgboLXTK8oT5Q6043PUXAkMcQcZEFQmwSjODItfc+22 PKw7psNlj9HzrjudhAWkjwu650NvfdgRb3B6DJwknrZjtGbvFct2//h1tkoy4uhVjvvR NzLw== 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=bsr2lcuUZ78duCduOrjEIhzTac5FkzmhdngvDyze87g=; b=IjS+1gop2n8KhEup4v9U42K+mH9n5wXApLBQX3iCgI8CLjxc7QN2GrUolrTDDSz7Pa pEprGtuy6ceoI7E9WnpbOfb2h2n33RjibMjcwwaU9iKS1+KFFbfZPKsx1PpFaE2GDfqi 3QG+dym0BAzALVMwZZ41I0IIKeCCoGQ/azfSO+SC/czkTeVP+bpz8qaFxu/yXzOu9tNV 06vurruqrpvWIsaK4gZ4Py3wJGAYIyTJ3y9hAr9fxUrb6e+geHIw1iFscqYQNz7b0A+k nfMLI3sDh5N0uxBuFXZcm+un/Re447vBeRi7V4WvNm5TPdD3aqFJvBOlCYfvFlc17zrS n7LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DEFZB7m2; 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 a11si2253418pla.20.2019.02.03.04.19.09; Sun, 03 Feb 2019 04:19: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=DEFZB7m2; 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 S1727755AbfBCMQN (ORCPT + 99 others); Sun, 3 Feb 2019 07:16:13 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:38726 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbfBCMQN (ORCPT ); Sun, 3 Feb 2019 07:16:13 -0500 Received: by mail-lf1-f66.google.com with SMTP id j15so1454576lfh.5 for ; Sun, 03 Feb 2019 04:16:11 -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=bsr2lcuUZ78duCduOrjEIhzTac5FkzmhdngvDyze87g=; b=DEFZB7m2x3lEjsSr4Vebj+gVVt7RLH0LzvwCLxLo87w5byYcx/eb6nkp/k5rPLuF39 mmpb1Mq5bkecyhhJJlhVeKWccLyDB6pbFTcG0XIJojHQ1bHDN6mtm+KoI8VXXSqh4yl8 ipfUr4T2tWkt0zjGXzc9GQDjaIzV49m5XBPq5fafnpOPUlJkiK438F1eBMpOp9WOD031 rS4TLTf9kl1YBlwKdOL4uPVoF0bqQVtg2TbM4tLaPL2XM6xJkhQmwMfCYyZNuUDWKGnu yXDuK0R70C2y4wvmF0CXFDycc+8qwbZhCbA6fzZGslHQA2fZUVEj6ZEW4WTc5BAZ/kpz u8UQ== 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=bsr2lcuUZ78duCduOrjEIhzTac5FkzmhdngvDyze87g=; b=HaI4ueDvMJCShQO86N6iHYjjcTiutpEv0rF9cEAg6AzO7IulHjj0iLUwYncL3/qUr/ 8HGZHICD24UF1c71mVFjC1rIaxnVr+MXhWEzfENz6Oh8peZIOB466Xkwrurd4ef6y5tP 9+GLrdS/MYFklo+bxYBcbxq3PcikarOC61RNPGr4+A+gpFTvj6C1R8xbtvwgsI5UaPhz 8iXPQ9Uu7oA1dDIGKqfWKa74c+mDNN7Mx0IgBagNUnsqaBL9a+XlUDr6q1/ntMnyx/VY JHRTIcsNBn4a+XNp7Ks+7mvyCoSzoC0zHpVgDk+gjtTJn9V0600E2MbiezGZ0fiWLRKR AeNA== X-Gm-Message-State: AHQUAuY3pSt+JH2ytzVxiLc6dflDidFOiroz7oyGWfqqkUtJtilwll62 QXTlmJvg+PWfdmH+yxsRpEYYvSezuTWgaS1Wd1E= X-Received: by 2002:a19:5004:: with SMTP id e4mr3804044lfb.75.1549196171078; Sun, 03 Feb 2019 04:16:11 -0800 (PST) MIME-Version: 1.0 References: <20190131030900.GA2284@jordon-HP-15-Notebook-PC> In-Reply-To: <20190131030900.GA2284@jordon-HP-15-Notebook-PC> From: Souptick Joarder Date: Sun, 3 Feb 2019 17:46:02 +0530 Message-ID: Subject: Re: [PATCHv2 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 Hi Russell, On Thu, Jan 31, 2019 at 8:34 AM Souptick Joarder wrote: > > Convert to use vm_insert_range() to map range of kernel > memory to user vma. > > Signed-off-by: Souptick Joarder Does it looks good ? > --- > 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 f1e2922..915f701 100644 > --- a/arch/arm/mm/dma-mapping.c > +++ b/arch/arm/mm/dma-mapping.c > @@ -1575,31 +1575,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 >