]> err.no Git - linux-2.6/commitdiff
[POWERPC] Make direct DMA use node local allocations
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Sat, 11 Nov 2006 06:25:16 +0000 (17:25 +1100)
committerPaul Mackerras <paulus@samba.org>
Mon, 4 Dec 2006 09:38:59 +0000 (20:38 +1100)
This patch makes dma_alloc_coherent() use node local allocation when
using the direct DMA ops. The node is obtained from the new device
extension. If no such extension is present, the current node is used.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/dma_64.c

index 1d1dc76606acbb5b229e05fd79805cc65e93dd5f..7b0e754383cf53e47affcf4a46acab9b5264761c 100644 (file)
@@ -120,14 +120,18 @@ unsigned long dma_direct_offset;
 static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
                                       dma_addr_t *dma_handle, gfp_t flag)
 {
+       struct page *page;
        void *ret;
+       int node = dev->archdata.numa_node;
 
        /* TODO: Maybe use the numa node here too ? */
-       ret = (void *)__get_free_pages(flag, get_order(size));
-       if (ret != NULL) {
-               memset(ret, 0, size);
-               *dma_handle = virt_to_abs(ret) | dma_direct_offset;
-       }
+       page = alloc_pages_node(node, flag, get_order(size));
+       if (page == NULL)
+               return NULL;
+       ret = page_address(page);
+       memset(ret, 0, size);
+       *dma_handle = virt_to_abs(ret) | dma_direct_offset;
+
        return ret;
 }