[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <936e5e107c746a7310e3a3c471188ca3ac8f9754.1552921225.git.jrdr.linux@gmail.com>
Date: Tue, 16 Apr 2019 17:19:43 +0530
From: Souptick Joarder <jrdr.linux@...il.com>
To: akpm@...ux-foundation.org, willy@...radead.org, mhocko@...e.com,
kirill.shutemov@...ux.intel.com, vbabka@...e.cz, riel@...riel.com,
sfr@...b.auug.org.au, rppt@...ux.vnet.ibm.com,
peterz@...radead.org, linux@...linux.org.uk, robin.murphy@....com,
iamjoonsoo.kim@....com, treding@...dia.com, keescook@...omium.org,
m.szyprowski@...sung.com, stefanr@...6.in-berlin.de,
hjc@...k-chips.com, heiko@...ech.de, airlied@...ux.ie,
oleksandr_andrushchenko@...m.com, joro@...tes.org,
pawel@...iak.com, kyungmin.park@...sung.com, mchehab@...nel.org,
boris.ostrovsky@...cle.com, jgross@...e.com
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-arm-kernel@...ts.infradead.org,
linux1394-devel@...ts.sourceforge.net,
dri-devel@...ts.freedesktop.org,
linux-rockchip@...ts.infradead.org, xen-devel@...ts.xen.org,
iommu@...ts.linux-foundation.org, linux-media@...r.kernel.org,
Souptick Joarder <jrdr.linux@...il.com>
Subject: [REBASE PATCH v5 2/9] arm: mm: dma-mapping: Convert to use vm_map_pages()
Convert to use vm_map_pages() to map range of kernel
memory to user vma.
Signed-off-by: Souptick Joarder <jrdr.linux@...il.com>
---
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..de7c76e 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_map_pages(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
Powered by blists - more mailing lists