amd-iommu: enlarge the aperture dynamically
authorJoerg Roedel <joerg.roedel@amd.com>
Tue, 19 May 2009 08:23:15 +0000 (10:23 +0200)
committerJoerg Roedel <joerg.roedel@amd.com>
Thu, 28 May 2009 16:15:57 +0000 (18:15 +0200)
By dynamically increasing the aperture the extended allocator is now
ready for use.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
arch/x86/kernel/amd_iommu.c

index 59ee1b94a7ceb79d13ea78ded2f3f504bbbc9e4e..d129d8feba073697883f98b673c7abe10f2ab0d1 100644 (file)
@@ -1403,10 +1403,26 @@ static dma_addr_t __map_single(struct device *dev,
        if (align)
                align_mask = (1UL << get_order(size)) - 1;
 
+retry:
        address = dma_ops_alloc_addresses(dev, dma_dom, pages, align_mask,
                                          dma_mask);
-       if (unlikely(address == bad_dma_address))
-               goto out;
+       if (unlikely(address == bad_dma_address)) {
+               /*
+                * setting next_address here will let the address
+                * allocator only scan the new allocated range in the
+                * first run. This is a small optimization.
+                */
+               dma_dom->next_address = dma_dom->aperture_size;
+
+               if (alloc_new_range(iommu, dma_dom, false, GFP_ATOMIC))
+                       goto out;
+
+               /*
+                * aperture was sucessfully enlarged by 128 MB, try
+                * allocation again
+                */
+               goto retry;
+       }
 
        start = address;
        for (i = 0; i < pages; ++i) {