• Home
  • Raw
  • Download

Lines Matching full:pool

15  * 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_virt - 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
179 * Add a new chunk of special memory to the specified pool.
183 int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, in gen_pool_add_virt() argument
187 int nbits = size >> pool->min_alloc_order; in gen_pool_add_virt()
200 spin_lock(&pool->lock); in gen_pool_add_virt()
201 list_add_rcu(&chunk->next_chunk, &pool->chunks); in gen_pool_add_virt()
202 spin_unlock(&pool->lock); in gen_pool_add_virt()
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 - allocate special memory from the pool
264 * @pool: pool to allocate from
265 * @size: number of bytes to allocate from the pool
267 * Allocate the requested number of bytes from the specified pool.
268 * Uses the pool allocation function (with first-fit algorithm by default).
272 unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size) in gen_pool_alloc() argument
274 return gen_pool_alloc_algo(pool, size, pool->algo, pool->data); in gen_pool_alloc()
279 * gen_pool_alloc_algo - allocate special memory from the pool
280 * @pool: pool to allocate from
281 * @size: number of bytes to allocate from the pool
285 * Allocate the requested number of bytes from the specified pool.
286 * Uses the pool allocation function (with first-fit algorithm by default).
290 unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size, in gen_pool_alloc_algo() argument
295 int order = pool->min_alloc_order; in gen_pool_alloc_algo()
307 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_alloc_algo()
315 nbits, data, pool, chunk->start_addr); in gen_pool_alloc_algo()
337 * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage
338 * @pool: pool to allocate from
339 * @size: number of bytes to allocate from the pool
342 * Allocate the requested number of bytes from the specified pool.
343 * Uses the pool allocation function (with first-fit algorithm by default).
347 void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) in gen_pool_dma_alloc() argument
351 if (!pool) in gen_pool_dma_alloc()
354 vaddr = gen_pool_alloc(pool, size); in gen_pool_dma_alloc()
359 *dma = gen_pool_virt_to_phys(pool, vaddr); in gen_pool_dma_alloc()
366 * gen_pool_free - free allocated special memory back to the pool
367 * @pool: pool to free to
368 * @addr: starting address of memory to free back to pool
372 * pool. Can not be used in NMI handler on architectures without
375 void gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size) in gen_pool_free() argument
378 int order = pool->min_alloc_order; in gen_pool_free()
387 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_free()
405 * gen_pool_for_each_chunk - call func for every chunk of generic memory pool
406 * @pool: the generic memory pool
410 * Call @func for every chunk of generic memory pool. The @func is
413 void gen_pool_for_each_chunk(struct gen_pool *pool, in gen_pool_for_each_chunk() argument
414 void (*func)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data), in gen_pool_for_each_chunk() argument
420 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) in gen_pool_for_each_chunk()
421 func(pool, chunk, data); in gen_pool_for_each_chunk()
427 * addr_in_gen_pool - checks if an address falls within the range of a pool
428 * @pool: the generic memory pool
432 * Check if the range of addresses falls within the specified pool. Returns
433 * true if the entire range is contained in the pool and false otherwise.
435 bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start, in addr_in_gen_pool() argument
443 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) { in addr_in_gen_pool()
456 * gen_pool_avail - get available free space of the pool
457 * @pool: pool to get available free space
459 * Return available free space of the specified pool.
461 size_t gen_pool_avail(struct gen_pool *pool) in gen_pool_avail() argument
467 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_avail()
475 * gen_pool_size - get size in bytes of memory managed by the pool
476 * @pool: pool to get size
478 * Return size in bytes of memory managed by the pool.
480 size_t gen_pool_size(struct gen_pool *pool) in gen_pool_size() argument
486 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_size()
495 * @pool: pool to change allocation algorithm
499 * Call @algo for each memory allocation in the pool.
503 void gen_pool_set_algo(struct gen_pool *pool, genpool_algo_t algo, void *data) in gen_pool_set_algo() argument
507 pool->algo = algo; in gen_pool_set_algo()
508 if (!pool->algo) in gen_pool_set_algo()
509 pool->algo = gen_pool_first_fit; in gen_pool_set_algo()
511 pool->data = data; in gen_pool_set_algo()
525 * @pool: pool to find the fit region memory from
529 struct gen_pool *pool, unsigned long start_addr) in gen_pool_first_fit() argument
543 * @pool: pool to get order from
547 struct gen_pool *pool, unsigned long start_addr) in gen_pool_first_fit_align() argument
554 order = pool->min_alloc_order; in gen_pool_first_fit_align()
570 * @pool: pool to get order from
574 struct gen_pool *pool, unsigned long start_addr) in gen_pool_fixed_alloc() argument
582 order = pool->min_alloc_order; in gen_pool_fixed_alloc()
604 * @pool: pool to find the fit region memory from
608 unsigned int nr, void *data, struct gen_pool *pool, in gen_pool_first_fit_order_align() argument
625 * @pool: pool to find the fit region memory from
632 struct gen_pool *pool, unsigned long start_addr) in gen_pool_best_fit() argument
665 /* NULL data matches only a pool without an assigned name */ in devm_gen_pool_match()
701 * Create a new special memory pool that can be used to manage special purpose
702 * memory not managed by the regular kmalloc/kfree interface. The pool will be
708 struct gen_pool **ptr, *pool; in devm_gen_pool_create() local
725 pool = gen_pool_create(min_alloc_order, nid); in devm_gen_pool_create()
726 if (!pool) in devm_gen_pool_create()
729 *ptr = pool; in devm_gen_pool_create()
730 pool->name = pool_name; in devm_gen_pool_create()
733 return pool; in devm_gen_pool_create()
746 * of_gen_pool_get - find a pool by phandle property
751 * Returns the pool that contains the chunk starting at the physical
761 struct gen_pool *pool = NULL; in of_gen_pool_get() local
779 pool = gen_pool_get(&pdev->dev, name); in of_gen_pool_get()
782 return pool; in of_gen_pool_get()