diff options
author | Tom Murphy <tmurphy@arista.com> | 2019-04-28 19:47:02 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2019-05-03 11:27:42 -0400 |
commit | 1a1079011da32db87e19fcb39e70d082f89da921 (patch) | |
tree | 00654600d0d5459bb68ffc9980bc690bf32713a1 | |
parent | c805b428f206a9097ef8c905d8b7e40bc411100e (diff) |
iommu/amd: Flush not present cache in iommu_map_page
check if there is a not-present cache present and flush it if there is.
Signed-off-by: Tom Murphy <tmurphy@arista.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r-- | drivers/iommu/amd_iommu.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 3e0696cf965c..bc98de5fa867 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -1307,6 +1307,16 @@ static void domain_flush_complete(struct protection_domain *domain) | |||
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | /* Flush the not present cache if it exists */ | ||
1311 | static void domain_flush_np_cache(struct protection_domain *domain, | ||
1312 | dma_addr_t iova, size_t size) | ||
1313 | { | ||
1314 | if (unlikely(amd_iommu_np_cache)) { | ||
1315 | domain_flush_pages(domain, iova, size); | ||
1316 | domain_flush_complete(domain); | ||
1317 | } | ||
1318 | } | ||
1319 | |||
1310 | 1320 | ||
1311 | /* | 1321 | /* |
1312 | * This function flushes the DTEs for all devices in domain | 1322 | * This function flushes the DTEs for all devices in domain |
@@ -2389,10 +2399,7 @@ static dma_addr_t __map_single(struct device *dev, | |||
2389 | } | 2399 | } |
2390 | address += offset; | 2400 | address += offset; |
2391 | 2401 | ||
2392 | if (unlikely(amd_iommu_np_cache)) { | 2402 | domain_flush_np_cache(&dma_dom->domain, address, size); |
2393 | domain_flush_pages(&dma_dom->domain, address, size); | ||
2394 | domain_flush_complete(&dma_dom->domain); | ||
2395 | } | ||
2396 | 2403 | ||
2397 | out: | 2404 | out: |
2398 | return address; | 2405 | return address; |
@@ -2548,6 +2555,8 @@ static int map_sg(struct device *dev, struct scatterlist *sglist, | |||
2548 | s->dma_length = s->length; | 2555 | s->dma_length = s->length; |
2549 | } | 2556 | } |
2550 | 2557 | ||
2558 | domain_flush_np_cache(domain, s->dma_address, s->dma_length); | ||
2559 | |||
2551 | return nelems; | 2560 | return nelems; |
2552 | 2561 | ||
2553 | out_unmap: | 2562 | out_unmap: |
@@ -3005,6 +3014,8 @@ static int amd_iommu_map(struct iommu_domain *dom, unsigned long iova, | |||
3005 | ret = iommu_map_page(domain, iova, paddr, page_size, prot, GFP_KERNEL); | 3014 | ret = iommu_map_page(domain, iova, paddr, page_size, prot, GFP_KERNEL); |
3006 | mutex_unlock(&domain->api_lock); | 3015 | mutex_unlock(&domain->api_lock); |
3007 | 3016 | ||
3017 | domain_flush_np_cache(domain, iova, page_size); | ||
3018 | |||
3008 | return ret; | 3019 | return ret; |
3009 | } | 3020 | } |
3010 | 3021 | ||