Lines Matching refs:pool
92 void rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool, in rxe_pool_init() argument
97 memset(pool, 0, sizeof(*pool)); in rxe_pool_init()
99 pool->rxe = rxe; in rxe_pool_init()
100 pool->name = info->name; in rxe_pool_init()
101 pool->type = type; in rxe_pool_init()
102 pool->max_elem = info->max_elem; in rxe_pool_init()
103 pool->elem_size = ALIGN(info->size, RXE_POOL_ALIGN); in rxe_pool_init()
104 pool->elem_offset = info->elem_offset; in rxe_pool_init()
105 pool->cleanup = info->cleanup; in rxe_pool_init()
107 atomic_set(&pool->num_elem, 0); in rxe_pool_init()
109 xa_init_flags(&pool->xa, XA_FLAGS_ALLOC); in rxe_pool_init()
110 pool->limit.min = info->min_index; in rxe_pool_init()
111 pool->limit.max = info->max_index; in rxe_pool_init()
114 void rxe_pool_cleanup(struct rxe_pool *pool) in rxe_pool_cleanup() argument
116 WARN_ON(!xa_empty(&pool->xa)); in rxe_pool_cleanup()
119 void *rxe_alloc(struct rxe_pool *pool) in rxe_alloc() argument
125 if (WARN_ON(!(pool->type == RXE_TYPE_MR))) in rxe_alloc()
128 if (atomic_inc_return(&pool->num_elem) > pool->max_elem) in rxe_alloc()
131 obj = kzalloc(pool->elem_size, GFP_KERNEL); in rxe_alloc()
135 elem = (struct rxe_pool_elem *)((u8 *)obj + pool->elem_offset); in rxe_alloc()
137 elem->pool = pool; in rxe_alloc()
145 err = xa_alloc_cyclic(&pool->xa, &elem->index, NULL, pool->limit, in rxe_alloc()
146 &pool->next, GFP_KERNEL); in rxe_alloc()
155 atomic_dec(&pool->num_elem); in rxe_alloc()
159 int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem, in __rxe_add_to_pool() argument
165 if (WARN_ON(pool->type == RXE_TYPE_MR)) in __rxe_add_to_pool()
168 if (atomic_inc_return(&pool->num_elem) > pool->max_elem) in __rxe_add_to_pool()
171 elem->pool = pool; in __rxe_add_to_pool()
172 elem->obj = (u8 *)elem - pool->elem_offset; in __rxe_add_to_pool()
184 err = xa_alloc_cyclic(&pool->xa, &elem->index, NULL, pool->limit, in __rxe_add_to_pool()
185 &pool->next, gfp_flags); in __rxe_add_to_pool()
192 atomic_dec(&pool->num_elem); in __rxe_add_to_pool()
196 void *rxe_pool_get_index(struct rxe_pool *pool, u32 index) in rxe_pool_get_index() argument
199 struct xarray *xa = &pool->xa; in rxe_pool_get_index()
222 struct rxe_pool *pool = elem->pool; in __rxe_cleanup() local
223 struct xarray *xa = &pool->xa; in __rxe_cleanup()
275 if (pool->cleanup) in __rxe_cleanup()
276 pool->cleanup(elem); in __rxe_cleanup()
278 if (pool->type == RXE_TYPE_MR) in __rxe_cleanup()
281 atomic_dec(&pool->num_elem); in __rxe_cleanup()
300 xa_ret = xa_store(&elem->pool->xa, elem->index, elem, GFP_KERNEL); in __rxe_finalize()