forked from MIrrors/gasket-driver
staging: gasket: fix mmap of coherent buffer when IOMMU translation on
Coherent buffer mmap code assumes DMA addresses are physical addresses, which is patently wrong when a downstream IOMMU allocates and translates IOVAs for DMA mappings. Use dma_mmap_coherent(). Bug: 140076240 Bug: 111709861 Change-Id: Ieaa052378844aaf126ea3bc9dba544e7edb37bc7 Signed-off-by: Todd Poynor <toddpoynor@google.com>
This commit is contained in:
committed by
Leonid Lobachev
parent
be43ad6a89
commit
4a701a4c31
@@ -1009,13 +1009,14 @@ static int gasket_mmap_coherent(struct gasket_dev *gasket_dev,
|
||||
}
|
||||
|
||||
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
|
||||
|
||||
ret = remap_pfn_range(vma, vma->vm_start,
|
||||
(gasket_dev->coherent_buffer.phys_base) >>
|
||||
PAGE_SHIFT, requested_length, vma->vm_page_prot);
|
||||
vma->vm_pgoff = 0;
|
||||
ret = dma_mmap_coherent(gasket_dev->dma_dev, vma,
|
||||
gasket_dev->coherent_buffer.virt_base,
|
||||
gasket_dev->coherent_buffer.phys_base,
|
||||
requested_length);
|
||||
if (ret) {
|
||||
dev_err(gasket_dev->dev, "Error remapping PFN range err=%d.\n",
|
||||
ret);
|
||||
dev_err(gasket_dev->dev,
|
||||
"Error mmapping coherent buffer err=%d.\n", ret);
|
||||
trace_gasket_mmap_exit(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user