Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5699652imu; Wed, 30 Jan 2019 02:01:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN5AHpmcaHkhBsnou9BbQ0G8wxvL1gnhtUOcmA0+l5ESwUMAAxxjUjUb6FwjF6Z9UppeXpaw X-Received: by 2002:a63:658:: with SMTP id 85mr26812454pgg.373.1548842476840; Wed, 30 Jan 2019 02:01:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548842476; cv=none; d=google.com; s=arc-20160816; b=joY6/Jg1W/UmdBo/OWrTfFfTGinPqGcRfMPdvKUdStkgLsYr8ATue50r76Aih9vSPD gEMtthPK35oLjbm9CVBn6TFnON4rxKhMq0I39QvDEP4jk3lfwiSuzXjKFTOKr0Us9imC AQ3fJ3Jx6xMD/QVXVwTpXCkRG9OtkVxjJAgf2NR4JhMVnJjoiivUSNGi4GBu2k/X2QG5 AVYmQrb2zSPKnvtTw0CCi/Ae9CZacwtACuMr4wrfE0zi1n/DHkkTqpeedNkj6sMzTXgm AMbOIwbPTkNYc6p+GqEnK1SfxYrXVAf5qq3QjvEoC80SB3XU6hnC0xDMWmf9at16vrZ0 HA7g== 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=/ahPDIIFv/MMPOGpeZxT3pmApwBNz3CD4N0VP4gKld8=; b=mGxzz919m6KbjZgWzuVltlaQwZcp55T33WzDpRjEsBKt68syvRosZylc6DluGVEBvJ gyrr4s+bYyqMKSeh2+V/BGug5+OpXTyDVfaTOmXjWqUQmjj5USO/mDpDTx7Y1lpaf8ks pl8kiE/zPhEiP47mG+nSPfL1zdn08l3O0ZKMmaAFPVE/P3rlYaj4xYKW43sqFPw7LTpm a6EeEagQnpNbwtKMMLje1BHVcO6G8imiz92oQJlq+OvOHTFUQ0IeOAbn2xK4LaV0Jk5R HMrXVQsn4euSD+2FwStVp0fzCHb6kBSVFr1Po2MGkQeVip9vYgEpUka6Vu8erHCzkCQ2 sANQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B2ri7Tjm; 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 o9si1134203pfe.63.2019.01.30.02.01.01; Wed, 30 Jan 2019 02:01:16 -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=B2ri7Tjm; 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 S1730657AbfA3KAJ (ORCPT + 99 others); Wed, 30 Jan 2019 05:00:09 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:46869 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726713AbfA3KAI (ORCPT ); Wed, 30 Jan 2019 05:00:08 -0500 Received: by mail-lj1-f196.google.com with SMTP id v15-v6so20115738ljh.13 for ; Wed, 30 Jan 2019 02:00:07 -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=/ahPDIIFv/MMPOGpeZxT3pmApwBNz3CD4N0VP4gKld8=; b=B2ri7TjmimvAXTVQ6NpGSwysKvPv1hRX+3Oh7rms+F5kl5dzWJHrIFOwJuF4qThTKO I04XKp6YookGQQmu5HRlrq8WM8/edqRbmryusF30k9Tmj3RyeHRH1aMeSyc+mATq5BgQ Z40SqAe9+PkppudAohfQEIxSSDOoIhBa1tFqVWxK3HgblGGMvyid0d57zye3T4U5GjiD 3sUbwI3/bkTL+5Nm02NbviKLld0N+TdVirbLuwg+Dmh71heG9+55XVbxGeryWKgXNc5x +lferOF3M5QO8an0Kmgzwnfy9oM1GjM2QE8henvXUlnxEA9X8MLoUvsfFTLfaXycLlZ1 h1Sg== 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=/ahPDIIFv/MMPOGpeZxT3pmApwBNz3CD4N0VP4gKld8=; b=hTgoDly/w3WcofPxoQlpZqIz+qGirpgijJMuEJ7fcC6pd/Stu8C0C8Sc4UF0a2Lq1G xT0z7IYTqk5be5vpIrxjkIXVQv9MFCzQGZWPOKIGxubrTTy/Hpltd6tYRnRvygDWzgeo qhXrsyKkmQ3KLe4vEpDXwdZMY1cPe1jmmlRnXugY5XRyzYJ6EDU0jkraSOKJ5nvcAiGr w5RzfwKElO4kh/Pzr/B+q4CDD78Y0ZWfZ98bfs6aWE6aNbgdLhjHWNx4NcoFusEFPwTB 3/OD6bHLOjDPgI16SPYv5jCFwxVb7W06W0N97RwxYIpgDmlOoY3FGSe9ETSb+8ADvEvk SgtA== X-Gm-Message-State: AJcUukeLVrNhG6bTG9N/E8qPHQ1e0zdMTXix6pyeQ4Fy/0vScYwXNs0A MpIgmRZh+pG95V93ko8osoo1eMNp0PVvp9wSrro= X-Received: by 2002:a2e:8643:: with SMTP id i3-v6mr25670564ljj.43.1548842406798; Wed, 30 Jan 2019 02:00:06 -0800 (PST) MIME-Version: 1.0 References: <20190111150801.GA2714@jordon-HP-15-Notebook-PC> In-Reply-To: From: Souptick Joarder Date: Wed, 30 Jan 2019 15:29:55 +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 25, 2019 at 11:54 AM Souptick Joarder wrote: > > 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 ? 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 > >