]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
iommu/amd: Free already flushed ring-buffer entries before full-check
authorJoerg Roedel <jroedel@suse.de>
Thu, 22 Jun 2017 10:16:33 +0000 (12:16 +0200)
committerJoerg Roedel <jroedel@suse.de>
Thu, 22 Jun 2017 10:54:22 +0000 (12:54 +0200)
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.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd_iommu.c

index 95ee360a519910b2dd86c31ac39618bc96a2ea38..c618c26a3b334189ad2e6bf9c9799e86e09e2268 100644 (file)
@@ -1910,15 +1910,21 @@ static void queue_add(struct dma_ops_domain *dom,
        queue = get_cpu_ptr(dom->flush_queue);
        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);