Lines Matching refs:pool
33 static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool, in __find_buddy_nocheck() argument
45 if (addr < pool->range_start || addr >= pool->range_end) in __find_buddy_nocheck()
52 static struct hyp_page *__find_buddy_avail(struct hyp_pool *pool, in __find_buddy_avail() argument
56 struct hyp_page *buddy = __find_buddy_nocheck(pool, p, order); in __find_buddy_avail()
93 static void __hyp_attach_page(struct hyp_pool *pool, in __hyp_attach_page() argument
103 if (phys < pool->range_start || phys >= pool->range_end) in __hyp_attach_page()
113 for (; (order + 1) <= pool->max_order; order++) { in __hyp_attach_page()
114 buddy = __find_buddy_avail(pool, p, order); in __hyp_attach_page()
127 page_add_to_list(p, &pool->free_area[order]); in __hyp_attach_page()
130 static struct hyp_page *__hyp_extract_page(struct hyp_pool *pool, in __hyp_extract_page() argument
145 buddy = __find_buddy_nocheck(pool, p, p->order); in __hyp_extract_page()
147 page_add_to_list(buddy, &pool->free_area[buddy->order]); in __hyp_extract_page()
153 static void __hyp_put_page(struct hyp_pool *pool, struct hyp_page *p) in __hyp_put_page() argument
156 __hyp_attach_page(pool, p); in __hyp_put_page()
166 void hyp_put_page(struct hyp_pool *pool, void *addr) in hyp_put_page() argument
170 hyp_spin_lock(&pool->lock); in hyp_put_page()
171 __hyp_put_page(pool, p); in hyp_put_page()
172 hyp_spin_unlock(&pool->lock); in hyp_put_page()
175 void hyp_get_page(struct hyp_pool *pool, void *addr) in hyp_get_page() argument
179 hyp_spin_lock(&pool->lock); in hyp_get_page()
181 hyp_spin_unlock(&pool->lock); in hyp_get_page()
198 void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order) in hyp_alloc_pages() argument
203 hyp_spin_lock(&pool->lock); in hyp_alloc_pages()
206 while (i <= pool->max_order && list_empty(&pool->free_area[i])) in hyp_alloc_pages()
208 if (i > pool->max_order) { in hyp_alloc_pages()
209 hyp_spin_unlock(&pool->lock); in hyp_alloc_pages()
214 p = node_to_page(pool->free_area[i].next); in hyp_alloc_pages()
215 p = __hyp_extract_page(pool, p, order); in hyp_alloc_pages()
218 hyp_spin_unlock(&pool->lock); in hyp_alloc_pages()
223 int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages, in hyp_pool_init() argument
230 hyp_spin_lock_init(&pool->lock); in hyp_pool_init()
231 pool->max_order = min(MAX_ORDER, get_order(nr_pages << PAGE_SHIFT)); in hyp_pool_init()
232 for (i = 0; i <= pool->max_order; i++) in hyp_pool_init()
233 INIT_LIST_HEAD(&pool->free_area[i]); in hyp_pool_init()
234 pool->range_start = phys; in hyp_pool_init()
235 pool->range_end = phys + (nr_pages << PAGE_SHIFT); in hyp_pool_init()
244 __hyp_put_page(pool, &p[i]); in hyp_pool_init()