Lines Matching refs:chunk
38 static inline size_t chunk_size(const struct gen_pool_chunk *chunk)
40 return chunk->end_addr - chunk->start_addr + 1;
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
175 * @nid: node id of the node the chunk structure and bitmap should be
179 * Add a new chunk of special memory to the specified pool.
186 struct gen_pool_chunk *chunk;
191 chunk = vzalloc_node(nbytes, nid);
192 if (unlikely(chunk == NULL))
195 chunk->phys_addr = phys;
196 chunk->start_addr = virt;
197 chunk->end_addr = virt + size - 1;
198 chunk->owner = owner;
199 atomic_long_set(&chunk->avail, size);
202 list_add_rcu(&chunk->next_chunk, &pool->chunks);
218 struct gen_pool_chunk *chunk;
222 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
223 if (addr >= chunk->start_addr && addr <= chunk->end_addr) {
224 paddr = chunk->phys_addr + (addr - chunk->start_addr);
244 struct gen_pool_chunk *chunk;
249 chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
250 list_del(&chunk->next_chunk);
252 end_bit = chunk_size(chunk) >> order;
253 bit = find_next_bit(chunk->bits, end_bit, 0);
256 vfree(chunk);
269 * @owner: optionally retrieve the chunk owner
279 struct gen_pool_chunk *chunk;
296 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
297 if (size > atomic_long_read(&chunk->avail))
301 end_bit = chunk_size(chunk) >> order;
303 start_bit = algo(chunk->bits, end_bit, start_bit,
304 nbits, data, pool, chunk->start_addr);
307 remain = bitmap_set_ll(chunk->bits, start_bit, nbits);
309 remain = bitmap_clear_ll(chunk->bits, start_bit,
315 addr = chunk->start_addr + ((unsigned long)start_bit << order);
317 atomic_long_sub(size, &chunk->avail);
319 *owner = chunk->owner;
489 struct gen_pool_chunk *chunk;
502 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
503 if (addr >= chunk->start_addr && addr <= chunk->end_addr) {
504 BUG_ON(addr + size - 1 > chunk->end_addr);
505 start_bit = (addr - chunk->start_addr) >> order;
506 remain = bitmap_clear_ll(chunk->bits, start_bit, nbits);
509 atomic_long_add(size, &chunk->avail);
511 *owner = chunk->owner;
522 * gen_pool_for_each_chunk - call func for every chunk of generic memory pool
527 * Call @func for every chunk of generic memory pool. The @func is
531 void (*func)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data),
534 struct gen_pool_chunk *chunk;
537 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk)
538 func(pool, chunk, data);
557 struct gen_pool_chunk *chunk;
560 list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) {
561 if (start >= chunk->start_addr && start <= chunk->end_addr) {
562 if (end <= chunk->end_addr) {
581 struct gen_pool_chunk *chunk;
585 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk)
586 avail += atomic_long_read(&chunk->avail);
600 struct gen_pool_chunk *chunk;
604 list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk)
605 size += chunk_size(chunk);
869 * Returns the pool that contains the chunk starting at the physical