Commit 7bfa5bd2 authored by Joerg Roedel's avatar Joerg Roedel

iommu/amd: Build io page-tables with cmpxchg64

This allows to build up the page-tables without holding any
locks. As a consequence it removes the need to pre-populate
dma_ops page-tables.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 266a3bd2
...@@ -1206,11 +1206,21 @@ static u64 *alloc_pte(struct protection_domain *domain, ...@@ -1206,11 +1206,21 @@ static u64 *alloc_pte(struct protection_domain *domain,
end_lvl = PAGE_SIZE_LEVEL(page_size); end_lvl = PAGE_SIZE_LEVEL(page_size);
while (level > end_lvl) { while (level > end_lvl) {
if (!IOMMU_PTE_PRESENT(*pte)) { u64 __pte, __npte;
__pte = *pte;
if (!IOMMU_PTE_PRESENT(__pte)) {
page = (u64 *)get_zeroed_page(gfp); page = (u64 *)get_zeroed_page(gfp);
if (!page) if (!page)
return NULL; return NULL;
*pte = PM_LEVEL_PDE(level, virt_to_phys(page));
__npte = PM_LEVEL_PDE(level, virt_to_phys(page));
if (cmpxchg64(pte, __pte, __npte)) {
free_page((unsigned long)page);
continue;
}
} }
/* No level skipping support yet */ /* No level skipping support yet */
...@@ -1607,7 +1617,7 @@ static unsigned long dma_ops_alloc_addresses(struct device *dev, ...@@ -1607,7 +1617,7 @@ static unsigned long dma_ops_alloc_addresses(struct device *dev,
address = dma_ops_area_alloc(dev, dom, pages, address = dma_ops_area_alloc(dev, dom, pages,
align_mask, dma_mask); align_mask, dma_mask);
if (address == -1 && alloc_new_range(dom, true, GFP_ATOMIC)) if (address == -1 && alloc_new_range(dom, false, GFP_ATOMIC))
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment