Skip to content

Commit ac1a348

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Add domain_flush_pasid_iotlb()
The VT-d spec requires to use PASID-based-IOTLB invalidation descriptor to invalidate IOTLB and the paging-structure caches for a first-stage page table. Add a generic helper to do this. RID2PASID is used if the domain has been attached to a physical device, otherwise real PASIDs that the domain has been attached to will be used. The 'real' PASID attachment is handled in the subsequent change. Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Jacob Pan <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 2dcebc7 commit ac1a348

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,18 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
14671467
spin_unlock_irqrestore(&domain->lock, flags);
14681468
}
14691469

1470+
static void domain_flush_pasid_iotlb(struct intel_iommu *iommu,
1471+
struct dmar_domain *domain, u64 addr,
1472+
unsigned long npages, bool ih)
1473+
{
1474+
u16 did = domain_id_iommu(domain, iommu);
1475+
unsigned long flags;
1476+
1477+
spin_lock_irqsave(&domain->lock, flags);
1478+
qi_flush_piotlb(iommu, did, IOMMU_NO_PASID, addr, npages, ih);
1479+
spin_unlock_irqrestore(&domain->lock, flags);
1480+
}
1481+
14701482
static void iommu_flush_iotlb_psi(struct intel_iommu *iommu,
14711483
struct dmar_domain *domain,
14721484
unsigned long pfn, unsigned int pages,
@@ -1484,7 +1496,7 @@ static void iommu_flush_iotlb_psi(struct intel_iommu *iommu,
14841496
ih = 1 << 6;
14851497

14861498
if (domain->use_first_level) {
1487-
qi_flush_piotlb(iommu, did, IOMMU_NO_PASID, addr, pages, ih);
1499+
domain_flush_pasid_iotlb(iommu, domain, addr, pages, ih);
14881500
} else {
14891501
unsigned long bitmask = aligned_pages - 1;
14901502

@@ -1554,7 +1566,7 @@ static void intel_flush_iotlb_all(struct iommu_domain *domain)
15541566
u16 did = domain_id_iommu(dmar_domain, iommu);
15551567

15561568
if (dmar_domain->use_first_level)
1557-
qi_flush_piotlb(iommu, did, IOMMU_NO_PASID, 0, -1, 0);
1569+
domain_flush_pasid_iotlb(iommu, dmar_domain, 0, -1, 0);
15581570
else
15591571
iommu->flush.flush_iotlb(iommu, did, 0, 0,
15601572
DMA_TLB_DSI_FLUSH);

0 commit comments

Comments
 (0)