Lines Matching full:pool

16  * available.  If new memory is added to the pool a lock has to be
144 * gen_pool_create - create a new special memory pool
146 * @nid: node id of the node the pool structure should be allocated on, or -1
148 * Create a new special memory pool that can be used to manage special purpose
153 struct gen_pool *pool; in gen_pool_create() local
155 pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid); in gen_pool_create()
156 if (pool != NULL) { in gen_pool_create()
157 spin_lock_init(&pool->lock); in gen_pool_create()
158 INIT_LIST_HEAD(&pool->chunks); in gen_pool_create()
159 pool->min_alloc_order = min_alloc_order; in gen_pool_create()
160 pool->algo = gen_pool_first_fit; in gen_pool_create()
161 pool->data = NULL; in gen_pool_create()
162 pool->name = NULL; in gen_pool_create()
164 return pool; in gen_pool_create()
169 * gen_pool_add_owner- add a new chunk of special memory to the pool
170 * @pool: pool to add new memory chunk to
171 * @virt: virtual starting address of memory chunk to add to pool
172 * @phys: physical starting address of memory chunk to add to pool
173 * @size: size in bytes of the memory chunk to add to pool
178 * Add a new chunk of special memory to the specified pool.
182 int gen_pool_add_owner(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, in gen_pool_add_owner() argument
186 int nbits = size >> pool->min_alloc_order; in gen_pool_add_owner()
200 spin_lock(&pool->lock); in gen_pool_add_owner()
201 list_add_rcu(&chunk->next_chunk, &pool->chunks); in gen_pool_add_owner()
202 spin_unlock(&pool->lock); in gen_pool_add_owner()
210 * @pool: pool to allocate from
215 phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long addr) in gen_pool_virt_to_phys() argument
221 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_virt_to_phys()
234 * gen_pool_destroy - destroy a special memory pool
235 * @pool: pool to destroy
237 * Destroy the specified special memory pool. Verifies that there are no
240 void gen_pool_destroy(struct gen_pool *pool) in gen_pool_destroy() argument
244 int order = pool->min_alloc_order; in gen_pool_destroy()
247 list_for_each_safe(_chunk, _next_chunk, &pool->chunks) { in gen_pool_destroy()
257 kfree_const(pool->name); in gen_pool_destroy()
258 kfree(pool); in gen_pool_destroy()
263 * gen_pool_alloc_algo_owner - allocate special memory from the pool
264 * @pool: pool to allocate from
265 * @size: number of bytes to allocate from the pool
270 * Allocate the requested number of bytes from the specified pool.
271 * Uses the pool allocation function (with first-fit algorithm by default).
275 unsigned long gen_pool_alloc_algo_owner(struct gen_pool *pool, size_t size, in gen_pool_alloc_algo_owner() argument
280 int order = pool->min_alloc_order; in gen_pool_alloc_algo_owner()
295 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_alloc_algo_owner()
303 nbits, data, pool, chunk->start_addr); in gen_pool_alloc_algo_owner()
327 * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage
328 * @pool: pool to allocate from
329 * @size: number of bytes to allocate from the pool
332 * Allocate the requested number of bytes from the specified pool.
333 * Uses the pool allocation function (with first-fit algorithm by default).
339 void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) in gen_pool_dma_alloc() argument
341 return gen_pool_dma_alloc_algo(pool, size, dma, pool->algo, pool->data); in gen_pool_dma_alloc()
346 * gen_pool_dma_alloc_algo - allocate special memory from the pool for DMA
347 * usage with the given pool algorithm
348 * @pool: pool to allocate from
349 * @size: number of bytes to allocate from the pool
354 * Allocate the requested number of bytes from the specified pool. Uses the
355 * given pool allocation function. Can not be used in NMI handler on
360 void *gen_pool_dma_alloc_algo(struct gen_pool *pool, size_t size, in gen_pool_dma_alloc_algo() argument
365 if (!pool) in gen_pool_dma_alloc_algo()
368 vaddr = gen_pool_alloc_algo(pool, size, algo, data); in gen_pool_dma_alloc_algo()
373 *dma = gen_pool_virt_to_phys(pool, vaddr); in gen_pool_dma_alloc_algo()
380 * gen_pool_dma_alloc_align - allocate special memory from the pool for DMA
382 * @pool: pool to allocate from
383 * @size: number of bytes to allocate from the pool
387 * Allocate the requested number bytes from the specified pool, with the given
393 void *gen_pool_dma_alloc_align(struct gen_pool *pool, size_t size, in gen_pool_dma_alloc_align() argument
398 return gen_pool_dma_alloc_algo(pool, size, dma, in gen_pool_dma_alloc_align()
404 * gen_pool_dma_zalloc - allocate special zeroed memory from the pool for
406 * @pool: pool to allocate from
407 * @size: number of bytes to allocate from the pool
410 * Allocate the requested number of zeroed bytes from the specified pool.
411 * Uses the pool allocation function (with first-fit algorithm by default).
417 void *gen_pool_dma_zalloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) in gen_pool_dma_zalloc() argument
419 return gen_pool_dma_zalloc_algo(pool, size, dma, pool->algo, pool->data); in gen_pool_dma_zalloc()
424 * gen_pool_dma_zalloc_algo - allocate special zeroed memory from the pool for
425 * DMA usage with the given pool algorithm
426 * @pool: pool to allocate from
427 * @size: number of bytes to allocate from the pool
432 * Allocate the requested number of zeroed bytes from the specified pool. Uses
433 * the given pool allocation function. Can not be used in NMI handler on
438 void *gen_pool_dma_zalloc_algo(struct gen_pool *pool, size_t size, in gen_pool_dma_zalloc_algo() argument
441 void *vaddr = gen_pool_dma_alloc_algo(pool, size, dma, algo, data); in gen_pool_dma_zalloc_algo()
451 * gen_pool_dma_zalloc_align - allocate special zeroed memory from the pool for
453 * @pool: pool to allocate from
454 * @size: number of bytes to allocate from the pool
458 * Allocate the requested number of zeroed bytes from the specified pool,
464 void *gen_pool_dma_zalloc_align(struct gen_pool *pool, size_t size, in gen_pool_dma_zalloc_align() argument
469 return gen_pool_dma_zalloc_algo(pool, size, dma, in gen_pool_dma_zalloc_align()
475 * gen_pool_free_owner - free allocated special memory back to the pool
476 * @pool: pool to free to
477 * @addr: starting address of memory to free back to pool
482 * pool. Can not be used in NMI handler on architectures without
485 void gen_pool_free_owner(struct gen_pool *pool, unsigned long addr, size_t size, in gen_pool_free_owner() argument
489 int order = pool->min_alloc_order; in gen_pool_free_owner()
501 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_free_owner()
521 * gen_pool_for_each_chunk - call func for every chunk of generic memory pool
522 * @pool: the generic memory pool
526 * Call @func for every chunk of generic memory pool. The @func is
529 void gen_pool_for_each_chunk(struct gen_pool *pool, in gen_pool_for_each_chunk() argument
530 void (*func)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data), in gen_pool_for_each_chunk() argument
536 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) in gen_pool_for_each_chunk()
537 func(pool, chunk, data); in gen_pool_for_each_chunk()
543 * gen_pool_has_addr - checks if an address falls within the range of a pool
544 * @pool: the generic memory pool
548 * Check if the range of addresses falls within the specified pool. Returns
549 * true if the entire range is contained in the pool and false otherwise.
551 bool gen_pool_has_addr(struct gen_pool *pool, unsigned long start, in gen_pool_has_addr() argument
559 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) { in gen_pool_has_addr()
573 * gen_pool_avail - get available free space of the pool
574 * @pool: pool to get available free space
576 * Return available free space of the specified pool.
578 size_t gen_pool_avail(struct gen_pool *pool) in gen_pool_avail() argument
584 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_avail()
592 * gen_pool_size - get size in bytes of memory managed by the pool
593 * @pool: pool to get size
595 * Return size in bytes of memory managed by the pool.
597 size_t gen_pool_size(struct gen_pool *pool) in gen_pool_size() argument
603 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_size()
612 * @pool: pool to change allocation algorithm
616 * Call @algo for each memory allocation in the pool.
620 void gen_pool_set_algo(struct gen_pool *pool, genpool_algo_t algo, void *data) in gen_pool_set_algo() argument
624 pool->algo = algo; in gen_pool_set_algo()
625 if (!pool->algo) in gen_pool_set_algo()
626 pool->algo = gen_pool_first_fit; in gen_pool_set_algo()
628 pool->data = data; in gen_pool_set_algo()
642 * @pool: pool to find the fit region memory from
646 struct gen_pool *pool, unsigned long start_addr) in gen_pool_first_fit() argument
660 * @pool: pool to get order from
664 struct gen_pool *pool, unsigned long start_addr) in gen_pool_first_fit_align() argument
671 order = pool->min_alloc_order; in gen_pool_first_fit_align()
687 * @pool: pool to get order from
691 struct gen_pool *pool, unsigned long start_addr) in gen_pool_fixed_alloc() argument
699 order = pool->min_alloc_order; in gen_pool_fixed_alloc()
721 * @pool: pool to find the fit region memory from
725 unsigned int nr, void *data, struct gen_pool *pool, in gen_pool_first_fit_order_align() argument
742 * @pool: pool to find the fit region memory from
749 struct gen_pool *pool, unsigned long start_addr) in gen_pool_best_fit() argument
782 /* NULL data matches only a pool without an assigned name */ in devm_gen_pool_match()
818 * Create a new special memory pool that can be used to manage special purpose
819 * memory not managed by the regular kmalloc/kfree interface. The pool will be
825 struct gen_pool **ptr, *pool; in devm_gen_pool_create() local
842 pool = gen_pool_create(min_alloc_order, nid); in devm_gen_pool_create()
843 if (!pool) in devm_gen_pool_create()
846 *ptr = pool; in devm_gen_pool_create()
847 pool->name = pool_name; in devm_gen_pool_create()
850 return pool; in devm_gen_pool_create()
863 * of_gen_pool_get - find a pool by phandle property
868 * Returns the pool that contains the chunk starting at the physical
878 struct gen_pool *pool = NULL; in of_gen_pool_get() local
896 pool = gen_pool_get(&pdev->dev, name); in of_gen_pool_get()
899 return pool; in of_gen_pool_get()