iommu/dma: Fix cache maintenance in iommu_dma_map_sg()
iommu_dma_map_sg() attempts to perform cache maintenance with
iommu_dma_sync_sg_for_device() prior to mapping the scatter gather
list to an IOVA. iommu_dma_sync_sg_for_device() uses the DMA address
in the scatter gather list structure to determine if the buffer is
mapped as cached or uncached by invoking iommu_is_iova_coherent().
Since the buffer has not been mapped yet, the DMA address in the scatter
gather list structure will be 0. If IOVA 0 is not mapped in the client's
IOMMU page tables, then iommu_is_iova_coherent() will return false,
and cache maintenance will be performed on the buffer, even for clients
that are io-coherent, which is not correct, as no cache maintenance is
required for io-coherent clients.
Ensure cache maintenance happens only after the buffer has been mapped,
so that iommu_dma_sync_sg_for_device() can correctly determine if
cache maintenance is required.
Change-Id: Ie1cec69077eaeada00b5a2709b6d1680afdaaeba
Signed-off-by:
Isaac J. Manjarres <isaacm@codeaurora.org>
Loading
Please register or sign in to comment