Lines Matching defs:pool
16 * Example buddy-tree for a 4-pages physically contiguous pool:
27 * Example of requests on this pool:
28 * __find_buddy_nocheck(pool, page 0, order 0) => page 1
29 * __find_buddy_nocheck(pool, page 0, order 1) => page 2
30 * __find_buddy_nocheck(pool, page 1, order 0) => page 0
31 * __find_buddy_nocheck(pool, page 2, order 0) => page 3
33 static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool,
42 * Don't return a page outside the pool range -- it belongs to
45 if (addr < pool->range_start || addr >= pool->range_end)
52 static struct hyp_page *__find_buddy_avail(struct hyp_pool *pool,
56 struct hyp_page *buddy = __find_buddy_nocheck(pool, p, order);
93 static void __hyp_attach_page(struct hyp_pool *pool,
102 /* Skip coalescing for 'external' pages being freed into the pool. */
103 if (phys < pool->range_start || phys >= pool->range_end)
113 for (; (order + 1) <= pool->max_order; order++) {
114 buddy = __find_buddy_avail(pool, p, order);
127 page_add_to_list(p, &pool->free_area[order]);
130 static struct hyp_page *__hyp_extract_page(struct hyp_pool *pool,
145 buddy = __find_buddy_nocheck(pool, p, p->order);
147 page_add_to_list(buddy, &pool->free_area[buddy->order]);
153 static void __hyp_put_page(struct hyp_pool *pool, struct hyp_page *p)
156 __hyp_attach_page(pool, p);
166 void hyp_put_page(struct hyp_pool *pool, void *addr)
170 hyp_spin_lock(&pool->lock);
171 __hyp_put_page(pool, p);
172 hyp_spin_unlock(&pool->lock);
175 void hyp_get_page(struct hyp_pool *pool, void *addr)
179 hyp_spin_lock(&pool->lock);
181 hyp_spin_unlock(&pool->lock);
198 void *hyp_alloc_pages(struct hyp_pool *pool, u8 order)
203 hyp_spin_lock(&pool->lock);
206 while (i <= pool->max_order && list_empty(&pool->free_area[i]))
208 if (i > pool->max_order) {
209 hyp_spin_unlock(&pool->lock);
214 p = node_to_page(pool->free_area[i].next);
215 p = __hyp_extract_page(pool, p, order);
218 hyp_spin_unlock(&pool->lock);
223 int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,
230 hyp_spin_lock_init(&pool->lock);
231 pool->max_order = min(MAX_PAGE_ORDER,
233 for (i = 0; i <= pool->max_order; i++)
234 INIT_LIST_HEAD(&pool->free_area[i]);
235 pool->range_start = phys;
236 pool->range_end = phys + (nr_pages << PAGE_SHIFT);
245 __hyp_put_page(pool, &p[i]);