diff options
author | Glauber Costa <gcosta@redhat.com> | 2008-04-08 12:21:02 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-19 13:19:58 -0400 |
commit | d1a079029036881375110f78df47d352e7c28a77 (patch) | |
tree | b7a2ade7ac6d220c81a4bc40becad2fe871e9834 /arch/x86 | |
parent | 71848d687e2a477cb7c68a854d8fdeaa5dff0ffc (diff) |
x86: use numa allocation function in i386
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>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/pci-dma_32.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c index 5ae3470113c6..0d630ae3d910 100644 --- a/arch/x86/kernel/pci-dma_32.c +++ b/arch/x86/kernel/pci-dma_32.c | |||
@@ -48,10 +48,23 @@ static int dma_release_coherent(struct device *dev, int order, void *vaddr) | |||
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | /* Allocate DMA memory on node near device */ | ||
52 | noinline struct page * | ||
53 | dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order) | ||
54 | { | ||
55 | int node; | ||
56 | |||
57 | node = dev_to_node(dev); | ||
58 | |||
59 | return alloc_pages_node(node, gfp, order); | ||
60 | } | ||
61 | |||
51 | void *dma_alloc_coherent(struct device *dev, size_t size, | 62 | void *dma_alloc_coherent(struct device *dev, size_t size, |
52 | dma_addr_t *dma_handle, gfp_t gfp) | 63 | dma_addr_t *dma_handle, gfp_t gfp) |
53 | { | 64 | { |
54 | void *ret = NULL; | 65 | void *ret = NULL; |
66 | struct page *page; | ||
67 | dma_addr_t bus; | ||
55 | int order = get_order(size); | 68 | int order = get_order(size); |
56 | /* ignore region specifiers */ | 69 | /* ignore region specifiers */ |
57 | gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); | 70 | gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); |
@@ -62,12 +75,16 @@ void *dma_alloc_coherent(struct device *dev, size_t size, | |||
62 | if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) | 75 | if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) |
63 | gfp |= GFP_DMA; | 76 | gfp |= GFP_DMA; |
64 | 77 | ||
65 | ret = (void *)__get_free_pages(gfp, order); | 78 | page = dma_alloc_pages(dev, gfp, order); |
79 | if (page == NULL) | ||
80 | return NULL; | ||
81 | |||
82 | ret = page_address(page); | ||
83 | bus = page_to_phys(page); | ||
84 | |||
85 | memset(ret, 0, size); | ||
86 | *dma_handle = bus; | ||
66 | 87 | ||
67 | if (ret != NULL) { | ||
68 | memset(ret, 0, size); | ||
69 | *dma_handle = virt_to_phys(ret); | ||
70 | } | ||
71 | return ret; | 88 | return ret; |
72 | } | 89 | } |
73 | EXPORT_SYMBOL(dma_alloc_coherent); | 90 | EXPORT_SYMBOL(dma_alloc_coherent); |