Thread (34 messages) 34 messages, 2 authors, 2006-11-07

[PATCH 26/31] powerpc: Make direct DMA use node local allocations

flat view
STALE7294d

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2006-11-07 07:22:59
Subsystem: the rest · Maintainer: Linus Torvalds

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>

 arch/powerpc/kernel/dma_64.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Index: linux-cell/arch/powerpc/kernel/dma_64.c
===================================================================
--- linux-cell.orig/arch/powerpc/kernel/dma_64.c	2006-11-07 16:59:46.000000000 +1100
+++ linux-cell/arch/powerpc/kernel/dma_64.c	2006-11-07 17:00:01.000000000 +1100
@@ -143,14 +143,22 @@ 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 device_ext *dext = device_get_ext(dev);
+	struct page *page;
 	void *ret;
+	int node = -1;
+
+	if (dext != NULL)
+		node = dext->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;
 }
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help