[Intel-gfx] [PATCH v2 07/10] iommu/vt-d: Implement deferred invalidate for SVM
David Woodhouse
dwmw2 at infradead.org
Tue Oct 13 14:35:08 PDT 2015
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/iommu/intel-iommu.c | 2 ++
drivers/iommu/intel-svm.c | 9 +++++++++
include/linux/dma_remapping.h | 1 +
3 files changed, 12 insertions(+)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 4c462ab..787cd6e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4993,6 +4993,8 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd
ctx_lo |= CONTEXT_TT_PT_PASID << 2;
}
ctx_lo |= CONTEXT_PASIDE;
+ if (iommu->pasid_state_table)
+ ctx_lo |= CONTEXT_DINVE;
context[0].lo = ctx_lo;
wmb();
iommu->flush.flush_context(iommu, sdev->did,
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index 82d53e1..a64720b 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -26,6 +26,10 @@ struct pasid_entry {
u64 val;
};
+struct pasid_state_entry {
+ u64 val;
+};
+
int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
{
struct page *pages;
@@ -127,6 +131,11 @@ static void intel_flush_svm_range(struct intel_svm *svm, unsigned long address,
{
struct intel_svm_dev *sdev;
+ /* Try deferred invalidate if available */
+ if (svm->iommu->pasid_state_table &&
+ !cmpxchg64(&svm->iommu->pasid_state_table[svm->pasid].val, 0, 1ULL << 63))
+ return;
+
rcu_read_lock();
list_for_each_entry_rcu(sdev, &svm->devs, list)
intel_flush_svm_range_dev(svm, sdev, address, pages, ih);
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index 0e114bf..187c102 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -25,6 +25,7 @@
#define CONTEXT_TT_PT_PASID_DEV_IOTLB 5
#define CONTEXT_TT_MASK (7ULL << 2)
+#define CONTEXT_DINVE (1ULL << 8)
#define CONTEXT_PRS (1ULL << 9)
#define CONTEXT_PASIDE (1ULL << 11)
--
2.4.3
--
David Woodhouse Open Source Technology Centre
David.Woodhouse at intel.com Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5691 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20151013/940b366b/attachment.bin>
More information about the Intel-gfx
mailing list