Lines Matching full:pool
16 * available. If new memory is added to the pool a lock has to be
146 * gen_pool_create - create a new special memory pool
148 * @nid: node id of the node the pool structure should be allocated on, or -1
150 * Create a new special memory pool that can be used to manage special purpose
155 struct gen_pool *pool; in gen_pool_create() local
157 pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid); in gen_pool_create()
158 if (pool != NULL) { in gen_pool_create()
159 spin_lock_init(&pool->lock); in gen_pool_create()
160 INIT_LIST_HEAD(&pool->chunks); in gen_pool_create()
161 pool->min_alloc_order = min_alloc_order; in gen_pool_create()
162 pool->algo = gen_pool_first_fit; in gen_pool_create()
163 pool->data = NULL; in gen_pool_create()
164 pool->name = NULL; in gen_pool_create()
166 return pool; in gen_pool_create()
171 * gen_pool_add_owner- add a new chunk of special memory to the pool
172 * @pool: pool to add new memory chunk to
173 * @virt: virtual starting address of memory chunk to add to pool
174 * @phys: physical starting address of memory chunk to add to pool
175 * @size: size in bytes of the memory chunk to add to pool
180 * Add a new chunk of special memory to the specified pool.
184 int gen_pool_add_owner(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, in gen_pool_add_owner() argument
188 unsigned long nbits = size >> pool->min_alloc_order; in gen_pool_add_owner()
202 spin_lock(&pool->lock); in gen_pool_add_owner()
203 list_add_rcu(&chunk->next_chunk, &pool->chunks); in gen_pool_add_owner()
204 spin_unlock(&pool->lock); in gen_pool_add_owner()
212 * @pool: pool to allocate from
217 phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long addr) in gen_pool_virt_to_phys() argument
223 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_virt_to_phys()
236 * gen_pool_destroy - destroy a special memory pool
237 * @pool: pool to destroy
239 * Destroy the specified special memory pool. Verifies that there are no
242 void gen_pool_destroy(struct gen_pool *pool) in gen_pool_destroy() argument
246 int order = pool->min_alloc_order; in gen_pool_destroy()
249 list_for_each_safe(_chunk, _next_chunk, &pool->chunks) { in gen_pool_destroy()
259 kfree_const(pool->name); in gen_pool_destroy()
260 kfree(pool); in gen_pool_destroy()
265 * gen_pool_alloc_algo_owner - allocate special memory from the pool
266 * @pool: pool to allocate from
267 * @size: number of bytes to allocate from the pool
272 * Allocate the requested number of bytes from the specified pool.
273 * Uses the pool allocation function (with first-fit algorithm by default).
277 unsigned long gen_pool_alloc_algo_owner(struct gen_pool *pool, size_t size, in gen_pool_alloc_algo_owner() argument
282 int order = pool->min_alloc_order; in gen_pool_alloc_algo_owner()
297 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_alloc_algo_owner()
305 nbits, data, pool, chunk->start_addr); in gen_pool_alloc_algo_owner()
329 * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage
330 * @pool: pool to allocate from
331 * @size: number of bytes to allocate from the pool
334 * Allocate the requested number of bytes from the specified pool.
335 * Uses the pool allocation function (with first-fit algorithm by default).
341 void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) in gen_pool_dma_alloc() argument
343 return gen_pool_dma_alloc_algo(pool, size, dma, pool->algo, pool->data); in gen_pool_dma_alloc()
348 * gen_pool_dma_alloc_algo - allocate special memory from the pool for DMA
349 * usage with the given pool algorithm
350 * @pool: pool to allocate from
351 * @size: number of bytes to allocate from the pool
356 * Allocate the requested number of bytes from the specified pool. Uses the
357 * given pool allocation function. Can not be used in NMI handler on
362 void *gen_pool_dma_alloc_algo(struct gen_pool *pool, size_t size, in gen_pool_dma_alloc_algo() argument
367 if (!pool) in gen_pool_dma_alloc_algo()
370 vaddr = gen_pool_alloc_algo(pool, size, algo, data); in gen_pool_dma_alloc_algo()
375 *dma = gen_pool_virt_to_phys(pool, vaddr); in gen_pool_dma_alloc_algo()
382 * gen_pool_dma_alloc_align - allocate special memory from the pool for DMA
384 * @pool: pool to allocate from
385 * @size: number of bytes to allocate from the pool
389 * Allocate the requested number bytes from the specified pool, with the given
395 void *gen_pool_dma_alloc_align(struct gen_pool *pool, size_t size, in gen_pool_dma_alloc_align() argument
400 return gen_pool_dma_alloc_algo(pool, size, dma, in gen_pool_dma_alloc_align()
406 * gen_pool_dma_zalloc - allocate special zeroed memory from the pool for
408 * @pool: pool to allocate from
409 * @size: number of bytes to allocate from the pool
412 * Allocate the requested number of zeroed bytes from the specified pool.
413 * Uses the pool allocation function (with first-fit algorithm by default).
419 void *gen_pool_dma_zalloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) in gen_pool_dma_zalloc() argument
421 return gen_pool_dma_zalloc_algo(pool, size, dma, pool->algo, pool->data); in gen_pool_dma_zalloc()
426 * gen_pool_dma_zalloc_algo - allocate special zeroed memory from the pool for
427 * DMA usage with the given pool algorithm
428 * @pool: pool to allocate from
429 * @size: number of bytes to allocate from the pool
434 * Allocate the requested number of zeroed bytes from the specified pool. Uses
435 * the given pool allocation function. Can not be used in NMI handler on
440 void *gen_pool_dma_zalloc_algo(struct gen_pool *pool, size_t size, in gen_pool_dma_zalloc_algo() argument
443 void *vaddr = gen_pool_dma_alloc_algo(pool, size, dma, algo, data); in gen_pool_dma_zalloc_algo()
453 * gen_pool_dma_zalloc_align - allocate special zeroed memory from the pool for
455 * @pool: pool to allocate from
456 * @size: number of bytes to allocate from the pool
460 * Allocate the requested number of zeroed bytes from the specified pool,
466 void *gen_pool_dma_zalloc_align(struct gen_pool *pool, size_t size, in gen_pool_dma_zalloc_align() argument
471 return gen_pool_dma_zalloc_algo(pool, size, dma, in gen_pool_dma_zalloc_align()
477 * gen_pool_free_owner - free allocated special memory back to the pool
478 * @pool: pool to free to
479 * @addr: starting address of memory to free back to pool
484 * pool. Can not be used in NMI handler on architectures without
487 void gen_pool_free_owner(struct gen_pool *pool, unsigned long addr, size_t size, in gen_pool_free_owner() argument
491 int order = pool->min_alloc_order; in gen_pool_free_owner()
503 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_free_owner()
523 * gen_pool_for_each_chunk - call func for every chunk of generic memory pool
524 * @pool: the generic memory pool
528 * Call @func for every chunk of generic memory pool. The @func is
531 void gen_pool_for_each_chunk(struct gen_pool *pool, in gen_pool_for_each_chunk() argument
532 void (*func)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data), in gen_pool_for_each_chunk() argument
538 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) in gen_pool_for_each_chunk()
539 func(pool, chunk, data); in gen_pool_for_each_chunk()
545 * gen_pool_has_addr - checks if an address falls within the range of a pool
546 * @pool: the generic memory pool
550 * Check if the range of addresses falls within the specified pool. Returns
551 * true if the entire range is contained in the pool and false otherwise.
553 bool gen_pool_has_addr(struct gen_pool *pool, unsigned long start, in gen_pool_has_addr() argument
561 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) { in gen_pool_has_addr()
575 * gen_pool_avail - get available free space of the pool
576 * @pool: pool to get available free space
578 * Return available free space of the specified pool.
580 size_t gen_pool_avail(struct gen_pool *pool) in gen_pool_avail() argument
586 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_avail()
594 * gen_pool_size - get size in bytes of memory managed by the pool
595 * @pool: pool to get size
597 * Return size in bytes of memory managed by the pool.
599 size_t gen_pool_size(struct gen_pool *pool) in gen_pool_size() argument
605 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_size()
614 * @pool: pool to change allocation algorithm
618 * Call @algo for each memory allocation in the pool.
622 void gen_pool_set_algo(struct gen_pool *pool, genpool_algo_t algo, void *data) in gen_pool_set_algo() argument
626 pool->algo = algo; in gen_pool_set_algo()
627 if (!pool->algo) in gen_pool_set_algo()
628 pool->algo = gen_pool_first_fit; in gen_pool_set_algo()
630 pool->data = data; in gen_pool_set_algo()
644 * @pool: pool to find the fit region memory from
649 struct gen_pool *pool, unsigned long start_addr) in gen_pool_first_fit() argument
663 * @pool: pool to get order from
668 struct gen_pool *pool, unsigned long start_addr) in gen_pool_first_fit_align() argument
675 order = pool->min_alloc_order; in gen_pool_first_fit_align()
691 * @pool: pool to get order from
696 struct gen_pool *pool, unsigned long start_addr) in gen_pool_fixed_alloc() argument
704 order = pool->min_alloc_order; in gen_pool_fixed_alloc()
726 * @pool: pool to find the fit region memory from
731 unsigned int nr, void *data, struct gen_pool *pool, in gen_pool_first_fit_order_align() argument
748 * @pool: pool to find the fit region memory from
756 struct gen_pool *pool, unsigned long start_addr) in gen_pool_best_fit() argument
789 /* NULL data matches only a pool without an assigned name */ in devm_gen_pool_match()
825 * Create a new special memory pool that can be used to manage special purpose
826 * memory not managed by the regular kmalloc/kfree interface. The pool will be
832 struct gen_pool **ptr, *pool; in devm_gen_pool_create() local
849 pool = gen_pool_create(min_alloc_order, nid); in devm_gen_pool_create()
850 if (!pool) in devm_gen_pool_create()
853 *ptr = pool; in devm_gen_pool_create()
854 pool->name = pool_name; in devm_gen_pool_create()
857 return pool; in devm_gen_pool_create()
870 * of_gen_pool_get - find a pool by phandle property
875 * Returns the pool that contains the chunk starting at the physical
885 struct gen_pool *pool = NULL; in of_gen_pool_get() local
903 pool = gen_pool_get(&pdev->dev, name); in of_gen_pool_get()
906 return pool; in of_gen_pool_get()