diff options
| author | Liam Mark <lmark@codeaurora.org> | 2017-02-24 11:32:17 -0800 |
|---|---|---|
| committer | Liam Mark <lmark@codeaurora.org> | 2017-03-02 09:20:58 -0800 |
| commit | 37a29f1605993040e3f21fa2fb51e14d9de11e65 (patch) | |
| tree | aeb32971bb6502638b64fa77731283b73700b3f5 | |
| parent | 98094e2149dad0658346d504edde8aac9a921500 (diff) | |
arm64: dma-mapping: optimize unmap coherency check
Change arm_iommu_unmap_page to check the DMA attributes for buffer
coherency support instead of checking the iommu page table.
This change now requires that clients correctly set the
DMA_ATTR_FORCE_COHERENT or DMA_ATTR_FORCE_NON_COHERENT DMA
attributes in their unmap call if they used it with their map call.
This will improve the performance of the arm_iommu_unmap_page
call.
Change-Id: Ie96ef0a1906a8732b7b1eef7bed8aa85abee95f4
Signed-off-by: Liam Mark <lmark@codeaurora.org>
| -rw-r--r-- | Documentation/DMA-attributes.txt | 9 | ||||
| -rw-r--r-- | arch/arm64/mm/dma-mapping.c | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/Documentation/DMA-attributes.txt b/Documentation/DMA-attributes.txt index 6eadd564a247..2ad68dbbaaae 100644 --- a/Documentation/DMA-attributes.txt +++ b/Documentation/DMA-attributes.txt @@ -132,6 +132,11 @@ DMA_ATTR_FORCE_COHERENT When passed to a DMA map call the DMA_ATTR_FORCE_COHERENT DMA attribute can be used to force a buffer to be mapped as IO coherent. + +When the DMA_ATTR_FORCE_COHERENT attribute is set during a map call ensure +that it is also set during for the matching unmap call to ensure that the +correct cache maintenance is carried out. + This DMA attribute is only currently supported for arm64 stage 1 IOMMU mappings. @@ -143,5 +148,9 @@ coherent. The DMA_ATTR_FORCE_NON_COHERENT DMA attribute overrides the buffer IO coherency configuration set by making the device IO coherent. +When the DMA_ATTR_FORCE_NON_COHERENT attribute is set during a map call +ensure that it is also set during for the matching unmap call to ensure +that the correct cache maintenance is carried out. + This DMA attribute is only currently supported for arm64 stage 1 IOMMU mappings. diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 45c365290553..2445db9bbd4f 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -1821,10 +1821,8 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle, mapping->domain, iova)); int offset = handle & ~PAGE_MASK; int len = PAGE_ALIGN(size + offset); - bool iova_coherent = iommu_is_iova_coherent(mapping->domain, - handle); - if (!(iova_coherent || + if (!(is_dma_coherent(dev, attrs) || dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))) __dma_page_dev_to_cpu(page, offset, size, dir); |
