Lines Matching full:pool
49 * hisi_acc_create_sgl_pool() - Create a hw sgl pool.
50 * @dev: The device which hw sgl pool belongs to.
51 * @count: Count of hisi_acc_hw_sgl in pool.
54 * This function creates a hw sgl pool, after this user can get hw sgl memory
61 struct hisi_acc_sgl_pool *pool; in hisi_acc_create_sgl_pool() local
73 * the pool may allocate a block of memory of size PAGE_SIZE * 2^MAX_PAGE_ORDER, in hisi_acc_create_sgl_pool()
86 pool = kzalloc(sizeof(*pool), GFP_KERNEL); in hisi_acc_create_sgl_pool()
87 if (!pool) in hisi_acc_create_sgl_pool()
89 block = pool->mem_block; in hisi_acc_create_sgl_pool()
115 pool->sgl_num_per_block = sgl_num_per_block; in hisi_acc_create_sgl_pool()
116 pool->block_num = remain_sgl ? block_num + 1 : block_num; in hisi_acc_create_sgl_pool()
117 pool->count = count; in hisi_acc_create_sgl_pool()
118 pool->sgl_size = sgl_size; in hisi_acc_create_sgl_pool()
119 pool->sge_nr = sge_nr; in hisi_acc_create_sgl_pool()
121 return pool; in hisi_acc_create_sgl_pool()
128 kfree_sensitive(pool); in hisi_acc_create_sgl_pool()
134 * hisi_acc_free_sgl_pool() - Free a hw sgl pool.
135 * @dev: The device which hw sgl pool belongs to.
136 * @pool: Pointer of pool.
138 * This function frees memory of a hw sgl pool.
140 void hisi_acc_free_sgl_pool(struct device *dev, struct hisi_acc_sgl_pool *pool) in hisi_acc_free_sgl_pool() argument
145 if (!dev || !pool) in hisi_acc_free_sgl_pool()
148 block = pool->mem_block; in hisi_acc_free_sgl_pool()
150 for (i = 0; i < pool->block_num; i++) in hisi_acc_free_sgl_pool()
154 kfree(pool); in hisi_acc_free_sgl_pool()
158 static struct hisi_acc_hw_sgl *acc_get_sgl(struct hisi_acc_sgl_pool *pool, in acc_get_sgl() argument
164 block = pool->mem_block; in acc_get_sgl()
165 block_index = index / pool->sgl_num_per_block; in acc_get_sgl()
166 offset = index % pool->sgl_num_per_block; in acc_get_sgl()
168 *hw_sgl_dma = block[block_index].sgl_dma + pool->sgl_size * offset; in acc_get_sgl()
169 return (void *)block[block_index].sgl + pool->sgl_size * offset; in acc_get_sgl()
210 * @pool: Pool which hw sgl memory will be allocated in.
211 * @index: Index of hisi_acc_hw_sgl in pool.
220 struct hisi_acc_sgl_pool *pool, u32 index, in hisi_acc_sg_buf_map_to_hw_sgl() argument
230 if (!dev || !sgl || !pool || !hw_sgl_dma || index >= pool->count) in hisi_acc_sg_buf_map_to_hw_sgl()
241 if (sg_n_mapped > pool->sge_nr) { in hisi_acc_sg_buf_map_to_hw_sgl()
242 dev_err(dev, "the number of entries in input scatterlist is bigger than SGL pool setting.\n"); in hisi_acc_sg_buf_map_to_hw_sgl()
247 curr_hw_sgl = acc_get_sgl(pool, index, &curr_sgl_dma); in hisi_acc_sg_buf_map_to_hw_sgl()
248 curr_hw_sgl->entry_length_in_sgl = cpu_to_le16(pool->sge_nr); in hisi_acc_sg_buf_map_to_hw_sgl()
257 update_hw_sgl_sum_sge(curr_hw_sgl, pool->sge_nr); in hisi_acc_sg_buf_map_to_hw_sgl()