[PATCH 5/9] iommu/amd: Implement .flush_np_cache

From: Tom Murphy
Date: Thu Apr 11 2019 - 14:49:13 EST


Implement flush_np_cache for the AMD iommu driver. This allows the amd
iommu non present cache to be flushed if amd_iommu_np_cache is set.

Signed-off-by: Tom Murphy <tmurphy@xxxxxxxxxx>
---
drivers/iommu/amd_iommu.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index b319e51c379b..2d4ee10626b4 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1319,6 +1319,18 @@ static void domain_flush_devices(struct protection_domain *domain)
device_flush_dte(dev_data);
}

+static void amd_iommu_flush_np_cache(struct iommu_domain *domain,
+ unsigned long iova, size_t size)
+{
+ struct protection_domain *dom = to_pdomain(domain);
+
+ if (unlikely(amd_iommu_np_cache)) {
+ domain_flush_pages(dom, iova, size);
+ domain_flush_complete(dom);
+ }
+}
+
+
/****************************************************************************
*
* The functions below are used the create the page table mappings for
@@ -3263,6 +3275,7 @@ const struct iommu_ops amd_iommu_ops = {
.flush_iotlb_all = amd_iommu_flush_iotlb_all,
.iotlb_range_add = amd_iommu_iotlb_range_add,
.iotlb_sync = amd_iommu_flush_iotlb_all,
+ .flush_np_cache = amd_iommu_flush_np_cache,
};

/*****************************************************************************
--
2.17.1