Commit 6248461d authored by Souptick Joarder's avatar Souptick Joarder Committed by Linus Torvalds
Browse files

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: default avatarSouptick Joarder <>
Cc: Boris Ostrovsky <>
Cc: David Airlie <>
Cc: Heiko Stuebner <>
Cc: Joerg Roedel <>
Cc: Joonsoo Kim <>
Cc: Juergen Gross <>
Cc: Kees Cook <>
Cc: "Kirill A. Shutemov" <>
Cc: Kyungmin Park <>
Cc: Marek Szyprowski <>
Cc: Matthew Wilcox <>
Cc: Mauro Carvalho Chehab <>
Cc: Michal Hocko <>
Cc: Mike Rapoport <>
Cc: Oleksandr Andrushchenko <>
Cc: Pawel Osciak <>
Cc: Peter Zijlstra <>
Cc: Rik van Riel <>
Cc: Robin Murphy <>
Cc: Russell King <>
Cc: Sandy Huang <>
Cc: Stefan Richter <>
Cc: Stephen Rothwell <>
Cc: Thierry Reding <>
Cc: Vlastimil Babka <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent a667d745
......@@ -1577,31 +1577,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,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment