{
        if (likely(!amd_iommu_np_cache)) {
                __domain_flush_pages(domain, address, size);
+
+               /* Wait until IOMMU TLB and all device IOTLB flushes are complete */
+               amd_iommu_domain_flush_complete(domain);
+
                return;
        }
 
                address += flush_size;
                size -= flush_size;
        }
+
+       /* Wait until IOMMU TLB and all device IOTLB flushes are complete */
+       amd_iommu_domain_flush_complete(domain);
 }
 
 /* Flush the whole IO/TLB for a given protection domain - including PDE */
 
                spin_lock_irqsave(&domain->lock, flags);
                domain_flush_pages(domain, iova, size);
-               amd_iommu_domain_flush_complete(domain);
                spin_unlock_irqrestore(&domain->lock, flags);
        }
 }
        /* Flush the DTE entry */
        device_flush_dte(dev_data);
 
-       /* Flush IOTLB */
+       /* Flush IOTLB and wait for the flushes to finish */
        amd_iommu_domain_flush_tlb_pde(domain);
 
-       /* Wait for the flushes to finish */
-       amd_iommu_domain_flush_complete(domain);
-
        /* decrease reference counters - needs to happen after the flushes */
        domain->dev_iommu[iommu->index] -= 1;
        domain->dev_cnt                 -= 1;
 
        /* Flush domain TLB(s) and wait for completion */
        amd_iommu_domain_flush_tlb_pde(domain);
-       amd_iommu_domain_flush_complete(domain);
 }
 
 /*****************************************************************************
        }
 
        /* Flush IOTLB to mark IOPTE dirty on the next translation(s) */
-       if (domain_flush) {
+       if (domain_flush)
                amd_iommu_domain_flush_tlb_pde(pdomain);
-               amd_iommu_domain_flush_complete(pdomain);
-       }
+
        pdomain->dirty_tracking = enable;
        spin_unlock_irqrestore(&pdomain->lock, flags);
 
 
        spin_lock_irqsave(&dom->lock, flags);
        amd_iommu_domain_flush_tlb_pde(dom);
-       amd_iommu_domain_flush_complete(dom);
        spin_unlock_irqrestore(&dom->lock, flags);
 }
 
 
        spin_lock_irqsave(&dom->lock, flags);
        domain_flush_pages(dom, gather->start, gather->end - gather->start + 1);
-       amd_iommu_domain_flush_complete(dom);
        spin_unlock_irqrestore(&dom->lock, flags);
 }