Commit 266a3bd2 authored by Joerg Roedel's avatar Joerg Roedel

iommu/amd: Allocate new aperture ranges in dma_ops_alloc_addresses

It really belongs there and not in __map_single.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 4eeca8c5
...@@ -1597,13 +1597,19 @@ static unsigned long dma_ops_alloc_addresses(struct device *dev, ...@@ -1597,13 +1597,19 @@ static unsigned long dma_ops_alloc_addresses(struct device *dev,
unsigned long align_mask, unsigned long align_mask,
u64 dma_mask) u64 dma_mask)
{ {
unsigned long address; unsigned long address = -1;
#ifdef CONFIG_IOMMU_STRESS #ifdef CONFIG_IOMMU_STRESS
dom->next_index = 0; dom->next_index = 0;
#endif #endif
address = dma_ops_area_alloc(dev, dom, pages, align_mask, dma_mask); while (address == -1) {
address = dma_ops_area_alloc(dev, dom, pages,
align_mask, dma_mask);
if (address == -1 && alloc_new_range(dom, true, GFP_ATOMIC))
break;
}
if (unlikely(address == -1)) if (unlikely(address == -1))
address = DMA_ERROR_CODE; address = DMA_ERROR_CODE;
...@@ -2460,26 +2466,11 @@ static dma_addr_t __map_single(struct device *dev, ...@@ -2460,26 +2466,11 @@ static dma_addr_t __map_single(struct device *dev,
if (align) if (align)
align_mask = (1UL << get_order(size)) - 1; align_mask = (1UL << get_order(size)) - 1;
retry:
address = dma_ops_alloc_addresses(dev, dma_dom, pages, align_mask, address = dma_ops_alloc_addresses(dev, dma_dom, pages, align_mask,
dma_mask); dma_mask);
if (unlikely(address == DMA_ERROR_CODE)) {
if (alloc_new_range(dma_dom, false, GFP_ATOMIC))
goto out;
/*
* setting next_index here will let the address
* allocator only scan the new allocated range in the
* first run. This is a small optimization.
*/
dma_dom->next_index = dma_dom->aperture_size >> APERTURE_RANGE_SHIFT;
/* if (address == DMA_ERROR_CODE)
* aperture was successfully enlarged by 128 MB, try goto out;
* allocation again
*/
goto retry;
}
start = address; start = address;
for (i = 0; i < pages; ++i) { for (i = 0; i < pages; ++i) {
......
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