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 pool->vsp1 = vsp1; in vsp1_dl_cmd_pool_create()
436 spin_lock_init(&pool->lock); in vsp1_dl_cmd_pool_create()
437 INIT_LIST_HEAD(&pool->free); in vsp1_dl_cmd_pool_create()
439 pool->cmds = kcalloc(num_cmds, sizeof(*pool->cmds), GFP_KERNEL); in vsp1_dl_cmd_pool_create()
440 if (!pool->cmds) { in vsp1_dl_cmd_pool_create()
441 kfree(pool); in vsp1_dl_cmd_pool_create()
449 pool->size = cmd_size * num_cmds; in vsp1_dl_cmd_pool_create()
450 pool->mem = dma_alloc_wc(vsp1->bus_master, pool->size, &pool->dma, in vsp1_dl_cmd_pool_create()
452 if (!pool->mem) { in vsp1_dl_cmd_pool_create()
453 kfree(pool->cmds); in vsp1_dl_cmd_pool_create()
454 kfree(pool); in vsp1_dl_cmd_pool_create()
459 struct vsp1_dl_ext_cmd *cmd = &pool->cmds[i]; in vsp1_dl_cmd_pool_create()
465 cmd->pool = pool; in vsp1_dl_cmd_pool_create()
473 cmd->cmds = pool->mem + cmd_offset; in vsp1_dl_cmd_pool_create()
474 cmd->cmd_dma = pool->dma + cmd_offset; in vsp1_dl_cmd_pool_create()
476 cmd->data = pool->mem + data_offset; in vsp1_dl_cmd_pool_create()
477 cmd->data_dma = pool->dma + data_offset; in vsp1_dl_cmd_pool_create()
479 list_add_tail(&cmd->free, &pool->free); in vsp1_dl_cmd_pool_create()
482 return pool; in vsp1_dl_cmd_pool_create()
486 struct vsp1_dl_ext_cmd *vsp1_dl_ext_cmd_get(struct vsp1_dl_cmd_pool *pool) in vsp1_dl_ext_cmd_get() argument
491 spin_lock_irqsave(&pool->lock, flags); in vsp1_dl_ext_cmd_get()
493 if (!list_empty(&pool->free)) { in vsp1_dl_ext_cmd_get()
494 cmd = list_first_entry(&pool->free, struct vsp1_dl_ext_cmd, in vsp1_dl_ext_cmd_get()
499 spin_unlock_irqrestore(&pool->lock, flags); in vsp1_dl_ext_cmd_get()
514 spin_lock_irqsave(&cmd->pool->lock, flags); in vsp1_dl_ext_cmd_put()
515 list_add_tail(&cmd->free, &cmd->pool->free); in vsp1_dl_ext_cmd_put()
516 spin_unlock_irqrestore(&cmd->pool->lock, flags); in vsp1_dl_ext_cmd_put()
519 static void vsp1_dl_ext_cmd_pool_destroy(struct vsp1_dl_cmd_pool *pool) in vsp1_dl_ext_cmd_pool_destroy() argument
521 if (!pool) in vsp1_dl_ext_cmd_pool_destroy()
524 if (pool->mem) in vsp1_dl_ext_cmd_pool_destroy()
525 dma_free_wc(pool->vsp1->bus_master, pool->size, pool->mem, in vsp1_dl_ext_cmd_pool_destroy()
526 pool->dma); in vsp1_dl_ext_cmd_pool_destroy()
528 kfree(pool->cmds); in vsp1_dl_ext_cmd_pool_destroy()
529 kfree(pool); in vsp1_dl_ext_cmd_pool_destroy()
561 dl->body0 = vsp1_dl_body_get(dlm->pool); in vsp1_dl_list_alloc()
1086 return vsp1_dl_body_get(dlm->pool); in vsp1_dlm_dl_body_get()
1121 dlm->pool = vsp1_dl_body_pool_create(vsp1, prealloc + 1, in vsp1_dlm_create()
1123 if (!dlm->pool) in vsp1_dlm_create()
1167 vsp1_dl_body_pool_destroy(dlm->pool); in vsp1_dlm_destroy()