Skip to content

Commit 041be27

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Fix missed device TLB cache tag
When a domain is attached to a device, the required cache tags are assigned to the domain so that the related caches can be flushed whenever it is needed. The device TLB cache tag is created based on whether the ats_enabled field of the device's iommu data is set. This creates an ordered dependency between cache tag assignment and ATS enabling. The device TLB cache tag would not be created if device's ATS is enabled after the cache tag assignment. This causes devices with PCI ATS support to malfunction. The ATS control is exclusively owned by the iommu driver. Hence, move cache_tag_assign_domain() after PCI ATS enabling to make sure that the device TLB cache tag is created for the domain. Fixes: 3b1d9e2 ("iommu/vt-d: Add cache tag assignment interface") Signed-off-by: Lu Baolu <[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 c362f32 commit 041be27

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,12 +2114,6 @@ static int dmar_domain_attach_device(struct dmar_domain *domain,
21142114
if (ret)
21152115
return ret;
21162116

2117-
ret = cache_tag_assign_domain(domain, dev, IOMMU_NO_PASID);
2118-
if (ret) {
2119-
domain_detach_iommu(domain, iommu);
2120-
return ret;
2121-
}
2122-
21232117
info->domain = domain;
21242118
spin_lock_irqsave(&domain->lock, flags);
21252119
list_add(&info->link, &domain->devices);
@@ -2137,15 +2131,21 @@ static int dmar_domain_attach_device(struct dmar_domain *domain,
21372131
else
21382132
ret = intel_pasid_setup_second_level(iommu, domain, dev, IOMMU_NO_PASID);
21392133

2140-
if (ret) {
2141-
device_block_translation(dev);
2142-
return ret;
2143-
}
2134+
if (ret)
2135+
goto out_block_translation;
21442136

21452137
if (sm_supported(info->iommu) || !domain_type_is_si(info->domain))
21462138
iommu_enable_pci_caps(info);
21472139

2140+
ret = cache_tag_assign_domain(domain, dev, IOMMU_NO_PASID);
2141+
if (ret)
2142+
goto out_block_translation;
2143+
21482144
return 0;
2145+
2146+
out_block_translation:
2147+
device_block_translation(dev);
2148+
return ret;
21492149
}
21502150

21512151
/**

0 commit comments

Comments
 (0)