Revert "iommu/amd: Flush not present cache in iommu_map_page"
authorJoerg Roedel <jroedel@suse.de>
Tue, 7 May 2019 07:39:32 +0000 (09:39 +0200)
committerJoerg Roedel <jroedel@suse.de>
Tue, 7 May 2019 07:40:03 +0000 (09:40 +0200)
This reverts commit 1a1079011da32db87e19fcb39e70d082f89da921.

This commit caused a NULL-ptr deference bug and must be
reverted for now.

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

index 23c1a7eebb061c48363c9df669f2b6fd6cbb0234..fde16c5b0a70162f3c2067d16a717e45d34d051c 100644 (file)
@@ -1307,16 +1307,6 @@ static void domain_flush_complete(struct protection_domain *domain)
        }
 }
 
-/* Flush the not present cache if it exists */
-static void domain_flush_np_cache(struct protection_domain *domain,
-               dma_addr_t iova, size_t size)
-{
-       if (unlikely(amd_iommu_np_cache)) {
-               domain_flush_pages(domain, iova, size);
-               domain_flush_complete(domain);
-       }
-}
-
 
 /*
  * This function flushes the DTEs for all devices in domain
@@ -2399,7 +2389,10 @@ static dma_addr_t __map_single(struct device *dev,
        }
        address += offset;
 
-       domain_flush_np_cache(&dma_dom->domain, address, size);
+       if (unlikely(amd_iommu_np_cache)) {
+               domain_flush_pages(&dma_dom->domain, address, size);
+               domain_flush_complete(&dma_dom->domain);
+       }
 
 out:
        return address;
@@ -2578,8 +2571,6 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
                s->dma_length   = s->length;
        }
 
-       domain_flush_np_cache(domain, s->dma_address, s->dma_length);
-
        return nelems;
 
 out_unmap:
@@ -3060,8 +3051,6 @@ static int amd_iommu_map(struct iommu_domain *dom, unsigned long iova,
        ret = iommu_map_page(domain, iova, paddr, page_size, prot, GFP_KERNEL);
        mutex_unlock(&domain->api_lock);
 
-       domain_flush_np_cache(domain, iova, page_size);
-
        return ret;
 }