diff options
| author | Will Deacon <will.deacon@arm.com> | 2013-06-10 14:34:39 -0400 |
|---|---|---|
| committer | Marek Szyprowski <m.szyprowski@samsung.com> | 2013-06-28 09:14:27 -0400 |
| commit | 13987d68bcf476a93fa864ea4e58755f1bc4bd30 (patch) | |
| tree | e13aca0a721c57bd36d3c0b2fb42488feb62aef6 | |
| parent | 836bfa0d2930b7ec236aa488f01678c92eb5f0de (diff) | |
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>
| -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 | |||
| 1637 | { | 1637 | { |
| 1638 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1638 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; |
| 1639 | dma_addr_t dma_addr; | 1639 | dma_addr_t dma_addr; |
| 1640 | int ret, len = PAGE_ALIGN(size + offset); | 1640 | int ret, prot, len = PAGE_ALIGN(size + offset); |
| 1641 | 1641 | ||
| 1642 | dma_addr = __alloc_iova(mapping, len); | 1642 | dma_addr = __alloc_iova(mapping, len); |
| 1643 | if (dma_addr == DMA_ERROR_CODE) | 1643 | if (dma_addr == DMA_ERROR_CODE) |
| 1644 | return dma_addr; | 1644 | return dma_addr; |
| 1645 | 1645 | ||
| 1646 | ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, 0); | 1646 | switch (dir) { |
| 1647 | case DMA_BIDIRECTIONAL: | ||
| 1648 | prot = IOMMU_READ | IOMMU_WRITE; | ||
| 1649 | break; | ||
| 1650 | case DMA_TO_DEVICE: | ||
| 1651 | prot = IOMMU_READ; | ||
| 1652 | break; | ||
| 1653 | case DMA_FROM_DEVICE: | ||
| 1654 | prot = IOMMU_WRITE; | ||
| 1655 | break; | ||
| 1656 | default: | ||
| 1657 | prot = 0; | ||
| 1658 | } | ||
| 1659 | |||
| 1660 | ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); | ||
| 1647 | if (ret < 0) | 1661 | if (ret < 0) |
| 1648 | goto fail; | 1662 | goto fail; |
| 1649 | 1663 | ||
