Lines Matching refs:pool

110 	struct vsp1_dl_body_pool *pool;  member
227 struct vsp1_dl_body_pool *pool; member
251 struct vsp1_dl_body_pool *pool; in vsp1_dl_body_pool_create() local
255 pool = kzalloc(sizeof(*pool), GFP_KERNEL); in vsp1_dl_body_pool_create()
256 if (!pool) in vsp1_dl_body_pool_create()
259 pool->vsp1 = vsp1; in vsp1_dl_body_pool_create()
268 pool->size = dlb_size * num_bodies; in vsp1_dl_body_pool_create()
270 pool->bodies = kcalloc(num_bodies, sizeof(*pool->bodies), GFP_KERNEL); in vsp1_dl_body_pool_create()
271 if (!pool->bodies) { in vsp1_dl_body_pool_create()
272 kfree(pool); in vsp1_dl_body_pool_create()
276 pool->mem = dma_alloc_wc(vsp1->bus_master, pool->size, &pool->dma, in vsp1_dl_body_pool_create()
278 if (!pool->mem) { in vsp1_dl_body_pool_create()
279 kfree(pool->bodies); in vsp1_dl_body_pool_create()
280 kfree(pool); in vsp1_dl_body_pool_create()
284 spin_lock_init(&pool->lock); in vsp1_dl_body_pool_create()
285 INIT_LIST_HEAD(&pool->free); in vsp1_dl_body_pool_create()
288 struct vsp1_dl_body *dlb = &pool->bodies[i]; in vsp1_dl_body_pool_create()
290 dlb->pool = pool; in vsp1_dl_body_pool_create()
293 dlb->dma = pool->dma + i * dlb_size; in vsp1_dl_body_pool_create()
294 dlb->entries = pool->mem + i * dlb_size; in vsp1_dl_body_pool_create()
296 list_add_tail(&dlb->free, &pool->free); in vsp1_dl_body_pool_create()
299 return pool; in vsp1_dl_body_pool_create()
308 void vsp1_dl_body_pool_destroy(struct vsp1_dl_body_pool *pool) in vsp1_dl_body_pool_destroy() argument
310 if (!pool) in vsp1_dl_body_pool_destroy()
313 if (pool->mem) in vsp1_dl_body_pool_destroy()
314 dma_free_wc(pool->vsp1->bus_master, pool->size, pool->mem, in vsp1_dl_body_pool_destroy()
315 pool->dma); in vsp1_dl_body_pool_destroy()
317 kfree(pool->bodies); in vsp1_dl_body_pool_destroy()
318 kfree(pool); in vsp1_dl_body_pool_destroy()
329 struct vsp1_dl_body *vsp1_dl_body_get(struct vsp1_dl_body_pool *pool) in vsp1_dl_body_get() argument
334 spin_lock_irqsave(&pool->lock, flags); in vsp1_dl_body_get()
336 if (!list_empty(&pool->free)) { in vsp1_dl_body_get()
337 dlb = list_first_entry(&pool->free, struct vsp1_dl_body, free); in vsp1_dl_body_get()
342 spin_unlock_irqrestore(&pool->lock, flags); in vsp1_dl_body_get()
365 spin_lock_irqsave(&dlb->pool->lock, flags); in vsp1_dl_body_put()
366 list_add_tail(&dlb->free, &dlb->pool->free); in vsp1_dl_body_put()
367 spin_unlock_irqrestore(&dlb->pool->lock, flags); in vsp1_dl_body_put()
426 struct vsp1_dl_cmd_pool *pool; in vsp1_dl_cmd_pool_create() local
430 pool = kzalloc(sizeof(*pool), GFP_KERNEL); in vsp1_dl_cmd_pool_create()
431 if (!pool) in vsp1_dl_cmd_pool_create()
434 spin_lock_init(&pool->lock); in vsp1_dl_cmd_pool_create()
435 INIT_LIST_HEAD(&pool->free); in vsp1_dl_cmd_pool_create()
437 pool->cmds = kcalloc(num_cmds, sizeof(*pool->cmds), GFP_KERNEL); in vsp1_dl_cmd_pool_create()
438 if (!pool->cmds) { in vsp1_dl_cmd_pool_create()
439 kfree(pool); in vsp1_dl_cmd_pool_create()
447 pool->size = cmd_size * num_cmds; in vsp1_dl_cmd_pool_create()
448 pool->mem = dma_alloc_wc(vsp1->bus_master, pool->size, &pool->dma, in vsp1_dl_cmd_pool_create()
450 if (!pool->mem) { in vsp1_dl_cmd_pool_create()
451 kfree(pool->cmds); in vsp1_dl_cmd_pool_create()
452 kfree(pool); in vsp1_dl_cmd_pool_create()
457 struct vsp1_dl_ext_cmd *cmd = &pool->cmds[i]; in vsp1_dl_cmd_pool_create()
463 cmd->pool = pool; in vsp1_dl_cmd_pool_create()
471 cmd->cmds = pool->mem + cmd_offset; in vsp1_dl_cmd_pool_create()
472 cmd->cmd_dma = pool->dma + cmd_offset; in vsp1_dl_cmd_pool_create()
474 cmd->data = pool->mem + data_offset; in vsp1_dl_cmd_pool_create()
475 cmd->data_dma = pool->dma + data_offset; in vsp1_dl_cmd_pool_create()
477 list_add_tail(&cmd->free, &pool->free); in vsp1_dl_cmd_pool_create()
480 return pool; in vsp1_dl_cmd_pool_create()
484 struct vsp1_dl_ext_cmd *vsp1_dl_ext_cmd_get(struct vsp1_dl_cmd_pool *pool) in vsp1_dl_ext_cmd_get() argument
489 spin_lock_irqsave(&pool->lock, flags); in vsp1_dl_ext_cmd_get()
491 if (!list_empty(&pool->free)) { in vsp1_dl_ext_cmd_get()
492 cmd = list_first_entry(&pool->free, struct vsp1_dl_ext_cmd, in vsp1_dl_ext_cmd_get()
497 spin_unlock_irqrestore(&pool->lock, flags); in vsp1_dl_ext_cmd_get()
512 spin_lock_irqsave(&cmd->pool->lock, flags); in vsp1_dl_ext_cmd_put()
513 list_add_tail(&cmd->free, &cmd->pool->free); in vsp1_dl_ext_cmd_put()
514 spin_unlock_irqrestore(&cmd->pool->lock, flags); in vsp1_dl_ext_cmd_put()
517 static void vsp1_dl_ext_cmd_pool_destroy(struct vsp1_dl_cmd_pool *pool) in vsp1_dl_ext_cmd_pool_destroy() argument
519 if (!pool) in vsp1_dl_ext_cmd_pool_destroy()
522 if (pool->mem) in vsp1_dl_ext_cmd_pool_destroy()
523 dma_free_wc(pool->vsp1->bus_master, pool->size, pool->mem, in vsp1_dl_ext_cmd_pool_destroy()
524 pool->dma); in vsp1_dl_ext_cmd_pool_destroy()
526 kfree(pool->cmds); in vsp1_dl_ext_cmd_pool_destroy()
527 kfree(pool); in vsp1_dl_ext_cmd_pool_destroy()
559 dl->body0 = vsp1_dl_body_get(dlm->pool); in vsp1_dl_list_alloc()
1054 return vsp1_dl_body_get(dlm->pool); in vsp1_dlm_dl_body_get()
1089 dlm->pool = vsp1_dl_body_pool_create(vsp1, prealloc + 1, in vsp1_dlm_create()
1091 if (!dlm->pool) in vsp1_dlm_create()
1135 vsp1_dl_body_pool_destroy(dlm->pool); in vsp1_dlm_destroy()