dmapool.c (3eb66e91a25497065c5322b1268cbc3953642227) | dmapool.c (a862f68a8b360086f248cbc3606029441b5f5197) |
---|---|
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 --- 100 unchanged lines hidden (view full) --- 109 110/** 111 * dma_pool_create - Creates a pool of consistent memory blocks, for dma. 112 * @name: name of pool, for diagnostics 113 * @dev: device that will be doing the DMA 114 * @size: size of the blocks in this pool. 115 * @align: alignment requirement for blocks; must be a power of two 116 * @boundary: returned blocks won't cross this power of two boundary | 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 --- 100 unchanged lines hidden (view full) --- 109 110/** 111 * dma_pool_create - Creates a pool of consistent memory blocks, for dma. 112 * @name: name of pool, for diagnostics 113 * @dev: device that will be doing the DMA 114 * @size: size of the blocks in this pool. 115 * @align: alignment requirement for blocks; must be a power of two 116 * @boundary: returned blocks won't cross this power of two boundary |
117 * Context: !in_interrupt() | 117 * Context: not in_interrupt() |
118 * | 118 * |
119 * Returns a dma allocation pool with the requested characteristics, or 120 * null if one can't be created. Given one of these pools, dma_pool_alloc() | 119 * Given one of these pools, dma_pool_alloc() |
121 * may be used to allocate memory. Such memory will all have "consistent" 122 * DMA mappings, accessible by the device and its driver without using 123 * cache flushing primitives. The actual size of blocks allocated may be 124 * larger than requested because of alignment. 125 * 126 * If @boundary is nonzero, objects returned from dma_pool_alloc() won't 127 * cross that size boundary. This is useful for devices which have 128 * addressing restrictions on individual DMA transfers, such as not crossing 129 * boundaries of 4KBytes. | 120 * may be used to allocate memory. Such memory will all have "consistent" 121 * DMA mappings, accessible by the device and its driver without using 122 * cache flushing primitives. The actual size of blocks allocated may be 123 * larger than requested because of alignment. 124 * 125 * If @boundary is nonzero, objects returned from dma_pool_alloc() won't 126 * cross that size boundary. This is useful for devices which have 127 * addressing restrictions on individual DMA transfers, such as not crossing 128 * boundaries of 4KBytes. |
129 * 130 * Return: a dma allocation pool with the requested characteristics, or 131 * %NULL if one can't be created. |
|
130 */ 131struct dma_pool *dma_pool_create(const char *name, struct device *dev, 132 size_t size, size_t align, size_t boundary) 133{ 134 struct dma_pool *retval; 135 size_t allocation; 136 bool empty = false; 137 --- 170 unchanged lines hidden (view full) --- 308EXPORT_SYMBOL(dma_pool_destroy); 309 310/** 311 * dma_pool_alloc - get a block of consistent memory 312 * @pool: dma pool that will produce the block 313 * @mem_flags: GFP_* bitmask 314 * @handle: pointer to dma address of block 315 * | 132 */ 133struct dma_pool *dma_pool_create(const char *name, struct device *dev, 134 size_t size, size_t align, size_t boundary) 135{ 136 struct dma_pool *retval; 137 size_t allocation; 138 bool empty = false; 139 --- 170 unchanged lines hidden (view full) --- 310EXPORT_SYMBOL(dma_pool_destroy); 311 312/** 313 * dma_pool_alloc - get a block of consistent memory 314 * @pool: dma pool that will produce the block 315 * @mem_flags: GFP_* bitmask 316 * @handle: pointer to dma address of block 317 * |
316 * This returns the kernel virtual address of a currently unused block, | 318 * Return: the kernel virtual address of a currently unused block, |
317 * and reports its dma address through the handle. 318 * If such a memory block can't be allocated, %NULL is returned. 319 */ 320void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, 321 dma_addr_t *handle) 322{ 323 unsigned long flags; 324 struct dma_page *page; --- 168 unchanged lines hidden (view full) --- 493 * @name: name of pool, for diagnostics 494 * @dev: device that will be doing the DMA 495 * @size: size of the blocks in this pool. 496 * @align: alignment requirement for blocks; must be a power of two 497 * @allocation: returned blocks won't cross this boundary (or zero) 498 * 499 * Managed dma_pool_create(). DMA pool created with this function is 500 * automatically destroyed on driver detach. | 319 * and reports its dma address through the handle. 320 * If such a memory block can't be allocated, %NULL is returned. 321 */ 322void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, 323 dma_addr_t *handle) 324{ 325 unsigned long flags; 326 struct dma_page *page; --- 168 unchanged lines hidden (view full) --- 495 * @name: name of pool, for diagnostics 496 * @dev: device that will be doing the DMA 497 * @size: size of the blocks in this pool. 498 * @align: alignment requirement for blocks; must be a power of two 499 * @allocation: returned blocks won't cross this boundary (or zero) 500 * 501 * Managed dma_pool_create(). DMA pool created with this function is 502 * automatically destroyed on driver detach. |
503 * 504 * Return: a managed dma allocation pool with the requested 505 * characteristics, or %NULL if one can't be created. |
|
501 */ 502struct dma_pool *dmam_pool_create(const char *name, struct device *dev, 503 size_t size, size_t align, size_t allocation) 504{ 505 struct dma_pool **ptr, *pool; 506 507 ptr = devres_alloc(dmam_pool_release, sizeof(*ptr), GFP_KERNEL); 508 if (!ptr) --- 25 unchanged lines hidden --- | 506 */ 507struct dma_pool *dmam_pool_create(const char *name, struct device *dev, 508 size_t size, size_t align, size_t allocation) 509{ 510 struct dma_pool **ptr, *pool; 511 512 ptr = devres_alloc(dmam_pool_release, sizeof(*ptr), GFP_KERNEL); 513 if (!ptr) --- 25 unchanged lines hidden --- |