Skip to content

Commit 25b1b75

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Assign devtlb cache tag on ATS enablement
Commit <4f1492efb495> ("iommu/vt-d: Revert ATS timing change to fix boot failure") placed the enabling of ATS in the probe_finalize callback. This occurs after the default domain attachment, which is when the ATS cache tag is assigned. Consequently, the device TLB cache tag is missed when the domain is attached, leading to the device TLB not being invalidated in the iommu_unmap paths. Fix this by assigning the CACHE_TAG_DEVTLB cache tag when ATS is enabled. Fixes: 4f1492e ("iommu/vt-d: Revert ATS timing change to fix boot failure") Cc: [email protected] Suggested-by: Kevin Tian <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Tested-by: Shuicheng Lin <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 62e062a commit 25b1b75

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

drivers/iommu/intel/cache.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ static bool cache_tage_match(struct cache_tag *tag, u16 domain_id,
4040
}
4141

4242
/* Assign a cache tag with specified type to domain. */
43-
static int cache_tag_assign(struct dmar_domain *domain, u16 did,
44-
struct device *dev, ioasid_t pasid,
45-
enum cache_tag_type type)
43+
int cache_tag_assign(struct dmar_domain *domain, u16 did, struct device *dev,
44+
ioasid_t pasid, enum cache_tag_type type)
4645
{
4746
struct device_domain_info *info = dev_iommu_priv_get(dev);
4847
struct intel_iommu *iommu = info->iommu;

drivers/iommu/intel/iommu.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3780,8 +3780,17 @@ static void intel_iommu_probe_finalize(struct device *dev)
37803780
!pci_enable_pasid(to_pci_dev(dev), info->pasid_supported & ~1))
37813781
info->pasid_enabled = 1;
37823782

3783-
if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev))
3783+
if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
37843784
iommu_enable_pci_ats(info);
3785+
/* Assign a DEVTLB cache tag to the default domain. */
3786+
if (info->ats_enabled && info->domain) {
3787+
u16 did = domain_id_iommu(info->domain, iommu);
3788+
3789+
if (cache_tag_assign(info->domain, did, dev,
3790+
IOMMU_NO_PASID, CACHE_TAG_DEVTLB))
3791+
iommu_disable_pci_ats(info);
3792+
}
3793+
}
37853794
iommu_enable_pci_pri(info);
37863795
}
37873796

drivers/iommu/intel/iommu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,8 @@ struct cache_tag {
12891289
unsigned int users;
12901290
};
12911291

1292+
int cache_tag_assign(struct dmar_domain *domain, u16 did, struct device *dev,
1293+
ioasid_t pasid, enum cache_tag_type type);
12921294
int cache_tag_assign_domain(struct dmar_domain *domain,
12931295
struct device *dev, ioasid_t pasid);
12941296
void cache_tag_unassign_domain(struct dmar_domain *domain,

0 commit comments

Comments
 (0)