Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b36b6c1b authored by Liam Mark's avatar Liam Mark Committed by Patrick Daly
Browse files

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: default avatarLiam Mark <lmark@codeaurora.org>
parent 5b15694b
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -182,6 +182,11 @@ DMA_ATTR_FORCE_COHERENT


When passed to a DMA map call the DMA_ATTR_FORCE_COHERENT DMA
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.
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
This DMA attribute is only currently supported for arm64 stage 1 IOMMU
mappings.
mappings.


@@ -193,5 +198,10 @@ attribute can be used to force a buffer to not be mapped as IO
coherent.
coherent.
The DMA_ATTR_FORCE_NON_COHERENT DMA attribute overrides the buffer IO
The DMA_ATTR_FORCE_NON_COHERENT DMA attribute overrides the buffer IO
coherency configuration set by making the device IO coherent.
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
This DMA attribute is only currently supported for arm64 stage 1 IOMMU
mappings.
mappings.
+1 −3
Original line number Original line Diff line number Diff line
@@ -1800,10 +1800,8 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
						mapping->domain, iova));
						mapping->domain, iova));
	int offset = handle & ~PAGE_MASK;
	int offset = handle & ~PAGE_MASK;
	int len = PAGE_ALIGN(size + offset);
	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) ||
	      (attrs & DMA_ATTR_SKIP_CPU_SYNC)))
	      (attrs & DMA_ATTR_SKIP_CPU_SYNC)))
		__dma_page_dev_to_cpu(page, offset, size, dir);
		__dma_page_dev_to_cpu(page, offset, size, dir);