Lines Matching defs:pool

16  * available.  If new memory is added to the pool a lock has to be
145 * gen_pool_create - create a new special memory pool
147 * @nid: node id of the node the pool structure should be allocated on, or -1
149 * Create a new special memory pool that can be used to manage special purpose
154 struct gen_pool *pool;
156 pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid);
157 if (pool != NULL) {
158 spin_lock_init(&pool->lock);
159 INIT_LIST_HEAD(&pool->chunks);
160 pool->min_alloc_order = min_alloc_order;
161 pool->algo = gen_pool_first_fit;
162 pool->data = NULL;
163 pool->name = NULL;
165 return pool;
170 * gen_pool_add_owner- add a new chunk of special memory to the pool
171 * @pool: pool to add new memory chunk to
172 * @virt: virtual starting address of memory chunk to add to pool
173 * @phys: physical starting address of memory chunk to add to pool
174 * @size: size in bytes of the memory chunk to add to pool
179 * Add a new chunk of special memory to the specified pool.
183 int gen_pool_add_owner(struct gen_pool *pool, unsigned long virt, phys_addr_t phys,
187 unsigned long nbits = size >> pool->min_alloc_order;
201 spin_lock(&pool->lock);
202 list_add_rcu(&chunk->next_chunk, &pool->chunks);
203 spin_unlock(&pool->lock);
211 * @pool: pool to allocate from
216 phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long addr)
222 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
235 * gen_pool_destroy - destroy a special memory pool
236 * @pool: pool to destroy
238 * Destroy the specified special memory pool. Verifies that there are no
241 void gen_pool_destroy(struct gen_pool *pool)
245 int order = pool->min_alloc_order;
248 list_for_each_safe(_chunk, _next_chunk, &pool->chunks) {
258 kfree_const(pool->name);
259 kfree(pool);
264 * gen_pool_alloc_algo_owner - allocate special memory from the pool
265 * @pool: pool to allocate from
266 * @size: number of bytes to allocate from the pool
271 * Allocate the requested number of bytes from the specified pool.
272 * Uses the pool allocation function (with first-fit algorithm by default).
276 unsigned long gen_pool_alloc_algo_owner(struct gen_pool *pool, size_t size,
281 int order = pool->min_alloc_order;
296 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
304 nbits, data, pool, chunk->start_addr);
328 * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage
329 * @pool: pool to allocate from
330 * @size: number of bytes to allocate from the pool
333 * Allocate the requested number of bytes from the specified pool.
334 * Uses the pool allocation function (with first-fit algorithm by default).
340 void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma)
342 return gen_pool_dma_alloc_algo(pool, size, dma, pool->algo, pool->data);
347 * gen_pool_dma_alloc_algo - allocate special memory from the pool for DMA
348 * usage with the given pool algorithm
349 * @pool: pool to allocate from
350 * @size: number of bytes to allocate from the pool
355 * Allocate the requested number of bytes from the specified pool. Uses the
356 * given pool allocation function. Can not be used in NMI handler on
361 void *gen_pool_dma_alloc_algo(struct gen_pool *pool, size_t size,
366 if (!pool)
369 vaddr = gen_pool_alloc_algo(pool, size, algo, data);
374 *dma = gen_pool_virt_to_phys(pool, vaddr);
381 * gen_pool_dma_alloc_align - allocate special memory from the pool for DMA
383 * @pool: pool to allocate from
384 * @size: number of bytes to allocate from the pool
388 * Allocate the requested number bytes from the specified pool, with the given
394 void *gen_pool_dma_alloc_align(struct gen_pool *pool, size_t size,
399 return gen_pool_dma_alloc_algo(pool, size, dma,
405 * gen_pool_dma_zalloc - allocate special zeroed memory from the pool for
407 * @pool: pool to allocate from
408 * @size: number of bytes to allocate from the pool
411 * Allocate the requested number of zeroed bytes from the specified pool.
412 * Uses the pool allocation function (with first-fit algorithm by default).
418 void *gen_pool_dma_zalloc(struct gen_pool *pool, size_t size, dma_addr_t *dma)
420 return gen_pool_dma_zalloc_algo(pool, size, dma, pool->algo, pool->data);
425 * gen_pool_dma_zalloc_algo - allocate special zeroed memory from the pool for
426 * DMA usage with the given pool algorithm
427 * @pool: pool to allocate from
428 * @size: number of bytes to allocate from the pool
433 * Allocate the requested number of zeroed bytes from the specified pool. Uses
434 * the given pool allocation function. Can not be used in NMI handler on
439 void *gen_pool_dma_zalloc_algo(struct gen_pool *pool, size_t size,
442 void *vaddr = gen_pool_dma_alloc_algo(pool, size, dma, algo, data);
452 * gen_pool_dma_zalloc_align - allocate special zeroed memory from the pool for
454 * @pool: pool to allocate from
455 * @size: number of bytes to allocate from the pool
459 * Allocate the requested number of zeroed bytes from the specified pool,
465 void *gen_pool_dma_zalloc_align(struct gen_pool *pool, size_t size,
470 return gen_pool_dma_zalloc_algo(pool, size, dma,
476 * gen_pool_free_owner - free allocated special memory back to the pool
477 * @pool: pool to free to
478 * @addr: starting address of memory to free back to pool
483 * pool. Can not be used in NMI handler on architectures without
486 void gen_pool_free_owner(struct gen_pool *pool, unsigned long addr, size_t size,
490 int order = pool->min_alloc_order;
502 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
522 * gen_pool_for_each_chunk - call func for every chunk of generic memory pool
523 * @pool: the generic memory pool
527 * Call @func for every chunk of generic memory pool. The @func is
530 void gen_pool_for_each_chunk(struct gen_pool *pool,
531 void (*func)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data),
537 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk)
538 func(pool, chunk, data);
544 * gen_pool_has_addr - checks if an address falls within the range of a pool
545 * @pool: the generic memory pool
549 * Check if the range of addresses falls within the specified pool. Returns
550 * true if the entire range is contained in the pool and false otherwise.
552 bool gen_pool_has_addr(struct gen_pool *pool, unsigned long start,
560 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) {
574 * gen_pool_avail - get available free space of the pool
575 * @pool: pool to get available free space
577 * Return available free space of the specified pool.
579 size_t gen_pool_avail(struct gen_pool *pool)
585 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk)
593 * gen_pool_size - get size in bytes of memory managed by the pool
594 * @pool: pool to get size
596 * Return size in bytes of memory managed by the pool.
598 size_t gen_pool_size(struct gen_pool *pool)
604 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk)
613 * @pool: pool to change allocation algorithm
617 * Call @algo for each memory allocation in the pool.
621 void gen_pool_set_algo(struct gen_pool *pool, genpool_algo_t algo, void *data)
625 pool->algo = algo;
626 if (!pool->algo)
627 pool->algo = gen_pool_first_fit;
629 pool->data = data;
643 * @pool: pool to find the fit region memory from
647 struct gen_pool *pool, unsigned long start_addr)
661 * @pool: pool to get order from
665 struct gen_pool *pool, unsigned long start_addr)
672 order = pool->min_alloc_order;
688 * @pool: pool to get order from
692 struct gen_pool *pool, unsigned long start_addr)
700 order = pool->min_alloc_order;
722 * @pool: pool to find the fit region memory from
726 unsigned int nr, void *data, struct gen_pool *pool,
743 * @pool: pool to find the fit region memory from
750 struct gen_pool *pool, unsigned long start_addr)
783 /* NULL data matches only a pool without an assigned name */
819 * Create a new special memory pool that can be used to manage special purpose
820 * memory not managed by the regular kmalloc/kfree interface. The pool will be
826 struct gen_pool **ptr, *pool;
843 pool = gen_pool_create(min_alloc_order, nid);
844 if (!pool)
847 *ptr = pool;
848 pool->name = pool_name;
851 return pool;
864 * of_gen_pool_get - find a pool by phandle property
869 * Returns the pool that contains the chunk starting at the physical
879 struct gen_pool *pool = NULL;
897 pool = gen_pool_get(&pdev->dev, name);
900 return pool;