Skip to content

Commit

Permalink
arm64: dma-mapping: Fix IOMMU breakage
Browse files Browse the repository at this point in the history
My forward-port of the arm64 pcie bounce buffer support broke builds
with IOMMU support enabled.

Fixes: 53f58fe ("Ported pcie-brcmstb bounce buffer implementation to ARM64. (#3144)")

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
  • Loading branch information
Phil Elwell committed Sep 16, 2019
1 parent ddd11a7 commit 45bfd96
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions arch/arm64/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,37 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
__dma_unmap_area(phys_to_virt(paddr), size, dir);
}

#ifdef CONFIG_IOMMU_DMA
static int __swiotlb_get_sgtable_page(struct sg_table *sgt,
struct page *page, size_t size)
{
int ret = sg_alloc_table(sgt, 1, GFP_KERNEL);

if (!ret)
sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);

return ret;
}

static int __swiotlb_mmap_pfn(struct vm_area_struct *vma,
unsigned long pfn, size_t size)
{
int ret = -ENXIO;
unsigned long nr_vma_pages = vma_pages(vma);
unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
unsigned long off = vma->vm_pgoff;

if (off < nr_pages && nr_vma_pages <= (nr_pages - off)) {
ret = remap_pfn_range(vma, vma->vm_start,
pfn + off,
vma->vm_end - vma->vm_start,
vma->vm_page_prot);
}

return ret;
}
#endif /* CONFIG_IOMMU_DMA */

static int __init atomic_pool_init(void)
{
pgprot_t prot = __pgprot(PROT_NORMAL_NC);
Expand Down

0 comments on commit 45bfd96

Please sign in to comment.