Skip to content

Commit d7ac677

Browse files
LuBaolugregkh
authored andcommitted
iommu/vt-d: Assign devtlb cache tag on ATS enablement
commit 25b1b75 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5af35e9 commit d7ac677

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

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
@@ -3819,8 +3819,17 @@ static void intel_iommu_probe_finalize(struct device *dev)
38193819
!pci_enable_pasid(to_pci_dev(dev), info->pasid_supported & ~1))
38203820
info->pasid_enabled = 1;
38213821

3822-
if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev))
3822+
if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
38233823
iommu_enable_pci_ats(info);
3824+
/* Assign a DEVTLB cache tag to the default domain. */
3825+
if (info->ats_enabled && info->domain) {
3826+
u16 did = domain_id_iommu(info->domain, iommu);
3827+
3828+
if (cache_tag_assign(info->domain, did, dev,
3829+
IOMMU_NO_PASID, CACHE_TAG_DEVTLB))
3830+
iommu_disable_pci_ats(info);
3831+
}
3832+
}
38243833
iommu_enable_pci_pri(info);
38253834
}
38263835

drivers/iommu/intel/iommu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,8 @@ struct cache_tag {
12771277
unsigned int users;
12781278
};
12791279

1280+
int cache_tag_assign(struct dmar_domain *domain, u16 did, struct device *dev,
1281+
ioasid_t pasid, enum cache_tag_type type);
12801282
int cache_tag_assign_domain(struct dmar_domain *domain,
12811283
struct device *dev, ioasid_t pasid);
12821284
void cache_tag_unassign_domain(struct dmar_domain *domain,

0 commit comments

Comments
 (0)