diff options
author | Will Deacon | 2013-06-10 20:34:39 +0200 |
---|---|---|
committer | Marek Szyprowski | 2013-06-28 15:14:27 +0200 |
commit | 13987d68bcf476a93fa864ea4e58755f1bc4bd30 (patch) | |
tree | e13aca0a721c57bd36d3c0b2fb42488feb62aef6 /arch/arm/mm/dma-mapping.c | |
parent | ARM: dma-mapping: Get pages if the cpu_addr is out of atomic_pool (diff) | |
download | kernel-qcow2-linux-13987d68bcf476a93fa864ea4e58755f1bc4bd30.tar.gz kernel-qcow2-linux-13987d68bcf476a93fa864ea4e58755f1bc4bd30.tar.xz kernel-qcow2-linux-13987d68bcf476a93fa864ea4e58755f1bc4bd30.zip |
ARM: dma-mapping: convert DMA direction into IOMMU protection attributes
IOMMU mappings take a prot parameter, identifying the protection bits
to enforce on the newly created mapping (READ or WRITE). The ARM
dma-mapping framework currently just passes 0 as the prot argument,
resulting in faulting mappings.
This patch infers the protection attributes based on the direction of
the DMA transfer.
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'arch/arm/mm/dma-mapping.c')
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 1d158c223ebb..282aacd6f570 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1637,13 +1637,27 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p { struct dma_iommu_mapping *mapping = dev->archdata.mapping; dma_addr_t dma_addr; - int ret, len = PAGE_ALIGN(size + offset); + int ret, prot, len = PAGE_ALIGN(size + offset); dma_addr = __alloc_iova(mapping, len); if (dma_addr == DMA_ERROR_CODE) return dma_addr; - ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, 0); + switch (dir) { + case DMA_BIDIRECTIONAL: + prot = IOMMU_READ | IOMMU_WRITE; + break; + case DMA_TO_DEVICE: + prot = IOMMU_READ; + break; + case DMA_FROM_DEVICE: + prot = IOMMU_WRITE; + break; + default: + prot = 0; + } + + ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); if (ret < 0) goto fail; |