Lines Matching +full:pool +full:- +full:long
1 // SPDX-License-Identifier: GPL-2.0-only
6 #include <linux/dma-buf.h>
12 static int pool_op_gen_alloc(struct tee_shm_pool *pool, struct tee_shm *shm, in pool_op_gen_alloc() argument
15 unsigned long va; in pool_op_gen_alloc()
16 struct gen_pool *genpool = pool->private_data; in pool_op_gen_alloc()
17 size_t a = max_t(size_t, align, BIT(genpool->min_alloc_order)); in pool_op_gen_alloc()
23 return -ENOMEM; in pool_op_gen_alloc()
26 shm->kaddr = (void *)va; in pool_op_gen_alloc()
27 shm->paddr = gen_pool_virt_to_phys(genpool, va); in pool_op_gen_alloc()
28 shm->size = s; in pool_op_gen_alloc()
30 * This is from a static shared memory pool so no need to register in pool_op_gen_alloc()
33 shm->flags &= ~TEE_SHM_DYNAMIC; in pool_op_gen_alloc()
37 static void pool_op_gen_free(struct tee_shm_pool *pool, struct tee_shm *shm) in pool_op_gen_free() argument
39 gen_pool_free(pool->private_data, (unsigned long)shm->kaddr, in pool_op_gen_free()
40 shm->size); in pool_op_gen_free()
41 shm->kaddr = NULL; in pool_op_gen_free()
44 static void pool_op_gen_destroy_pool(struct tee_shm_pool *pool) in pool_op_gen_destroy_pool() argument
46 gen_pool_destroy(pool->private_data); in pool_op_gen_destroy_pool()
47 kfree(pool); in pool_op_gen_destroy_pool()
56 struct tee_shm_pool *tee_shm_pool_alloc_res_mem(unsigned long vaddr, in tee_shm_pool_alloc_res_mem()
60 const size_t page_mask = PAGE_SIZE - 1; in tee_shm_pool_alloc_res_mem()
61 struct tee_shm_pool *pool; in tee_shm_pool_alloc_res_mem() local
66 return ERR_PTR(-EINVAL); in tee_shm_pool_alloc_res_mem()
68 pool = kzalloc(sizeof(*pool), GFP_KERNEL); in tee_shm_pool_alloc_res_mem()
69 if (!pool) in tee_shm_pool_alloc_res_mem()
70 return ERR_PTR(-ENOMEM); in tee_shm_pool_alloc_res_mem()
72 pool->private_data = gen_pool_create(min_alloc_order, -1); in tee_shm_pool_alloc_res_mem()
73 if (!pool->private_data) { in tee_shm_pool_alloc_res_mem()
74 rc = -ENOMEM; in tee_shm_pool_alloc_res_mem()
78 rc = gen_pool_add_virt(pool->private_data, vaddr, paddr, size, -1); in tee_shm_pool_alloc_res_mem()
80 gen_pool_destroy(pool->private_data); in tee_shm_pool_alloc_res_mem()
84 pool->ops = &pool_ops_generic; in tee_shm_pool_alloc_res_mem()
86 return pool; in tee_shm_pool_alloc_res_mem()
88 kfree(pool); in tee_shm_pool_alloc_res_mem()