iommu/dma: Add support for non-strict mode
authorZhen Lei <thunder.leizhen@huawei.com>
Thu, 20 Sep 2018 16:10:22 +0000 (17:10 +0100)
committerWill Deacon <will.deacon@arm.com>
Mon, 1 Oct 2018 12:01:32 +0000 (13:01 +0100)
commit2da274cdf998a1c12afa6b5975db2df1df01edf1
tree0edeb8424745e5f3f4a5e42d9df6aadd1c737c83
parent7d321bd3542500caf125249f44dc37cb4e738013
iommu/dma: Add support for non-strict mode

With the flush queue infrastructure already abstracted into IOVA
domains, hooking it up in iommu-dma is pretty simple. Since there is a
degree of dependency on the IOMMU driver knowing what to do to play
along, we key the whole thing off a domain attribute which will be set
on default DMA ops domains to request non-strict invalidation. That way,
drivers can indicate the appropriate support by acknowledging the
attribute, and we can easily fall back to strict invalidation otherwise.

The flush queue callback needs a handle on the iommu_domain which owns
our cookie, so we have to add a pointer back to that, but neatly, that's
also sufficient to indicate whether we're using a flush queue or not,
and thus which way to release IOVAs. The only slight subtlety is
switching __iommu_dma_unmap() from calling iommu_unmap() to explicit
iommu_unmap_fast()/iommu_tlb_sync() so that we can elide the sync
entirely in non-strict mode.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
[rm: convert to domain attribute, tweak comments and commit message]
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/dma-iommu.c
include/linux/iommu.h