Skip to content

Commit e36ee89

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/vt-d: Pass size_order to qi_desc_piotlb() not npages
It doesn't make sense for the caller to compute mask, throw it away and then have qi_desc_piotlb() compute it again. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/2-v1-f175e27af136+11647-iommupt_inv_vtd_jgg@nvidia.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent b6fd468 commit e36ee89

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

drivers/iommu/intel/cache.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,11 @@ static void qi_batch_add_piotlb_all(struct intel_iommu *iommu, u16 did,
338338
}
339339

340340
static void qi_batch_add_piotlb(struct intel_iommu *iommu, u16 did, u32 pasid,
341-
u64 addr, unsigned long npages, bool ih,
341+
u64 addr, unsigned int size_order, bool ih,
342342
struct qi_batch *batch)
343343
{
344-
if (!npages)
345-
return;
346-
347-
qi_desc_piotlb(did, pasid, addr, npages, ih, &batch->descs[batch->index]);
344+
qi_desc_piotlb(did, pasid, addr, size_order, ih,
345+
&batch->descs[batch->index]);
348346
qi_batch_increment_index(iommu, batch);
349347
}
350348

@@ -385,7 +383,7 @@ static void cache_tag_flush_iotlb(struct dmar_domain *domain, struct cache_tag *
385383
tag->pasid, domain->qi_batch);
386384
else
387385
qi_batch_add_piotlb(iommu, tag->domain_id, tag->pasid,
388-
addr, pages, ih, domain->qi_batch);
386+
addr, mask, ih, domain->qi_batch);
389387
return;
390388
}
391389

drivers/iommu/intel/iommu.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,19 +1087,16 @@ static inline void qi_desc_piotlb_all(u16 did, u32 pasid, struct qi_desc *desc)
10871087

10881088
/* Page-selective-within-PASID IOTLB invalidation */
10891089
static inline void qi_desc_piotlb(u16 did, u32 pasid, u64 addr,
1090-
unsigned long npages, bool ih,
1090+
unsigned int size_order, bool ih,
10911091
struct qi_desc *desc)
10921092
{
1093-
int mask = ilog2(__roundup_pow_of_two(npages));
1094-
unsigned long align = (1ULL << (VTD_PAGE_SHIFT + mask));
1095-
1096-
if (WARN_ON_ONCE(!IS_ALIGNED(addr, align)))
1097-
addr = ALIGN_DOWN(addr, align);
1098-
1093+
/*
1094+
* calculate_psi_aligned_address() must be used for addr and size_order
1095+
*/
10991096
desc->qw0 = QI_EIOTLB_PASID(pasid) | QI_EIOTLB_DID(did) |
11001097
QI_EIOTLB_GRAN(QI_GRAN_PSI_PASID) | QI_EIOTLB_TYPE;
11011098
desc->qw1 = QI_EIOTLB_ADDR(addr) | QI_EIOTLB_IH(ih) |
1102-
QI_EIOTLB_AM(mask);
1099+
QI_EIOTLB_AM(size_order);
11031100
}
11041101

11051102
static inline void qi_desc_dev_iotlb_pasid(u16 sid, u16 pfsid, u32 pasid,

0 commit comments

Comments
 (0)