Lines Matching refs:pool
27 void k3_cppi_desc_pool_destroy(struct k3_cppi_desc_pool *pool) in k3_cppi_desc_pool_destroy() argument
29 if (!pool) in k3_cppi_desc_pool_destroy()
32 WARN(gen_pool_size(pool->gen_pool) != gen_pool_avail(pool->gen_pool), in k3_cppi_desc_pool_destroy()
34 gen_pool_size(pool->gen_pool), in k3_cppi_desc_pool_destroy()
35 gen_pool_avail(pool->gen_pool)); in k3_cppi_desc_pool_destroy()
36 if (pool->cpumem) in k3_cppi_desc_pool_destroy()
37 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumem, in k3_cppi_desc_pool_destroy()
38 pool->dma_addr); in k3_cppi_desc_pool_destroy()
40 gen_pool_destroy(pool->gen_pool); /* frees pool->name */ in k3_cppi_desc_pool_destroy()
49 struct k3_cppi_desc_pool *pool; in k3_cppi_desc_pool_create_name() local
53 pool = devm_kzalloc(dev, sizeof(*pool), GFP_KERNEL); in k3_cppi_desc_pool_create_name()
54 if (!pool) in k3_cppi_desc_pool_create_name()
57 pool->dev = dev; in k3_cppi_desc_pool_create_name()
58 pool->desc_size = roundup_pow_of_two(desc_size); in k3_cppi_desc_pool_create_name()
59 pool->num_desc = size; in k3_cppi_desc_pool_create_name()
60 pool->mem_size = pool->num_desc * pool->desc_size; in k3_cppi_desc_pool_create_name()
62 pool_name = kstrdup_const(name ? name : dev_name(pool->dev), in k3_cppi_desc_pool_create_name()
67 pool->gen_pool = gen_pool_create(ilog2(pool->desc_size), -1); in k3_cppi_desc_pool_create_name()
68 if (!pool->gen_pool) { in k3_cppi_desc_pool_create_name()
70 dev_err(pool->dev, "pool create failed %d\n", ret); in k3_cppi_desc_pool_create_name()
75 pool->gen_pool->name = pool_name; in k3_cppi_desc_pool_create_name()
77 pool->cpumem = dma_alloc_coherent(pool->dev, pool->mem_size, in k3_cppi_desc_pool_create_name()
78 &pool->dma_addr, GFP_KERNEL); in k3_cppi_desc_pool_create_name()
80 if (!pool->cpumem) in k3_cppi_desc_pool_create_name()
83 ret = gen_pool_add_virt(pool->gen_pool, (unsigned long)pool->cpumem, in k3_cppi_desc_pool_create_name()
84 (phys_addr_t)pool->dma_addr, pool->mem_size, in k3_cppi_desc_pool_create_name()
87 dev_err(pool->dev, "pool add failed %d\n", ret); in k3_cppi_desc_pool_create_name()
91 return pool; in k3_cppi_desc_pool_create_name()
94 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumem, in k3_cppi_desc_pool_create_name()
95 pool->dma_addr); in k3_cppi_desc_pool_create_name()
97 gen_pool_destroy(pool->gen_pool); /* frees pool->name */ in k3_cppi_desc_pool_create_name()
99 devm_kfree(pool->dev, pool); in k3_cppi_desc_pool_create_name()
104 dma_addr_t k3_cppi_desc_pool_virt2dma(struct k3_cppi_desc_pool *pool, in k3_cppi_desc_pool_virt2dma() argument
107 return addr ? pool->dma_addr + (addr - pool->cpumem) : 0; in k3_cppi_desc_pool_virt2dma()
111 void *k3_cppi_desc_pool_dma2virt(struct k3_cppi_desc_pool *pool, dma_addr_t dma) in k3_cppi_desc_pool_dma2virt() argument
113 return dma ? pool->cpumem + (dma - pool->dma_addr) : NULL; in k3_cppi_desc_pool_dma2virt()
117 void *k3_cppi_desc_pool_alloc(struct k3_cppi_desc_pool *pool) in k3_cppi_desc_pool_alloc() argument
119 return (void *)gen_pool_alloc(pool->gen_pool, pool->desc_size); in k3_cppi_desc_pool_alloc()
123 void k3_cppi_desc_pool_free(struct k3_cppi_desc_pool *pool, void *addr) in k3_cppi_desc_pool_free() argument
125 gen_pool_free(pool->gen_pool, (unsigned long)addr, pool->desc_size); in k3_cppi_desc_pool_free()
129 size_t k3_cppi_desc_pool_avail(struct k3_cppi_desc_pool *pool) in k3_cppi_desc_pool_avail() argument
131 return gen_pool_avail(pool->gen_pool) / pool->desc_size; in k3_cppi_desc_pool_avail()