iommu/vt-d: Consolidate various cache flush ops
cover iommu/vt-d: Consolidate various cache flush ops
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing iommu_flush structure.
/* struct iommu_flush - Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches when software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by requests-with-PASID
* from the Device-TLB on an endpoint device
*/
struct iommu_flush {
void (*cc_inv)(struct intel_iommu *iommu, u16 did,
u16 sid, u8 fm, u64 type);
void (*iotlb_inv)(struct intel_iommu *iommu, u16 did, u64 addr,
unsigned int size_order, u64 type);
void (*p_iotlb_inv)(struct intel_iommu *iommu, u16 did, u32 pasid,
u64 addr, unsigned long npages, bool ih);
void (*pc_inv)(struct intel_iommu *iommu, u16 did, u32 pasid,
u64 granu);
void (*dev_tlb_inv)(struct intel_iommu *iommu, u16 sid, u16 pfsid,
u16 qdep, u64 addr, unsigned int mask);
void (*p_dev_tlb_inv)(struct intel_iommu *iommu, u16 sid, u16 pfsid,
u32 pasid, u16 qdep, u64 addr,
unsigned long npages);
};The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Best regards,
Lu Baolu
Lu Baolu (5):
iommu/vt-d: Extend iommu_flush for scalable mode iommu/vt-d: Consolidate pasid cache invalidation iommu/vt-d: Consolidate device tlb invalidation iommu/vt-d: Consolidate pasid-based tlb invalidation iommu/vt-d: Consolidate pasid-based device tlb invalidation
drivers/iommu/dmar.c | 61 --------- drivers/iommu/intel-iommu.c | 246 +++++++++++++++++++++++++++++------- drivers/iommu/intel-pasid.c | 39 +----- drivers/iommu/intel-svm.c | 60 ++------- include/linux/intel-iommu.h | 39 ++++-- 5 files changed, 244 insertions(+), 201 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/5 iommu/vt-d: Extend iommu_flush for scalable mode
Intel VT-d 3.0 introduces more cache flush interfaces when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing iommu_flush structure. The name of each cache flush operation is defined according to the spec (section 6.5) so that people are easy to look up them in the spec.
--- drivers/iommu/dmar.c | 38 ------------ drivers/iommu/intel-iommu.c | 118 ++++++++++++++++++++++-------------- include/linux/intel-iommu.h | 34 ++++++++--- 3 files changed, 98 insertions(+), 92 deletions(-)
drivers/iommu/dmar.c +0 -38
@@ -1307,44 +1307,6 @@ void qi_global_iec(struct intel_iommu *iommu)qi_submit_sync (&desc, iommu); } -void qi_flush_context (struct intel_iommu *iommu,u16 did,u16 sid,u8 fm, -u64 type) -{ -struct qi_desc desc; - - desc.qw0 =QI_CC_FM (fm) |QI_CC_SID (sid) |QI_CC_DID (did) - |QI_CC_GRAN (type) |QI_CC_TYPE ; - desc.qw1 =0 ; - desc.qw2 =0 ; - desc.qw3 =0 ; - -qi_submit_sync (&desc, iommu); -} - -void qi_flush_iotlb (struct intel_iommu *iommu,u16 did,u64 addr, -unsigned int size_order,u64 type) -{ -u8 dw =0 , dr =0 ; - -struct qi_desc desc; -int ih =0 ; - -if (cap_write_drain (iommu->cap)) - dw =1 ; - -if (cap_read_drain (iommu->cap)) - dr =1 ; - - desc.qw0 =QI_IOTLB_DID (did) |QI_IOTLB_DR (dr) |QI_IOTLB_DW (dw) - |QI_IOTLB_GRAN (type) |QI_IOTLB_TYPE ; - desc.qw1 =QI_IOTLB_ADDR (addr) |QI_IOTLB_IH (ih) - |QI_IOTLB_AM (size_order); - desc.qw2 =0 ; - desc.qw3 =0 ; - -qi_submit_sync (&desc, iommu); -} -void qi_flush_dev_iotlb (struct intel_iommu *iommu,u16 sid,u16 pfsid,u16 qdep,u64 addr,unsigned mask) {
drivers/iommu/intel-iommu.c +72 -46
194 lines not on this page · raw message
include/linux/intel-iommu.h +26 -8
@@ -418,11 +418,33 @@ struct ir_table { };#endif +/* struct iommu_flush - Intel IOMMU cache invalidation ops +* +* @cc_inv: invalidate context cache +* @iotlb_inv: Invalidate IOTLB and paging structure caches when software +* has changed second-level tables. +* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when software +* has changed first-level tables. +* @pc_inv: invalidate pasid cache +* @dev_tlb_inv: invalidate cached mappings used by requests-without-PASID +* from the Device-TLB on a endpoint device. +* @p_dev_tlb_inv: invalidate cached mappings used by requests-with-PASID +* from the Device-TLB on an endpoint device +*/ struct iommu_flush { -void (*flush_context)(struct intel_iommu *iommu,u16 did,u16 sid, -u8 fm,u64 type); -void (*flush_iotlb)(struct intel_iommu *iommu,u16 did,u64 addr, -unsigned int size_order,u64 type); +void (*cc_inv)(struct intel_iommu *iommu,u16 did, +u16 sid,u8 fm,u64 type); +void (*iotlb_inv)(struct intel_iommu *iommu,u16 did,u64 addr, +unsigned int size_order,u64 type); +void (*p_iotlb_inv)(struct intel_iommu *iommu,u16 did,u32 pasid, +u64 addr,unsigned long npages,bool ih); +void (*pc_inv)(struct intel_iommu *iommu,u16 did,u32 pasid, +u64 granu); +void (*dev_tlb_inv)(struct intel_iommu *iommu,u16 sid,u16 pfsid, +u16 qdep,u64 addr,unsigned int mask); +void (*p_dev_tlb_inv)(struct intel_iommu *iommu,u16 sid,u16 pfsid, +u32 pasid,u16 qdep,u64 addr, +unsigned long npages); };enum {
@@ -640,10 +662,6 @@ extern void dmar_disable_qi(struct intel_iommu *iommu);extern int dmar_reenable_qi (struct intel_iommu *iommu);extern void qi_global_iec (struct intel_iommu *iommu); -extern void qi_flush_context (struct intel_iommu *iommu,u16 did,u16 sid, -u8 fm,u64 type); -extern void qi_flush_iotlb (struct intel_iommu *iommu,u16 did,u64 addr, -unsigned int size_order,u64 type);extern void qi_flush_dev_iotlb (struct intel_iommu *iommu,u16 sid,u16 pfsid,u16 qdep,u64 addr,unsigned mask);extern int qi_submit_sync (struct qi_desc *desc,struct intel_iommu *iommu);
Signature · 1 line
2.17.1
PATCH 2/5 iommu/vt-d: Consolidate pasid cache invalidation
In reply to Lu BaoluMerge pasid cache invalidation into iommu->flush.pc_inv.
--- drivers/iommu/intel-iommu.c | 13 +++++++++++++ drivers/iommu/intel-pasid.c | 18 ++---------------- include/linux/intel-iommu.h | 3 +++ 3 files changed, 18 insertions(+), 16 deletions(-)
drivers/iommu/intel-iommu.c +13 -0
@@ -2994,6 +2994,18 @@ qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,qi_submit_sync (&desc, iommu); } +/* PASID cache invalidation */ +static void +qi_flush_pasid (struct intel_iommu *iommu,u16 did,u32 pasid,u64 granu) +{ +struct qi_desc desc = {.qw1 =0 , .qw2 =0 , .qw3 =0 }; + + desc.qw0 =QI_PC_PASID (pasid) |QI_PC_DID (did) | +QI_PC_GRAN (granu) |QI_PC_TYPE ; + +qi_submit_sync (&desc, iommu); +} +static void intel_iommu_init_qi (struct intel_iommu *iommu) {/*
@@ -3025,6 +3037,7 @@ static void intel_iommu_init_qi(struct intel_iommu *iommu) }else { iommu->flush.cc_inv = qi_flush_context; iommu->flush.iotlb_inv = qi_flush_iotlb; + iommu->flush.pc_inv = qi_flush_pasid;pr_info ("%s: Using Queued invalidation\n" , iommu->name); } }
drivers/iommu/intel-pasid.c +2 -16
@@ -359,20 +359,6 @@ pasid_set_flpm(struct pasid_entry *pe, u64 value)pasid_set_bits (&pe->val[2 ],GENMASK_ULL (3 ,2 ), value <<2 ); } -static void -pasid_cache_invalidation_with_pasid (struct intel_iommu *iommu, -u16 did,int pasid) -{ -struct qi_desc desc; - - desc.qw0 =QI_PC_DID (did) |QI_PC_PASID_SEL |QI_PC_PASID (pasid); - desc.qw1 =0 ; - desc.qw2 =0 ; - desc.qw3 =0 ; - -qi_submit_sync (&desc, iommu); -} -static void iotlb_invalidation_with_pasid (struct intel_iommu *iommu,u16 did,u32 pasid) {
@@ -421,7 +407,7 @@ void intel_pasid_tear_down_entry(struct intel_iommu *iommu,if (!ecap_coherent (iommu->ecap))clflush_cache_range (pte,sizeof (*pte)); -pasid_cache_invalidation_with_pasid (iommu, did, pasid); + iommu->flush.pc_inv (iommu, did, pasid,QI_PC_GRAN_PSWD );iotlb_invalidation_with_pasid (iommu, did, pasid);/* Device IOTLB doesn't need to be flushed in caching mode. */
@@ -437,7 +423,7 @@ static void pasid_flush_caches(struct intel_iommu *iommu,clflush_cache_range (pte,sizeof (*pte));if (cap_caching_mode (iommu->cap)) { -pasid_cache_invalidation_with_pasid (iommu, did, pasid); + iommu->flush.pc_inv (iommu, did, pasid,QI_PC_GRAN_PSWD );iotlb_invalidation_with_pasid (iommu, did, pasid); }else {iommu_flush_write_buffer (iommu);
include/linux/intel-iommu.h +3 -0
@@ -344,6 +344,9 @@ enum {#define QI_PC_PASID (pasid) (((u64)pasid) << 32)#define QI_PC_DID (did) (((u64)did) << 16)#define QI_PC_GRAN (gran) (((u64)gran) << 4) +#define QI_PC_GRAN_DS 0 +#define QI_PC_GRAN_PSWD 1 +#define QI_PC_GRAN_GLOBAL 3#define QI_PC_ALL_PASIDS (QI_PC_TYPE | QI_PC_GRAN(0))#define QI_PC_PASID_SEL (QI_PC_TYPE | QI_PC_GRAN(1))
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 3/5 iommu/vt-d: Consolidate device tlb invalidation
In reply to Lu BaoluMerge device tlb invalidation into iommu->flush.dev_tlb_inv.
--- drivers/iommu/dmar.c | 23 ----------------------- drivers/iommu/intel-iommu.c | 31 +++++++++++++++++++++++++++++-- drivers/iommu/intel-pasid.c | 3 ++- include/linux/intel-iommu.h | 2 -- 4 files changed, 31 insertions(+), 28 deletions(-)
drivers/iommu/dmar.c +0 -23
@@ -1307,29 +1307,6 @@ void qi_global_iec(struct intel_iommu *iommu)qi_submit_sync (&desc, iommu); } -void qi_flush_dev_iotlb (struct intel_iommu *iommu,u16 sid,u16 pfsid, -u16 qdep,u64 addr,unsigned mask) -{ -struct qi_desc desc; - -if (mask) { -WARN_ON_ONCE (addr & ((1ULL << (VTD_PAGE_SHIFT + mask)) -1 )); - addr |= (1ULL << (VTD_PAGE_SHIFT + mask -1 )) -1 ; - desc.qw1 =QI_DEV_IOTLB_ADDR (addr) |QI_DEV_IOTLB_SIZE ; - }else - desc.qw1 =QI_DEV_IOTLB_ADDR (addr); - -if (qdep >=QI_DEV_IOTLB_MAX_INVS ) - qdep =0 ; - - desc.qw0 =QI_DEV_IOTLB_SID (sid) |QI_DEV_IOTLB_QDEP (qdep) | -QI_DIOTLB_TYPE |QI_DEV_IOTLB_PFSID (pfsid); - desc.qw2 =0 ; - desc.qw3 =0 ; - -qi_submit_sync (&desc, iommu); -} -/* * Disable Queued Invalidation interface. */
drivers/iommu/intel-iommu.c +29 -2
@@ -1465,6 +1465,7 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain, {u16 sid, qdep;unsigned long flags; +struct intel_iommu *iommu;struct device_domain_info *info;if (!domain->has_iotlb_device)
@@ -1477,8 +1478,9 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain, sid = info->bus <<8 | info->devfn; qdep = info->ats_qdep; -qi_flush_dev_iotlb (info->iommu, sid, info->pfsid, - qdep, addr, mask); + iommu = info->iommu; + iommu->flush.dev_tlb_inv (iommu, sid, info->pfsid, + qdep, addr, mask); }spin_unlock_irqrestore (&device_domain_lock, flags); }
@@ -3006,6 +3008,30 @@ qi_flush_pasid(struct intel_iommu *iommu, u16 did, u32 pasid, u64 granu)qi_submit_sync (&desc, iommu); } +/* Device TLB invalidation */ +static void +qi_flush_dev_iotlb (struct intel_iommu *iommu,u16 sid,u16 pfsid, +u16 qdep,u64 addr,unsigned int mask) +{ +struct qi_desc desc = {.qw2 =0 , .qw3 =0 }; + +if (mask) { +WARN_ON_ONCE (addr & ((1ULL << (VTD_PAGE_SHIFT + mask)) -1 )); + addr |= (1ULL << (VTD_PAGE_SHIFT + mask -1 )) -1 ; + desc.qw1 =QI_DEV_IOTLB_ADDR (addr) |QI_DEV_IOTLB_SIZE ; + }else { + desc.qw1 =QI_DEV_IOTLB_ADDR (addr); + } + +if (qdep >=QI_DEV_IOTLB_MAX_INVS ) + qdep =0 ; + + desc.qw0 =QI_DEV_IOTLB_SID (sid) |QI_DEV_IOTLB_QDEP (qdep) | +QI_DIOTLB_TYPE |QI_DEV_IOTLB_PFSID (pfsid); + +qi_submit_sync (&desc, iommu); +} +static void intel_iommu_init_qi (struct intel_iommu *iommu) {/*
@@ -3038,6 +3064,7 @@ static void intel_iommu_init_qi(struct intel_iommu *iommu) iommu->flush.cc_inv = qi_flush_context; iommu->flush.iotlb_inv = qi_flush_iotlb; iommu->flush.pc_inv = qi_flush_pasid; + iommu->flush.dev_tlb_inv = qi_flush_dev_iotlb;pr_info ("%s: Using Queued invalidation\n" , iommu->name); } }
drivers/iommu/intel-pasid.c +2 -1
@@ -388,7 +388,8 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu, qdep = info->ats_qdep; pfsid = info->pfsid; -qi_flush_dev_iotlb (iommu, sid, pfsid, qdep,0 ,64 -VTD_PAGE_SHIFT ); + iommu->flush.dev_tlb_inv (iommu, sid, pfsid, qdep, +0 ,64 -VTD_PAGE_SHIFT ); } void intel_pasid_tear_down_entry(struct intel_iommu *iommu,
include/linux/intel-iommu.h +0 -2
@@ -665,8 +665,6 @@ extern void dmar_disable_qi(struct intel_iommu *iommu);extern int dmar_reenable_qi (struct intel_iommu *iommu);extern void qi_global_iec (struct intel_iommu *iommu); -extern void qi_flush_dev_iotlb (struct intel_iommu *iommu,u16 sid,u16 pfsid, -u16 qdep,u64 addr,unsigned mask);extern int qi_submit_sync (struct qi_desc *desc,struct intel_iommu *iommu);extern int dmar_ir_support (void );
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 4/5 iommu/vt-d: Consolidate pasid-based tlb invalidation
In reply to Lu BaoluMerge pasid-based tlb invalidation into iommu->flush.p_iotlb_inv.
--- drivers/iommu/intel-iommu.c | 43 +++++++++++++++++++++++++++++++++++++ drivers/iommu/intel-pasid.c | 18 ++-------------- drivers/iommu/intel-svm.c | 23 +++----------------- 3 files changed, 48 insertions(+), 36 deletions(-)
drivers/iommu/intel-iommu.c +43 -0
@@ -3032,6 +3032,48 @@ qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,qi_submit_sync (&desc, iommu); } +/* PASID-based IOTLB invalidation */ +static void +qi_flush_piotlb (struct intel_iommu *iommu,u16 did,u32 pasid,u64 addr, +unsigned long npages,bool ih) +{ +struct qi_desc desc = {.qw2 =0 , .qw3 =0 }; + +/* +* npages == -1 means a PASID-selective invalidation, otherwise, +* a positive value for Page-selective-within-PASID invalidation. +* 0 is not a valid input. +*/ +if (WARN_ON (!npages)) { +pr_err ("Invalid input npages = %ld\n" , npages); +return ; + } + +if (npages ==-1 ) { + desc.qw0 =QI_EIOTLB_PASID (pasid) | +QI_EIOTLB_DID (did) | +QI_EIOTLB_GRAN (QI_GRAN_NONG_PASID ) | +QI_EIOTLB_TYPE ; + desc.qw1 =0 ; + }else { +int mask =ilog2 (__roundup_pow_of_two (npages)); +unsigned long align = (1ULL << (VTD_PAGE_SHIFT + mask)); + +if (WARN_ON_ONCE (!ALIGN (addr, align))) + addr &= ~(align -1 ); + + desc.qw0 =QI_EIOTLB_PASID (pasid) | +QI_EIOTLB_DID (did) | +QI_EIOTLB_GRAN (QI_GRAN_PSI_PASID ) | +QI_EIOTLB_TYPE ; + desc.qw1 =QI_EIOTLB_ADDR (addr) | +QI_EIOTLB_IH (ih) | +QI_EIOTLB_AM (mask); + } + +qi_submit_sync (&desc, iommu); +} +static void intel_iommu_init_qi (struct intel_iommu *iommu) {/*
@@ -3065,6 +3107,7 @@ static void intel_iommu_init_qi(struct intel_iommu *iommu) iommu->flush.iotlb_inv = qi_flush_iotlb; iommu->flush.pc_inv = qi_flush_pasid; iommu->flush.dev_tlb_inv = qi_flush_dev_iotlb; + iommu->flush.p_iotlb_inv = qi_flush_piotlb;pr_info ("%s: Using Queued invalidation\n" , iommu->name); } }
drivers/iommu/intel-pasid.c +2 -16
@@ -359,20 +359,6 @@ pasid_set_flpm(struct pasid_entry *pe, u64 value)pasid_set_bits (&pe->val[2 ],GENMASK_ULL (3 ,2 ), value <<2 ); } -static void -iotlb_invalidation_with_pasid (struct intel_iommu *iommu,u16 did,u32 pasid) -{ -struct qi_desc desc; - - desc.qw0 =QI_EIOTLB_PASID (pasid) |QI_EIOTLB_DID (did) | -QI_EIOTLB_GRAN (QI_GRAN_NONG_PASID ) |QI_EIOTLB_TYPE ; - desc.qw1 =0 ; - desc.qw2 =0 ; - desc.qw3 =0 ; - -qi_submit_sync (&desc, iommu); -} -static void devtlb_invalidation_with_pasid (struct intel_iommu *iommu,struct device *dev,int pasid)
@@ -409,7 +395,7 @@ void intel_pasid_tear_down_entry(struct intel_iommu *iommu,clflush_cache_range (pte,sizeof (*pte)); iommu->flush.pc_inv (iommu, did, pasid,QI_PC_GRAN_PSWD ); -iotlb_invalidation_with_pasid (iommu, did, pasid); + iommu->flush.p_iotlb_inv (iommu, did, pasid,0 ,-1 ,0 );/* Device IOTLB doesn't need to be flushed in caching mode. */ if (!cap_caching_mode (iommu->cap))
@@ -425,7 +411,7 @@ static void pasid_flush_caches(struct intel_iommu *iommu,if (cap_caching_mode (iommu->cap)) { iommu->flush.pc_inv (iommu, did, pasid,QI_PC_GRAN_PSWD ); -iotlb_invalidation_with_pasid (iommu, did, pasid); + iommu->flush.p_iotlb_inv (iommu, did, pasid,0 ,-1 ,0 ); }else {iommu_flush_write_buffer (iommu); }
drivers/iommu/intel-svm.c +3 -20
@@ -118,27 +118,10 @@ static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_d unsigned long address, unsigned long pages, int ih) { struct qi_desc desc; +struct intel_iommu *iommu = svm->iommu; -if (pages ==-1 ) { - desc.qw0 =QI_EIOTLB_PASID (svm->pasid) | -QI_EIOTLB_DID (sdev->did) | -QI_EIOTLB_GRAN (QI_GRAN_NONG_PASID ) | -QI_EIOTLB_TYPE ; - desc.qw1 =0 ; - }else { -int mask =ilog2 (__roundup_pow_of_two (pages)); - - desc.qw0 =QI_EIOTLB_PASID (svm->pasid) | -QI_EIOTLB_DID (sdev->did) | -QI_EIOTLB_GRAN (QI_GRAN_PSI_PASID ) | -QI_EIOTLB_TYPE ; - desc.qw1 =QI_EIOTLB_ADDR (address) | -QI_EIOTLB_IH (ih) | -QI_EIOTLB_AM (mask); - } - desc.qw2 =0 ; - desc.qw3 =0 ; -qi_submit_sync (&desc, svm->iommu); + iommu->flush.p_iotlb_inv (iommu, sdev->did, + svm->pasid, address, pages, ih);if (sdev->dev_iotlb) { desc.qw0 = QI_DEV_EIOTLB_PASID(svm->pasid) |
Signature · 1 line
2.17.1
PATCH 5/5 iommu/vt-d: Consolidate pasid-based device tlb invalidation
In reply to Lu BaoluMerge pasid-based device tlb invalidation into iommu->flush.p_dev_tlb_inv.
--- drivers/iommu/intel-iommu.c | 41 +++++++++++++++++++++++++++++++++++++ drivers/iommu/intel-svm.c | 33 ++++++----------------------- 2 files changed, 47 insertions(+), 27 deletions(-)
drivers/iommu/intel-iommu.c +41 -0
@@ -3074,6 +3074,46 @@ qi_flush_piotlb(struct intel_iommu *iommu, u16 did, u32 pasid, u64 addr,qi_submit_sync (&desc, iommu); } +/* PASID-based device TLB invalidation */ +static void +qi_flush_dev_piotlb (struct intel_iommu *iommu,u16 sid,u16 pfsid, +u32 pasid,u16 qdep,u64 address,unsigned long npages) +{ +struct qi_desc desc = {.qw2 =0 , .qw3 =0 }; + + desc.qw0 =QI_DEV_EIOTLB_PASID (pasid) |QI_DEV_EIOTLB_SID (sid) | +QI_DEV_EIOTLB_QDEP (qdep) |QI_DEIOTLB_TYPE | +QI_DEV_IOTLB_PFSID (pfsid); + +/* +* npages == -1 means a PASID-selective invalidation, otherwise, +* a positive value for Page-selective-within-PASID invalidation. +* 0 is not a valid input. +*/ +if (WARN_ON (!npages)) { +pr_err ("Invalid input npages = %ld\n" , npages); +return ; + } + +if (npages ==-1 ) { + desc.qw1 =QI_DEV_EIOTLB_ADDR (((u64)-1 ) >>1 ) | +QI_DEV_EIOTLB_SIZE ; + }else if (npages >1 ) { +/* The least significant zero bit indicates the size. So, +* for example, an "address" value of 0x12345f000 will +* flush from 0x123440000 to 0x12347ffff (256KiB). */ +unsigned long last = address + ((unsigned long )(npages -1 ) <<VTD_PAGE_SHIFT ); +unsigned long mask =__rounddown_pow_of_two (address ^ last); + + desc.qw1 =QI_DEV_EIOTLB_ADDR ((address & ~mask) | + (mask -1 )) |QI_DEV_EIOTLB_SIZE ; + }else { + desc.qw1 =QI_DEV_EIOTLB_ADDR (address); + } + +qi_submit_sync (&desc, iommu); +} +static void intel_iommu_init_qi (struct intel_iommu *iommu) {/*
@@ -3108,6 +3148,7 @@ static void intel_iommu_init_qi(struct intel_iommu *iommu) iommu->flush.pc_inv = qi_flush_pasid; iommu->flush.dev_tlb_inv = qi_flush_dev_iotlb; iommu->flush.p_iotlb_inv = qi_flush_piotlb; + iommu->flush.p_dev_tlb_inv = qi_flush_dev_piotlb;pr_info ("%s: Using Queued invalidation\n" , iommu->name); } }
drivers/iommu/intel-svm.c +6 -27
@@ -114,39 +114,18 @@ void intel_svm_check(struct intel_iommu *iommu) iommu->flags |=VTD_FLAG_SVM_CAPABLE ; } -static void intel_flush_svm_range_dev (struct intel_svm *svm,struct intel_svm_dev *sdev, -unsigned long address,unsigned long pages,int ih) +static void +intel_flush_svm_range_dev (struct intel_svm *svm,struct intel_svm_dev *sdev, +unsigned long address,unsigned long pages,int ih) { -struct qi_desc desc;struct intel_iommu *iommu = svm->iommu; iommu->flush.p_iotlb_inv (iommu, sdev->did, svm->pasid, address, pages, ih); -if (sdev->dev_iotlb) { - desc.qw0 =QI_DEV_EIOTLB_PASID (svm->pasid) | -QI_DEV_EIOTLB_SID (sdev->sid) | -QI_DEV_EIOTLB_QDEP (sdev->qdep) | -QI_DEIOTLB_TYPE ; -if (pages ==-1 ) { - desc.qw1 =QI_DEV_EIOTLB_ADDR (-1ULL >>1 ) | -QI_DEV_EIOTLB_SIZE ; - }else if (pages >1 ) { -/* The least significant zero bit indicates the size. So, -* for example, an "address" value of 0x12345f000 will -* flush from 0x123440000 to 0x12347ffff (256KiB). */ -unsigned long last = address + ((unsigned long )(pages -1 ) <<VTD_PAGE_SHIFT ); -unsigned long mask =__rounddown_pow_of_two (address ^ last); - - desc.qw1 =QI_DEV_EIOTLB_ADDR ((address & ~mask) | - (mask -1 )) |QI_DEV_EIOTLB_SIZE ; - }else { - desc.qw1 =QI_DEV_EIOTLB_ADDR (address); - } - desc.qw2 =0 ; - desc.qw3 =0 ; -qi_submit_sync (&desc, svm->iommu); - } +if (sdev->dev_iotlb) + iommu->flush.p_dev_tlb_inv (iommu, sdev->sid,0 , svm->pasid, + sdev->qdep, address, pages); } static void intel_flush_svm_range(struct intel_svm *svm, unsigned long address,
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 35 lines · On Fri, 22 Nov 2019 11:04:44 +0800 Lu Baolu <[email protected]> wrote:
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing
iommu_flushstructure./* struct
iommu_flush- Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by
requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by
requests-with-PASID
* from the Device-TLB on an endpoint device
*/
structiommu_flush{
void (*cc_inv)(structintel_iommu*iommu, u16 did,
u16 sid, u8 fm, u64 type);
void (*iotlb_inv)(structintel_iommu*iommu, u16 did, u64
addr, unsigned intsize_order, u64 type);
void (*p_iotlb_inv)(structintel_iommu*iommu, u16 did, u32
pasid, u64 addr, unsigned long npages, bool ih);
void (*pc_inv)(structintel_iommu*iommu, u16 did, u32 pasid,
u64 granu);
void (*dev_tlb_inv)(structintel_iommu*iommu, u16 sid, u16
pfsid, u16 qdep, u64 addr, unsigned int mask);
void (*p_dev_tlb_inv)(structintel_iommu*iommu, u16 sid, u16
pfsid, u32 pasid, u16 qdep, u64 addr,
Quoted 6 lines
unsigned long npages); };The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Nice consolidation. For nested SVM, I also introduced cache flushed helpers as needed.
https://lkml.org/lkml/2019/10/24/857
Should I wait for yours to be merged or you want to extend the this consolidation after SVA/SVM cache flush? I expect to send my v8 shortly.
Quoted 10 lines
Best regards,
Lu BaoluLu Baolu (5):
iommu/vt-d: Extendiommu_flushfor scalable mode iommu/vt-d: Consolidate pasid cache invalidation iommu/vt-d: Consolidate device tlb invalidation iommu/vt-d: Consolidate pasid-based tlb invalidation iommu/vt-d: Consolidate pasid-based device tlb invalidation
Quoted 7 lines
drivers/iommu/dmar.c | 61 --------- drivers/iommu/intel-iommu.c | 246 +++++++++++++++++++++++++++++------- drivers/iommu/intel-pasid.c | 39 +----- drivers/iommu/intel-svm.c | 60 ++------- include/linux/intel-iommu.h | 39 ++++-- 5 files changed, 244 insertions(+), 201 deletions(-)
[Jacob Pan]
Hi Jacob,
Quoted 44 lines · Jacob Pan
Quoted 35 lines · On Fri, 22 Nov 2019 11:04:44 +0800 Lu Baolu<[email protected]> wrote:
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing
iommu_flushstructure./* struct
iommu_flush- Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by
requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by
requests-with-PASID
* from the Device-TLB on an endpoint device
*/
structiommu_flush{
void (*cc_inv)(structintel_iommu*iommu, u16 did,
u16 sid, u8 fm, u64 type);
void (*iotlb_inv)(structintel_iommu*iommu, u16 did, u64
addr, unsigned intsize_order, u64 type);
void (*p_iotlb_inv)(structintel_iommu*iommu, u16 did, u32
pasid, u64 addr, unsigned long npages, bool ih);
void (*pc_inv)(structintel_iommu*iommu, u16 did, u32 pasid,
u64 granu);
void (*dev_tlb_inv)(structintel_iommu*iommu, u16 sid, u16
pfsid, u16 qdep, u64 addr, unsigned int mask);
void (*p_dev_tlb_inv)(structintel_iommu*iommu, u16 sid, u16
pfsid, u32 pasid, u16 qdep, u64 addr,Quoted 6 lines
unsigned long npages); };The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Quoted 7 lines
Nice consolidation. For nested SVM, I also introduced cache flushed helpers as needed.
https://lkml.org/lkml/2019/10/24/857Should I wait for yours to be merged or you want to extend the this consolidation after SVA/SVM cache flush? I expect to send my v8 shortly.
Please base your v8 patch on this series. So it could get more chances for test.
I will queue this patch series for internal test after 5.5-rc1 and if everything goes well, I will forward it to Joerg around rc4 for linux- next.
Best regards,
baolu
Quoted 34 lines · Lu Baolu
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing
iommu_flushstructure./* struct
iommu_flush- Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches when software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by requests-with-PASID
* from the Device-TLB on an endpoint device
*/struct iommu_flush { void (*cc_inv)(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm, u64 type); void (*iotlb_inv)(struct intel_iommu *iommu, u16 did, u64 addr, unsigned int size_order, u64 type); void (*p_iotlb_inv)(struct intel_iommu *iommu, u16 did, u32 pasid, u64 addr, unsigned long npages, bool ih); void (*pc_inv)(struct intel_iommu *iommu, u16 did, u32 pasid, u64 granu); void (*dev_tlb_inv)(struct intel_iommu *iommu, u16 sid, u16 pfsid, u16 qdep, u64 addr, unsigned int mask); void (*p_dev_tlb_inv)(struct intel_iommu *iommu, u16 sid, u16 pfsid, u32 pasid, u16 qdep, u64 addr, unsigned long npages); };
Quoted 2 lines
The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Hm, indirect function calls are quite expensive these days.
I would have preferred to go in the opposite direction, since surely aren't going to have *many* of these implementations. Currently there's only one for register-based and one for queued invalidation, right? Even if VT-d 3.0 throws an extra version in, I think I'd prefer to take out the indirection completely and have an if/then helper.
Would love to see a microbenchmark of unmap operations before and after this patch series with retpoline enabled, to see the effect.
Quoted 51 lines · On Tue, 3 Dec 2019 10:44:45 +0800 Lu Baolu <[email protected]> wrote:
Hi Jacob,
Quoted 48 lines · Jacob Pan
Quoted 35 lines · On Fri, 22 Nov 2019 11:04:44 +0800 Lu Baolu<[email protected]> wrote:
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing
iommu_flushstructure./* struct
iommu_flush- Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by
requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by
requests-with-PASID
* from the Device-TLB on an endpoint device
*/
structiommu_flush{
void (*cc_inv)(structintel_iommu*iommu, u16 did,
u16 sid, u8 fm, u64 type);
void (*iotlb_inv)(structintel_iommu*iommu, u16 did, u64
addr, unsigned intsize_order, u64 type);
void (*p_iotlb_inv)(structintel_iommu*iommu, u16 did,
u32 pasid, u64 addr, unsigned long npages, bool ih);
void (*pc_inv)(structintel_iommu*iommu, u16 did, u32
pasid, u64 granu);
void (*dev_tlb_inv)(structintel_iommu*iommu, u16 sid,
u16 pfsid, u16 qdep, u64 addr, unsigned int mask);
void (*p_dev_tlb_inv)(structintel_iommu*iommu, u16 sid,
u16 pfsid, u32 pasid, u16 qdep, u64 addr,Quoted 6 lines
unsigned long npages); };The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Nice consolidation. For nested SVM, I also introduced cache flushed helpers as needed.
https://lkml.org/lkml/2019/10/24/857
Quoted 7 lines
Quoted 3 lines
Should I wait for yours to be merged or you want to extend the this consolidation after SVA/SVM cache flush? I expect to send my v8 shortly.
Please base your v8 patch on this series. So it could get more chances for test.
Sounds good.
Quoted 6 lines
I will queue this patch series for internal test after 5.5-rc1 and if everything goes well, I will forward it to Joerg around rc4 for linux- next.
Best regards,
baolu
[Jacob Pan]
Re: [PATCH 4/5] iommu/vt-d: Consolidate pasid-based tlb invalidation
In reply to Lu BaoluQuoted 34 lines · On Fri, 22 Nov 2019 11:04:48 +0800 Lu Baolu <[email protected]> wrote:
Merge pasid-based tlb invalidation into
iommu->flush.p_iotlb_inv.Signed-off-by Lu Baolu <[email protected]>--- drivers/iommu/intel-iommu.c | 43+++++++++++++++++++++++++++++++++++++
drivers/iommu/intel-pasid.c|
18 ++--------------drivers/iommu/intel-svm.c| 23
+++----------------- 3 files changed, 48 insertions(+), 36 deletions(-)drivers/iommu/intel-iommu.c +10
-0@@ -3032,6 +3032,48 @@ qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid, qi_submit_sync(&desc, iommu); } +/* PASID-based IOTLB invalidation */ +static void +qi_flush_piotlb (struct intel_iommu *iommu,u16 did,u32 pasid,u64 addr, +unsigned long npages,bool ih) +{ +struct qi_desc desc = {.qw2 =0 , .qw3 =0 }; + +/* +* npages == -1 means a PASID-selective invalidation, otherwise, +* a positive value for Page-selective-within-PASID invalidation.
drivers/iommu/intel-iommu.c +3
-0+* 0 is not a valid input. +*/ +if (WARN_ON (!npages)) {
drivers/iommu/intel-iommu.c qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid, · line 3057
Quoted 10 lines
drivers/iommu/intel-iommu.c +10
-0+pr_err ("Invalid input npages = %ld\n" , npages); +return ; + } + +if (npages ==-1 ) { + desc.qw0 =QI_EIOTLB_PASID (pasid) | +QI_EIOTLB_DID (did) | +QI_EIOTLB_GRAN (QI_GRAN_NONG_PASID ) | +QI_EIOTLB_TYPE ; + desc.qw1 =0 ;
Is this based on the latest kernel? seems to be missing the recent change for checking page selective cap. So I run into conflict.
+ /*
+ * Do PASID granu IOTLB invalidation if page selective
capability is
+ * not
available.
+
*/
+ if (pages == -1 || !cap_pgsel_inv(svm->iommu->cap))
{
+ desc.qw0 = QI_EIOTLB_PASID(svm->pasid)
|
Seems missing this one in your base?
Refs: v5.3-rc6-2-g8744daf4b069 Author: Jacob Pan <[email protected]> AuthorDate: Mon Aug 26 08:53:29 2019 -0700 Commit: Joerg Roedel <[email protected]> CommitDate: Tue Sep 3 15:01:27 2019 +0200
iommu/vt-d: Remove global page flush support
Quoted 100 lines
drivers/iommu/intel-iommu.c +3
-0+ }else { +int mask =ilog2 (__roundup_pow_of_two (npages)); + unsigned long align = (1ULL << (VTD_PAGE_SHIFT +mask)); +
drivers/iommu/intel-iommu.c +16
-0+if (WARN_ON_ONCE (!ALIGN (addr, align))) + addr &= ~(align -1 ); + + desc.qw0 =QI_EIOTLB_PASID (pasid) | +QI_EIOTLB_DID (did) | +QI_EIOTLB_GRAN (QI_GRAN_PSI_PASID ) | +QI_EIOTLB_TYPE ; + desc.qw1 =QI_EIOTLB_ADDR (addr) | +QI_EIOTLB_IH (ih) | +QI_EIOTLB_AM (mask); + } + +qi_submit_sync (&desc, iommu); +} +static void intel_iommu_init_qi (struct intel_iommu *iommu) {/* @@ -3065,6 +3107,7 @@ static void intel_iommu_init_qi(struct intel_iommu *iommu) iommu->flush.iotlb_inv = qi_flush_iotlb; iommu->flush.pc_inv = qi_flush_pasid; iommu->flush.dev_tlb_inv = qi_flush_dev_iotlb; + iommu->flush.p_iotlb_inv = qi_flush_piotlb;pr_info ("%s: Using Queued invalidation\n" , iommu->name); } }drivers/iommu/intel-pasid.c +2
-15@@ -359,20 +359,6 @@ pasid_set_flpm(struct pasid_entry *pe, u64 value)pasid_set_bits (&pe->val[2 ],GENMASK_ULL (3 ,2 ), value <<2 ); } -static void -iotlb_invalidation_with_pasid (struct intel_iommu *iommu,u16 did, u32 pasid) -{ -struct qi_desc desc; - - desc.qw0 =QI_EIOTLB_PASID (pasid) |QI_EIOTLB_DID (did) | -QI_EIOTLB_GRAN (QI_GRAN_NONG_PASID ) |QI_EIOTLB_TYPE ; - desc.qw1 =0 ; - desc.qw2 =0 ; - desc.qw3 =0 ; - -qi_submit_sync (&desc, iommu); -} -static void devtlb_invalidation_with_pasid (struct intel_iommu *iommu,struct device *dev,int pasid)@@ -409,7 +395,7 @@ void intel_pasid_tear_down_entry(struct intel_iommu *iommu,clflush_cache_range (pte,sizeof (*pte)); iommu->flush.pc_inv (iommu, did, pasid,QI_PC_GRAN_PSWD ); -iotlb_invalidation_with_pasid (iommu, did, pasid); + iommu->flush.p_iotlb_inv (iommu, did, pasid,0 ,-1 ,0 );/* Device IOTLB doesn't need to be flushed in caching mode. */ if (!cap_caching_mode (iommu->cap))@@ -425,7 +411,7 @@ static void pasid_flush_caches(struct intel_iommu *iommu,if (cap_caching_mode (iommu->cap)) { iommu->flush.pc_inv (iommu, did, pasid,QI_PC_GRAN_PSWD ); -iotlb_invalidation_with_pasid (iommu, did, pasid); + iommu->flush.p_iotlb_inv (iommu, did, pasid,0 ,-1 ,0 ); }else {iommu_flush_write_buffer (iommu);drivers/iommu/intel-pasid.c +0
-0}drivers/iommu/intel-svm.c +0
-0@@ -118,27 +118,10 @@ static void intel_flush_svm_range_dev (struct
intel_svm*svm, structintel_svm_dunsigned long address, unsigned long pages, int ih) {drivers/iommu/intel-svm.c +1
-15struct qi_desc desc; +struct intel_iommu *iommu = svm->iommu; -if (pages ==-1 ) { - desc.qw0 =QI_EIOTLB_PASID (svm->pasid) | -QI_EIOTLB_DID (sdev->did) | -QI_EIOTLB_GRAN (QI_GRAN_NONG_PASID ) | -QI_EIOTLB_TYPE ; - desc.qw1 =0 ; - }else { -int mask =ilog2 (__roundup_pow_of_two (pages)); - - desc.qw0 =QI_EIOTLB_PASID (svm->pasid) | -QI_EIOTLB_DID (sdev->did) | -QI_EIOTLB_GRAN (QI_GRAN_PSI_PASID ) | -QI_EIOTLB_TYPE ; - desc.qw1 =QI_EIOTLB_ADDR (address) | - QI_EIOTLB_IH(ih) |
drivers/iommu/intel-svm.c static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_d · line 127
Quoted 10 lines
drivers/iommu/intel-svm.c +2
-5-QI_EIOTLB_AM (mask); - } - desc.qw2 =0 ; - desc.qw3 =0 ; -qi_submit_sync (&desc, svm->iommu); + iommu->flush.p_iotlb_inv (iommu, sdev->did, + svm->pasid, address, pages, ih);if (sdev->dev_iotlb) { desc.qw0 = QI_DEV_EIOTLB_PASID(svm->pasid) |
[Jacob Pan]
Hi David,
Quoted 35 lines · David Woodhouse
Quoted 34 lines · Lu Baolu
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing
iommu_flushstructure./* struct
iommu_flush- Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches when software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by requests-with-PASID
* from the Device-TLB on an endpoint device
*/struct iommu_flush { void (*cc_inv)(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm, u64 type); void (*iotlb_inv)(struct intel_iommu *iommu, u16 did, u64 addr, unsigned int size_order, u64 type); void (*p_iotlb_inv)(struct intel_iommu *iommu, u16 did, u32 pasid, u64 addr, unsigned long npages, bool ih); void (*pc_inv)(struct intel_iommu *iommu, u16 did, u32 pasid, u64 granu); void (*dev_tlb_inv)(struct intel_iommu *iommu, u16 sid, u16 pfsid, u16 qdep, u64 addr, unsigned int mask); void (*p_dev_tlb_inv)(struct intel_iommu *iommu, u16 sid, u16 pfsid, u32 pasid, u16 qdep, u64 addr, unsigned long npages); };
Quoted 4 lines
Quoted 2 lines
The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Hm, indirect function calls are quite expensive these days.
Good consideration. Thanks!
Quoted 9 lines
I would have preferred to go in the opposite direction, since surely aren't going to have *many* of these implementations. Currently there's only one for register-based and one for queued invalidation, right? Even if VT-d 3.0 throws an extra version in, I think I'd prefer to take out the indirection completely and have an if/then helper.
Would love to see a microbenchmark of unmap operations before and after this patch series with retpoline enabled, to see the effect.
Yes. Need some micro-bench tests to address the concern.
Best regards,
baolu
Hi Jacob,
Quoted 54 lines · Jacob Pan
Quoted 51 lines · On Tue, 3 Dec 2019 10:44:45 +0800 Lu Baolu <[email protected]> wrote:
Hi Jacob,
Quoted 48 lines · Jacob Pan
Quoted 35 lines · On Fri, 22 Nov 2019 11:04:44 +0800 Lu Baolu<[email protected]> wrote:
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing
iommu_flushstructure./* struct
iommu_flush- Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches when
software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by
requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by
requests-with-PASID
* from the Device-TLB on an endpoint device
*/
structiommu_flush{
void (*cc_inv)(structintel_iommu*iommu, u16 did,
u16 sid, u8 fm, u64 type);
void (*iotlb_inv)(structintel_iommu*iommu, u16 did, u64
addr, unsigned intsize_order, u64 type);
void (*p_iotlb_inv)(structintel_iommu*iommu, u16 did,
u32 pasid, u64 addr, unsigned long npages, bool ih);
void (*pc_inv)(structintel_iommu*iommu, u16 did, u32
pasid, u64 granu);
void (*dev_tlb_inv)(structintel_iommu*iommu, u16 sid,
u16 pfsid, u16 qdep, u64 addr, unsigned int mask);
void (*p_dev_tlb_inv)(structintel_iommu*iommu, u16 sid,
u16 pfsid, u32 pasid, u16 qdep, u64 addr,Quoted 6 lines
unsigned long npages); };The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Nice consolidation. For nested SVM, I also introduced cache flushed helpers as needed.
https://lkml.org/lkml/2019/10/24/857
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Should I wait for yours to be merged or you want to extend the this consolidation after SVA/SVM cache flush? I expect to send my v8 shortly.
Please base your v8 patch on this series. So it could get more chances for test.
Sounds good.
I am sorry I need to spend more time on this patch series. Please go ahead without it.
Best regards,
baolu
Quoted 10 lines
Quoted 7 lines
I will queue this patch series for internal test after 5.5-rc1 and if everything goes well, I will forward it to Joerg around rc4 for linux- next.
Best regards,
baolu[Jacob Pan]
Quoted 61 lines · On Wed, 4 Dec 2019 08:32:17 +0800 Lu Baolu <[email protected]> wrote:
Hi Jacob,
Quoted 58 lines · Jacob Pan
Quoted 55 lines · On Tue, 3 Dec 2019 10:44:45 +0800 Lu Baolu <[email protected]> wrote:
Hi Jacob,
Quoted 51 lines · Jacob Pan
Quoted 35 lines · On Fri, 22 Nov 2019 11:04:44 +0800 Lu Baolu<[email protected]> wrote:
Intel VT-d 3.0 introduces more caches and interfaces for software to flush when it runs in the scalable mode. Currently various cache flush helpers are scattered around. This consolidates them by putting them in the existing
iommu_flushstructure./* struct
iommu_flush- Intel IOMMU cache invalidation ops
*
* @cc_inv: invalidate context cache
* @iotlb_inv: Invalidate IOTLB and paging structure caches
when software
* has changed second-level tables.
* @p_iotlb_inv: Invalidate IOTLB and paging structure caches
when software
* has changed first-level tables.
* @pc_inv: invalidate pasid cache
* @dev_tlb_inv: invalidate cached mappings used by
requests-without-PASID
* from the Device-TLB on a endpoint device.
* @p_dev_tlb_inv: invalidate cached mappings used by
requests-with-PASID
* from the Device-TLB on an endpoint device
*/
structiommu_flush{
void (*cc_inv)(structintel_iommu*iommu, u16 did,
u16 sid, u8 fm, u64 type);
void (*iotlb_inv)(structintel_iommu*iommu, u16 did,
u64 addr, unsigned intsize_order, u64 type);
void (*p_iotlb_inv)(structintel_iommu*iommu, u16 did,
u32 pasid, u64 addr, unsigned long npages, bool ih);
void (*pc_inv)(structintel_iommu*iommu, u16 did, u32
pasid, u64 granu);
void (*dev_tlb_inv)(structintel_iommu*iommu, u16 sid,
u16 pfsid, u16 qdep, u64 addr, unsigned int mask);
void (*p_dev_tlb_inv)(structintel_iommu*iommu, u16
sid, u16 pfsid, u32 pasid, u16 qdep, u64 addr,Quoted 6 lines
unsigned long npages); };The name of each cache flush ops is defined according to the spec section 6.5 so that people are easy to look up them in the spec.
Nice consolidation. For nested SVM, I also introduced cache flushed helpers as needed.
https://lkml.org/lkml/2019/10/24/857Should I wait for yours to be merged or you want to extend the this consolidation after SVA/SVM cache flush? I expect to send my v8 shortly.
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Please base your v8 patch on this series. So it could get more chances for test.
Sounds good.
I am sorry I need to spend more time on this patch series. Please go ahead without it.
NP, let me know when you need testing.