iommu/amd: Flush the IOMMU TLB before the addresses are freed
authorJoerg Roedel <jroedel@suse.de>
Mon, 21 Dec 2015 12:23:59 +0000 (13:23 +0100)
committerJoerg Roedel <jroedel@suse.de>
Mon, 28 Dec 2015 16:18:50 +0000 (17:18 +0100)
This allows to keep the bitmap_lock only for a very short
period of time.

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

index 42c0a81ba9b37a33a38f9c25cc38088516d02229..69021ec79da99d30606951cfe04ffe63ef69a80d 100644 (file)
@@ -2527,14 +2527,14 @@ static void __unmap_single(struct dma_ops_domain *dma_dom,
                start += PAGE_SIZE;
        }
 
-       SUB_STATS_COUNTER(alloced_io_mem, size);
-
-       dma_ops_free_addresses(dma_dom, dma_addr, pages);
-
        if (amd_iommu_unmap_flush || dma_dom->need_flush) {
                domain_flush_pages(&dma_dom->domain, flush_addr, size);
                dma_dom->need_flush = false;
        }
+
+       SUB_STATS_COUNTER(alloced_io_mem, size);
+
+       dma_ops_free_addresses(dma_dom, dma_addr, pages);
 }
 
 /*