Lines Matching refs:chunk

40 static inline size_t chunk_size(const struct gen_pool_chunk *chunk)  in chunk_size()  argument
42 return chunk->end_addr - chunk->start_addr + 1; in chunk_size()
187 struct gen_pool_chunk *chunk; in gen_pool_add_owner() local
192 chunk = vzalloc_node(nbytes, nid); in gen_pool_add_owner()
193 if (unlikely(chunk == NULL)) in gen_pool_add_owner()
196 chunk->phys_addr = phys; in gen_pool_add_owner()
197 chunk->start_addr = virt; in gen_pool_add_owner()
198 chunk->end_addr = virt + size - 1; in gen_pool_add_owner()
199 chunk->owner = owner; in gen_pool_add_owner()
200 atomic_long_set(&chunk->avail, size); in gen_pool_add_owner()
203 list_add_rcu(&chunk->next_chunk, &pool->chunks); in gen_pool_add_owner()
219 struct gen_pool_chunk *chunk; in gen_pool_virt_to_phys() local
223 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_virt_to_phys()
224 if (addr >= chunk->start_addr && addr <= chunk->end_addr) { in gen_pool_virt_to_phys()
225 paddr = chunk->phys_addr + (addr - chunk->start_addr); in gen_pool_virt_to_phys()
245 struct gen_pool_chunk *chunk; in gen_pool_destroy() local
250 chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk); in gen_pool_destroy()
251 list_del(&chunk->next_chunk); in gen_pool_destroy()
253 end_bit = chunk_size(chunk) >> order; in gen_pool_destroy()
254 bit = find_first_bit(chunk->bits, end_bit); in gen_pool_destroy()
257 vfree(chunk); in gen_pool_destroy()
280 struct gen_pool_chunk *chunk; in gen_pool_alloc_algo_owner() local
297 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_alloc_algo_owner()
298 if (size > atomic_long_read(&chunk->avail)) in gen_pool_alloc_algo_owner()
302 end_bit = chunk_size(chunk) >> order; in gen_pool_alloc_algo_owner()
304 start_bit = algo(chunk->bits, end_bit, start_bit, in gen_pool_alloc_algo_owner()
305 nbits, data, pool, chunk->start_addr); in gen_pool_alloc_algo_owner()
308 remain = bitmap_set_ll(chunk->bits, start_bit, nbits); in gen_pool_alloc_algo_owner()
310 remain = bitmap_clear_ll(chunk->bits, start_bit, in gen_pool_alloc_algo_owner()
316 addr = chunk->start_addr + ((unsigned long)start_bit << order); in gen_pool_alloc_algo_owner()
318 atomic_long_sub(size, &chunk->avail); in gen_pool_alloc_algo_owner()
320 *owner = chunk->owner; in gen_pool_alloc_algo_owner()
490 struct gen_pool_chunk *chunk; in gen_pool_free_owner() local
503 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) { in gen_pool_free_owner()
504 if (addr >= chunk->start_addr && addr <= chunk->end_addr) { in gen_pool_free_owner()
505 BUG_ON(addr + size - 1 > chunk->end_addr); in gen_pool_free_owner()
506 start_bit = (addr - chunk->start_addr) >> order; in gen_pool_free_owner()
507 remain = bitmap_clear_ll(chunk->bits, start_bit, nbits); in gen_pool_free_owner()
510 atomic_long_add(size, &chunk->avail); in gen_pool_free_owner()
512 *owner = chunk->owner; in gen_pool_free_owner()
532 void (*func)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data), in gen_pool_for_each_chunk() argument
535 struct gen_pool_chunk *chunk; in gen_pool_for_each_chunk() local
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()
558 struct gen_pool_chunk *chunk; in gen_pool_has_addr() local
561 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) { in gen_pool_has_addr()
562 if (start >= chunk->start_addr && start <= chunk->end_addr) { in gen_pool_has_addr()
563 if (end <= chunk->end_addr) { in gen_pool_has_addr()
582 struct gen_pool_chunk *chunk; in gen_pool_avail() local
586 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_avail()
587 avail += atomic_long_read(&chunk->avail); in gen_pool_avail()
601 struct gen_pool_chunk *chunk; in gen_pool_size() local
605 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) in gen_pool_size()
606 size += chunk_size(chunk); in gen_pool_size()