Skip to contentSkip to conversation

iommu/amd: Free already flushed ring-buffer entries before full-check

PATCH New Joerg Roedel 1 participant 1 message Jun 22, 2017 IOMMU

lore
Share & tools
lore

Joerg Roedel

author maintainer
#0 lore raw

PATCH 1/1 iommu/amd: Free already flushed ring-buffer entries before full-check

From: Joerg Roedel <[email protected]>

To benefit from IOTLB flushes on other CPUs we have to free the already flushed IOVAs from the ring-buffer before we do the queue_ring_full() check.

---
 drivers/iommu/amd_iommu.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/iommu/amd_iommu.c +9 -3
index 623ab53..34a6cac 100644
@@ -1883,14 +1883,20 @@ static void queue_add(struct dma_ops_domain *dom,
 	spin_lock_irqsave(&queue->lock, flags);
 
 	/*
+	 * First remove the enries from the ring-buffer that are already
+	 * flushed to make the below queue_ring_full() check less likely
+	 */
+	queue_ring_free_flushed(dom, queue);
+
+	/*
 	 * When ring-queue is full, flush the entries from the IOTLB so
 	 * that we can free all entries with queue_ring_free_flushed()
 	 * below.
 	 */
-	if (queue_ring_full(queue))
+	if (queue_ring_full(queue)) {
 		dma_ops_domain_flush_tlb(dom);
-
-	queue_ring_free_flushed(dom, queue);
+		queue_ring_free_flushed(dom, queue);
+	}
 
 	idx = queue_ring_add(queue);
 
Signature · 1 line
2.7.4