Skip to contentSkip to conversation

iommu/apple-dart: Report TLB flush failures from iotlb_sync_map

PATCH New Yuho Choi 1 participant 1 message Oct 22

Subsystems (2)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 iommu/apple-dart: Report TLB flush failures from iotlb_sync_map

apple_dart_iotlb_sync_map() flushes the TLBs of every DART the domain is attached to after a new mapping has been written. The invalidate_tlb() callbacks return -ETIMEDOUT when the busy bit does not clear in time, but apple_dart_domain_flush_tlb() drops the result and the callback always returns 0, so iommu_map() reports success although the flush did not complete.

Since commit fa4c4507099f ("iommu: Allow .iotlb_sync_map to fail and handle s390's -ENOMEM return"), iommu_map() unmaps the range and fails when .iotlb_sync_map() returns an error. Return the error from apple_dart_domain_flush_tlb(), after still flushing every DART of the domain.

---
The unmap path is not changed, as .iotlb_sync() and .flush_iotlb_all() cannot report a failure.

 drivers/iommu/apple-dart.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/iommu/apple-dart.c +7 -5
index b160fb464c5f..1119769f9f51 100644
@@ -494,9 +494,9 @@ static int apple_dart_hw_reset(struct apple_dart *dart)
 	return dart->hw->invalidate_tlb(&stream_map);
 }
 
-static void apple_dart_domain_flush_tlb(struct apple_dart_domain *domain)
+static int apple_dart_domain_flush_tlb(struct apple_dart_domain *domain)
 {
-	int i, j;
+	int i, j, ret = 0;
 	struct apple_dart_atomic_stream_map *domain_stream_map;
 	struct apple_dart_stream_map stream_map;
 
@@ -506,8 +506,11 @@ static void apple_dart_domain_flush_tlb(struct apple_dart_domain *domain)
 		for (j = 0; j < BITS_TO_LONGS(stream_map.dart->num_streams); j++)
 			stream_map.sidmap[j] = atomic_long_read(&domain_stream_map->sidmap[j]);
 
-		stream_map.dart->hw->invalidate_tlb(&stream_map);
+		/* Flush every DART even if one of them fails. */
+		ret = stream_map.dart->hw->invalidate_tlb(&stream_map) ?: ret;
 	}
+
+	return ret;
 }
 
 static void apple_dart_flush_iotlb_all(struct iommu_domain *domain)
@@ -524,8 +527,7 @@ static void apple_dart_iotlb_sync(struct iommu_domain *domain,
 static int apple_dart_iotlb_sync_map(struct iommu_domain *domain,
 				     unsigned long iova, size_t size)
 {
-	apple_dart_domain_flush_tlb(to_dart_domain(domain));
-	return 0;
+	return apple_dart_domain_flush_tlb(to_dart_domain(domain));
 }
 
 static phys_addr_t apple_dart_iova_to_phys(struct iommu_domain *domain,

base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222

Signature · 1 line
2.43.0