aboutsummaryrefslogtreecommitdiffstats
path: root/mm/dmapool.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/dmapool.c')
-rw-r--r--mm/dmapool.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/mm/dmapool.c b/mm/dmapool.c
index 744d541df866..e2ea4543abb4 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -1,19 +1,39 @@
1/*
2 * DMA Pool allocator
3 *
4 * Copyright 2001 David Brownell
5 * Copyright 2007 Intel Corporation
6 * Author: Matthew Wilcox <willy@linux.intel.com>
7 *
8 * This software may be redistributed and/or modified under the terms of
9 * the GNU General Public License ("GPL") version 2 as published by the
10 * Free Software Foundation.
11 *
12 * This allocator returns small blocks of a given size which are DMA-able by
13 * the given device. It uses the dma_alloc_coherent page allocator to get
14 * new pages, then splits them up into blocks of the required size.
15 * Many older drivers still have their own code to do this.
16 *
17 * The current design of this allocator is fairly simple. The pool is
18 * represented by the 'struct dma_pool' which keeps a doubly-linked list of
19 * allocated pages. Each page in the page_list is split into blocks of at
20 * least 'size' bytes.
21 */
1 22
2#include <linux/device.h> 23#include <linux/device.h>
3#include <linux/mm.h>
4#include <asm/io.h> /* Needed for i386 to build */
5#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
6#include <linux/dmapool.h> 25#include <linux/dmapool.h>
7#include <linux/slab.h> 26#include <linux/kernel.h>
27#include <linux/list.h>
8#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/mutex.h>
9#include <linux/poison.h> 30#include <linux/poison.h>
10#include <linux/sched.h> 31#include <linux/sched.h>
11 32#include <linux/slab.h>
12/* 33#include <linux/spinlock.h>
13 * Pool allocator ... wraps the dma_alloc_coherent page allocator, so 34#include <linux/string.h>
14 * small blocks are easily used by drivers for bus mastering controllers. 35#include <linux/types.h>
15 * This should probably be sharing the guts of the slab allocator. 36#include <linux/wait.h>
16 */
17 37
18struct dma_pool { /* the pool */ 38struct dma_pool { /* the pool */
19 struct list_head page_list; 39 struct list_head page_list;
@@ -265,7 +285,7 @@ EXPORT_SYMBOL(dma_pool_destroy);
265 * 285 *
266 * This returns the kernel virtual address of a currently unused block, 286 * This returns the kernel virtual address of a currently unused block,
267 * and reports its dma address through the handle. 287 * and reports its dma address through the handle.
268 * If such a memory block can't be allocated, null is returned. 288 * If such a memory block can't be allocated, %NULL is returned.
269 */ 289 */
270void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, 290void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
271 dma_addr_t *handle) 291 dma_addr_t *handle)