提交 5cd3f2e9 编写于 作者: T Tom Murphy 提交者: Joerg Roedel

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: NTom Murphy <murphyt7@tcd.ie>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 5c90501a
......@@ -1307,6 +1307,16 @@ 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
......@@ -2389,10 +2399,7 @@ static dma_addr_t __map_single(struct device *dev,
}
address += offset;
if (unlikely(amd_iommu_np_cache)) {
domain_flush_pages(&dma_dom->domain, address, size);
domain_flush_complete(&dma_dom->domain);
}
domain_flush_np_cache(&dma_dom->domain, address, size);
out:
return address;
......@@ -2571,6 +2578,9 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
s->dma_length = s->length;
}
if (s)
domain_flush_np_cache(domain, s->dma_address, s->dma_length);
return nelems;
out_unmap:
......@@ -3051,6 +3061,8 @@ 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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册