Skip to contentSkip to conversation

iommu/amd: fix the flush IOTLB issue when do detach

PATCH New Jesse Zhang 1 participant 1 message Jul 25, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: fix the flush IOTLB issue when do detach

From: Jesse Zhang <[email protected]>

[WHY] After invalidating a domain's page tables, then we need to flush the IOTLB of the device in the domain. [HOW] so we need clear the IOTLB first, then delete the device list.
otherwise, that will not clear the IOTLB by the function of amd_iommu_domain_flush_tlb_pde

---
 drivers/iommu/amd/iommu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/iommu/amd/iommu.c +6 -6
index dc1ec6849775..6e4c43e25c27 100644
@@ -1699,12 +1699,6 @@ static void do_detach(struct iommu_dev_data *dev_data)
 	if (!iommu)
 		return;
 
-	/* Update data structures */
-	dev_data->domain = NULL;
-	list_del(&dev_data->list);
-	clear_dte_entry(iommu, dev_data->devid);
-	clone_aliases(iommu, dev_data->dev);
-
 	/* Flush the DTE entry */
 	device_flush_dte(dev_data);
 
@@ -1714,6 +1708,12 @@ static void do_detach(struct iommu_dev_data *dev_data)
 	/* Wait for the flushes to finish */
 	amd_iommu_domain_flush_complete(domain);
 
+	/* Update data structures */
+	dev_data->domain = NULL;
+	list_del(&dev_data->list);
+	clear_dte_entry(iommu, dev_data->devid);
+	clone_aliases(iommu, dev_data->dev);
+
 	/* decrease reference counters - needs to happen after the flushes */
 	domain->dev_iommu[iommu->index] -= 1;
 	domain->dev_cnt                 -= 1;
Signature · 1 line
2.25.1