Skip to content

Commit

Permalink
x86: use numa allocation function in i386
Browse files Browse the repository at this point in the history
We can do it here to, in the same way x86_64 does.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Glauber Costa authored and Ingo Molnar committed Apr 19, 2008
1 parent 71848d6 commit d1a0790
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions arch/x86/kernel/pci-dma_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,23 @@ static int dma_release_coherent(struct device *dev, int order, void *vaddr)
return 0;
}

/* Allocate DMA memory on node near device */
noinline struct page *
dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
{
int node;

node = dev_to_node(dev);

return alloc_pages_node(node, gfp, order);
}

void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp)
{
void *ret = NULL;
struct page *page;
dma_addr_t bus;
int order = get_order(size);
/* ignore region specifiers */
gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
Expand All @@ -62,12 +75,16 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
gfp |= GFP_DMA;

ret = (void *)__get_free_pages(gfp, order);
page = dma_alloc_pages(dev, gfp, order);
if (page == NULL)
return NULL;

ret = page_address(page);
bus = page_to_phys(page);

memset(ret, 0, size);
*dma_handle = bus;

if (ret != NULL) {
memset(ret, 0, size);
*dma_handle = virt_to_phys(ret);
}
return ret;
}
EXPORT_SYMBOL(dma_alloc_coherent);
Expand Down

0 comments on commit d1a0790

Please sign in to comment.