Intel IOMMU updates for Linux v6.1
Subsystems (2)
Lu Baolu
maintainerHi Joerg,
This includes patches queued for v6.1. It includes:
- Decouple PASID and PRI from SVA
- Add ESRTPS & ESIRTPS capability check
- Cleanups
The whole series is also available at:
https://github.com/LuBaolu/intel-iommu/commits/vtd-update-for-v6.1
Please consider them for next.
Best regards,
Baolu
Lu Baolu (5):
iommu/vt-d: Remove unnecessary SVA data accesses in page fault path iommu/vt-d: Decouple PASID & PRI enabling from SVA iommu/vt-d: Remove pasid_set_eafe()
iommu/vt-d: Avoid unnecessary global IRTE cache invalidation iommu/vt-d: Avoid unnecessary global DMA cache invalidation
Yi Liu (1):
iommu/vt-d: Rename cap_5lp_support to cap_fl5lp_support
drivers/iommu/intel/iommu.h | 7 ++- drivers/iommu/intel/cap_audit.c | 4 +- drivers/iommu/intel/iommu.c | 87 ++++++++--------------------- drivers/iommu/intel/irq_remapping.c | 6 +- drivers/iommu/intel/pasid.c | 12 +--- drivers/iommu/intel/svm.c | 62 +++----------------- drivers/iommu/intel/Kconfig | 5 +- 7 files changed, 45 insertions(+), 138 deletions(-)
Signature · 1 line
2.34.1
Lu Baolu
maintainerPATCH 1/6 iommu/vt-d: Remove unnecessary SVA data accesses in page fault path
The existing I/O page fault handling code accesses the per-PASID SVA data structures. This is unnecessary and makes the fault handling code only suitable for SVA scenarios. This removes the SVA data accesses from the I/O page fault reporting and responding code, so that the fault handling code could be generic.
--- drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/intel/svm.c | 60 +++++-------------------------------- 2 files changed, 8 insertions(+), 54 deletions(-)
drivers/iommu/intel/iommu.h +1 -1
@@ -586,6 +586,7 @@ struct intel_iommu {#ifdef CONFIG_INTEL_IOMMU_SVM struct page_req_dsc *prq;unsigned char prq_name[16 ];/* Name for PRQ interrupt */ +unsigned long prq_seq_number;struct completion prq_complete;struct ioasid_allocator_ops pasid_allocator;/* Custom allocator for PASIDs */ #endif
@@ -761,7 +762,6 @@ struct intel_svm_dev {struct device *dev;struct intel_iommu *iommu;struct iommu_sva sva; -unsigned long prq_seq_number;u32 pasid;int users;u16 did;
drivers/iommu/intel/svm.c +7 -53
117 lines not on this page · raw message
Signature · 1 line
2.34.1
Lu Baolu
maintainerPATCH 2/6 iommu/vt-d: Decouple PASID & PRI enabling from SVA
In reply to Lu BaoluPreviously the PCI PASID and PRI capabilities are enabled in the path of iommu device probe only if INTEL_IOMMU_SVM is configured and the device supports ATS. As we've already decoupled the I/O page fault handler from SVA, we could also decouple PASID and PRI enabling from it to make room for growth of new features like kernel DMA with PASID, SIOV and nested translation.
At the same time, the iommu_enable_dev_iotlb() helper is also called in iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA) path. It's unnecessary and duplicate. This cleanups this helper to make the code neat.
--- drivers/iommu/intel/iommu.h | 1 - drivers/iommu/intel/iommu.c | 78 ++++++++----------------------------- drivers/iommu/intel/Kconfig | 5 +-- 3 files changed, 18 insertions(+), 66 deletions(-)
drivers/iommu/intel/iommu.h +0 -1
@@ -742,7 +742,6 @@ extern int dmar_ir_support(void);void *alloc_pgtable_page (int node);void free_pgtable_page (void *vaddr);void iommu_flush_write_buffer (struct intel_iommu *iommu); -int intel_iommu_enable_pasid (struct intel_iommu *iommu,struct device *dev);struct intel_iommu *device_to_iommu (struct device *dev,u8 *bus,u8 *devfn);#ifdef CONFIG_INTEL_IOMMU_SVM
drivers/iommu/intel/iommu.c +16 -62
161 lines not on this page · raw message
drivers/iommu/intel/Kconfig +2 -3
@@ -20,6 +20,8 @@ config INTEL_IOMMU select SWIOTLB select IOASID select PCI_ATS + select PCI_PRI + select PCI_PASID help DMA remapping (DMAR) devices support enables independent address translations for Direct Memory Access (DMA) from devices.
@@ -47,10 +49,7 @@ config INTEL_IOMMU_DEBUGFS config INTEL_IOMMU_SVM bool "Support for Shared Virtual Memory with Intel IOMMU" depends on X86_64 - select PCI_PASID - select PCI_PRI select MMU_NOTIFIER - select IOASID select IOMMU_SVA help Shared Virtual Memory (SVM) provides a facility for devices
Signature · 1 line
2.34.1
Lu Baolu
maintainerPATCH 3/6 iommu/vt-d: Remove pasid_set_eafe()
In reply to Lu BaoluIt is not used anywhere in the tree. Remove it to avoid dead code. No functional change intended.
--- drivers/iommu/intel/pasid.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/iommu/intel/pasid.c +0 -10
@@ -392,16 +392,6 @@ pasid_set_flpm(struct pasid_entry *pe, u64 value)pasid_set_bits (&pe->val[2 ],GENMASK_ULL (3 ,2 ), value <<2 ); } -/* -* Setup the Extended Access Flag Enable (EAFE) field (Bit 135) -* of a scalable mode PASID entry. -*/ -static inline void -pasid_set_eafe (struct pasid_entry *pe) -{ -pasid_set_bits (&pe->val[2 ],1 <<7 ,1 <<7 ); -} -static void pasid_cache_invalidation_with_pasid (struct intel_iommu *iommu,u16 did,u32 pasid)
Signature · 1 line
2.34.1
Lu Baolu
maintainerPATCH 4/6 iommu/vt-d: Rename cap_5lp_support to cap_fl5lp_support
In reply to Lu BaoluFrom: Yi Liu <[email protected]>
This renaming better describes it is for first level page table (a.k.a first stage page table since VT-d spec 3.4).
--- drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/intel/cap_audit.c | 4 ++-- drivers/iommu/intel/iommu.c | 2 +- drivers/iommu/intel/pasid.c | 2 +- drivers/iommu/intel/svm.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)
drivers/iommu/intel/iommu.h +1 -1
@@ -146,7 +146,7 @@/* * Decoding Capability Register */ -#define cap_5lp_support (c) (((c) >> 60) & 1) +#define cap_fl5lp_support (c) (((c) >> 60) & 1)#define cap_pi_support (c) (((c) >> 59) & 1)#define cap_fl1gp_support (c) (((c) >> 56) & 1)#define cap_read_drain (c) (((c) >> 55) & 1)
drivers/iommu/intel/cap_audit.c +2 -2
@@ -37,7 +37,7 @@ static inline void check_dmar_capabilities(struct intel_iommu *a,MINIMAL_FEATURE_IOMMU (b, ecap,ECAP_MHMV_MASK );MINIMAL_FEATURE_IOMMU (b, ecap,ECAP_IRO_MASK ); - CHECK_FEATURE_MISMATCH(a, b, cap, 5lp_support, CAP_FL5LP_MASK); +CHECK_FEATURE_MISMATCH (a, b, cap, fl5lp_support,CAP_FL5LP_MASK );CHECK_FEATURE_MISMATCH (a, b, cap, fl1gp_support,CAP_FL1GP_MASK );CHECK_FEATURE_MISMATCH (a, b, cap, read_drain,CAP_RD_MASK );CHECK_FEATURE_MISMATCH (a, b, cap, write_drain,CAP_WD_MASK );
@@ -84,7 +84,7 @@ static int cap_audit_hotplug(struct intel_iommu *iommu, enum cap_audit_type type goto out; } - CHECK_FEATURE_MISMATCH_HOTPLUG(iommu, cap, 5lp_support, CAP_FL5LP_MASK); +CHECK_FEATURE_MISMATCH_HOTPLUG (iommu, cap, fl5lp_support,CAP_FL5LP_MASK );CHECK_FEATURE_MISMATCH_HOTPLUG (iommu, cap, fl1gp_support,CAP_FL1GP_MASK );CHECK_FEATURE_MISMATCH_HOTPLUG (iommu, cap, read_drain,CAP_RD_MASK );CHECK_FEATURE_MISMATCH_HOTPLUG (iommu, cap, write_drain,CAP_WD_MASK );
drivers/iommu/intel/iommu.c +1 -1
@@ -404,7 +404,7 @@ static unsigned long __iommu_calculate_sagaw(struct intel_iommu *iommu) {unsigned long fl_sagaw, sl_sagaw; - fl_sagaw =BIT (2 ) | (cap_5lp_support (iommu->cap) ?BIT (3 ) :0 ); + fl_sagaw =BIT (2 ) | (cap_fl5lp_support (iommu->cap) ?BIT (3 ) :0 ); sl_sagaw =cap_sagaw (iommu->cap);/* Second level only. */
drivers/iommu/intel/pasid.c +1 -1
@@ -519,7 +519,7 @@ int intel_pasid_setup_first_level(struct intel_iommu *iommu, } } -if ((flags &PASID_FLAG_FL5LP ) && !cap_5lp_support (iommu->cap)) { +if ((flags &PASID_FLAG_FL5LP ) && !cap_fl5lp_support (iommu->cap)) {pr_err ("No 5-level paging support for first-level on %s\n" , iommu->name);return -EINVAL ;
drivers/iommu/intel/svm.c +1 -1
@@ -164,7 +164,7 @@ void intel_svm_check(struct intel_iommu *iommu) }if (cpu_feature_enabled (X86_FEATURE_LA57 ) && - !cap_5lp_support (iommu->cap)) { + !cap_fl5lp_support (iommu->cap)) {pr_err ("%s SVM disabled, incompatible paging mode\n" , iommu->name);return ;
Signature · 1 line
2.34.1
Lu Baolu
maintainerPATCH 5/6 iommu/vt-d: Avoid unnecessary global IRTE cache invalidation
In reply to Lu BaoluSome VT-d hardware implementations invalidate all interrupt remapping hardware translation caches as part of SIRTP flow. The VT-d spec adds a ESIRTPS (Enhanced Set Interrupt Remap Table Pointer Support, section 11.4.2 in VT-d spec) capability bit to indicate this.
The spec also states in 11.4.4 that hardware also performs global invalidation on all interrupt remapping caches as part of Interrupt Remapping Disable operation if ESIRTPS capability bit is set.
This checks the ESIRTPS capability bit and skip software global cache invalidation if it's set.
--- drivers/iommu/intel/iommu.h | 1 + drivers/iommu/intel/irq_remapping.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/intel/iommu.h +1 -0
@@ -146,6 +146,7 @@/* * Decoding Capability Register */ +#define cap_esirtps (c) (((c) >> 62) & 1)#define cap_fl5lp_support (c) (((c) >> 60) & 1)#define cap_pi_support (c) (((c) >> 59) & 1)#define cap_fl1gp_support (c) (((c) >> 56) & 1)
drivers/iommu/intel/irq_remapping.c +4 -2
@@ -494,7 +494,8 @@ static void iommu_set_irq_remapping(struct intel_iommu *iommu, int mode)* Global invalidation of interrupt entry cache to make sure the * hardware uses the new irq remapping table. */ -qi_global_iec (iommu); +if (!cap_esirtps (iommu->cap)) +qi_global_iec (iommu); }static void iommu_enable_irq_remapping (struct intel_iommu *iommu)
@@ -680,7 +681,8 @@ static void iommu_disable_irq_remapping(struct intel_iommu *iommu)* global invalidation of interrupt entry cache before disabling * interrupt-remapping. */ -qi_global_iec (iommu); +if (!cap_esirtps (iommu->cap)) +qi_global_iec (iommu);raw_spin_lock_irqsave (&iommu->register_lock, flags);
Signature · 1 line
2.34.1
Lu Baolu
maintainerPATCH 6/6 iommu/vt-d: Avoid unnecessary global DMA cache invalidation
In reply to Lu BaoluSome VT-d hardware implementations invalidate all DMA remapping hardware translation caches as part of SRTP flow. The VT-d spec adds a ESRTPS (Enhanced Set Root Table Pointer Support, section 11.4.2 in VT-d spec) capability bit to indicate this. With this bit set, software has no need to issue the global invalidation request.
--- drivers/iommu/intel/iommu.h | 1 + drivers/iommu/intel/iommu.c | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/iommu/intel/iommu.h +1 -0
@@ -146,6 +146,7 @@/* * Decoding Capability Register */ +#define cap_esrtps (c) (((c) >> 63) & 1)#define cap_esirtps (c) (((c) >> 62) & 1)#define cap_fl5lp_support (c) (((c) >> 60) & 1)#define cap_pi_support (c) (((c) >> 59) & 1)
drivers/iommu/intel/iommu.c +7 -0
@@ -1239,6 +1239,13 @@ static void iommu_set_root_entry(struct intel_iommu *iommu)raw_spin_unlock_irqrestore (&iommu->register_lock, flag); +/* +* Hardware invalidates all DMA remapping hardware translation +* caches as part of SRTP flow. +*/ +if (cap_esrtps (iommu->cap)) +return ; + iommu->flush.flush_context (iommu,0 ,0 ,0 ,DMA_CCMD_GLOBAL_INVL );if (sm_supported (iommu))qi_flush_pasid_cache (iommu,0 ,QI_PC_GLOBAL ,0 );
Signature · 1 line
2.34.1
Joerg Roedel
maintainerHi Baolu,
Quoted 9 lines · Lu Baolu
Lu Baolu (5):
iommu/vt-d: Remove unnecessary SVA data accesses in page fault path iommu/vt-d: Decouple PASID & PRI enabling from SVA iommu/vt-d: Removepasid_set_eafe()
iommu/vt-d: Avoid unnecessary global IRTE cache invalidation iommu/vt-d: Avoid unnecessary global DMA cache invalidationYi Liu (1):
iommu/vt-d: Renamecap_5lp_supporttocap_fl5lp_support
These don't apply cleanly on v6.0-rc4 or -rc7. Please rebase these patches to my x86/vt-d branch and re-send.
Thanks,
Joerg
Baolu Lu
maintainerHi Joerg,
Quoted 10 lines · Joerg Roedel
Hi Baolu,
Quoted 7 lines · Lu Baolu
Lu Baolu (5):
iommu/vt-d: Remove unnecessary SVA data accesses in page fault path iommu/vt-d: Decouple PASID & PRI enabling from SVA iommu/vt-d: Removepasid_set_eafe()
iommu/vt-d: Avoid unnecessary global IRTE cache invalidation iommu/vt-d: Avoid unnecessary global DMA cache invalidation
Quoted 5 lines
Quoted 2 lines
Yi Liu (1):
iommu/vt-d: Renamecap_5lp_supporttocap_fl5lp_supportThese don't apply cleanly on v6.0-rc4 or -rc7. Please rebase these patches to my x86/vt-d branch and re-send.
This pull request is based on the next branch. There's a conflict between
de9f8a91eb32 iommu/dma: Clean up Kconfig (core branch)
and
iommu/vt-d: Decouple PASID & PRI enabling from SVA (this series).
Do you prefer applying de9f8a91eb32 to vt-d branch, or let me send a new v6.0-rc7 based pull request?
Best regards,
baolu
Joerg Roedel
maintainerQuoted 2 lines · Baolu Lu
Do you prefer applying
de9f8a91eb32to vt-d branch, or let me send a new v6.0-rc7 based pull request?
Yes, please send a v6.0-rc7 pull-request. I'd like to carry the conflict resolution in the merge commit for next.
Regards,
Joerg
Baolu Lu
maintainerQuoted 5 lines · Joerg Roedel
Quoted 2 lines · Baolu Lu
Do you prefer applying
de9f8a91eb32to vt-d branch, or let me send a new v6.0-rc7 based pull request?Yes, please send a v6.0-rc7 pull-request. I'd like to carry the conflict resolution in the merge commit for next.
Sure. A new pull request has been posted:
https://lore.kernel.org/linux-iommu/[email protected]/
Best regards,
baolu