Lines Matching refs:pool

28 void k3_cppi_desc_pool_destroy(struct k3_cppi_desc_pool *pool)  in k3_cppi_desc_pool_destroy()  argument
30 if (!pool) in k3_cppi_desc_pool_destroy()
33 WARN(gen_pool_size(pool->gen_pool) != gen_pool_avail(pool->gen_pool), in k3_cppi_desc_pool_destroy()
35 gen_pool_size(pool->gen_pool), in k3_cppi_desc_pool_destroy()
36 gen_pool_avail(pool->gen_pool)); in k3_cppi_desc_pool_destroy()
37 if (pool->cpumem) in k3_cppi_desc_pool_destroy()
38 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumem, in k3_cppi_desc_pool_destroy()
39 pool->dma_addr); in k3_cppi_desc_pool_destroy()
41 kfree(pool->desc_infos); in k3_cppi_desc_pool_destroy()
43 gen_pool_destroy(pool->gen_pool); /* frees pool->name */ in k3_cppi_desc_pool_destroy()
45 kfree(pool); in k3_cppi_desc_pool_destroy()
54 struct k3_cppi_desc_pool *pool; in k3_cppi_desc_pool_create_name() local
58 pool = kzalloc(sizeof(*pool), GFP_KERNEL); in k3_cppi_desc_pool_create_name()
59 if (!pool) in k3_cppi_desc_pool_create_name()
62 pool->dev = dev; in k3_cppi_desc_pool_create_name()
63 pool->desc_size = roundup_pow_of_two(desc_size); in k3_cppi_desc_pool_create_name()
64 pool->num_desc = size; in k3_cppi_desc_pool_create_name()
65 pool->mem_size = pool->num_desc * pool->desc_size; in k3_cppi_desc_pool_create_name()
67 pool_name = kstrdup_const(name ? name : dev_name(pool->dev), in k3_cppi_desc_pool_create_name()
72 pool->gen_pool = gen_pool_create(ilog2(pool->desc_size), -1); in k3_cppi_desc_pool_create_name()
73 if (!pool->gen_pool) { in k3_cppi_desc_pool_create_name()
78 pool->gen_pool->name = pool_name; in k3_cppi_desc_pool_create_name()
80 pool->desc_infos = kcalloc(pool->num_desc, in k3_cppi_desc_pool_create_name()
81 sizeof(*pool->desc_infos), GFP_KERNEL); in k3_cppi_desc_pool_create_name()
82 if (!pool->desc_infos) in k3_cppi_desc_pool_create_name()
85 pool->cpumem = dma_alloc_coherent(pool->dev, pool->mem_size, in k3_cppi_desc_pool_create_name()
86 &pool->dma_addr, GFP_KERNEL); in k3_cppi_desc_pool_create_name()
88 if (!pool->cpumem) in k3_cppi_desc_pool_create_name()
91 ret = gen_pool_add_virt(pool->gen_pool, (unsigned long)pool->cpumem, in k3_cppi_desc_pool_create_name()
92 (phys_addr_t)pool->dma_addr, pool->mem_size, in k3_cppi_desc_pool_create_name()
95 dev_err(pool->dev, "pool add failed %d\n", ret); in k3_cppi_desc_pool_create_name()
99 return pool; in k3_cppi_desc_pool_create_name()
102 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumem, in k3_cppi_desc_pool_create_name()
103 pool->dma_addr); in k3_cppi_desc_pool_create_name()
105 kfree(pool->desc_infos); in k3_cppi_desc_pool_create_name()
107 gen_pool_destroy(pool->gen_pool); /* frees pool->name */ in k3_cppi_desc_pool_create_name()
109 kfree(pool); in k3_cppi_desc_pool_create_name()
114 dma_addr_t k3_cppi_desc_pool_virt2dma(struct k3_cppi_desc_pool *pool, in k3_cppi_desc_pool_virt2dma() argument
117 return addr ? pool->dma_addr + (addr - pool->cpumem) : 0; in k3_cppi_desc_pool_virt2dma()
121 void *k3_cppi_desc_pool_dma2virt(struct k3_cppi_desc_pool *pool, dma_addr_t dma) in k3_cppi_desc_pool_dma2virt() argument
123 return dma ? pool->cpumem + (dma - pool->dma_addr) : NULL; in k3_cppi_desc_pool_dma2virt()
127 void *k3_cppi_desc_pool_alloc(struct k3_cppi_desc_pool *pool) in k3_cppi_desc_pool_alloc() argument
129 return (void *)gen_pool_alloc(pool->gen_pool, pool->desc_size); in k3_cppi_desc_pool_alloc()
133 void k3_cppi_desc_pool_free(struct k3_cppi_desc_pool *pool, void *addr) in k3_cppi_desc_pool_free() argument
135 gen_pool_free(pool->gen_pool, (unsigned long)addr, pool->desc_size); in k3_cppi_desc_pool_free()
139 size_t k3_cppi_desc_pool_avail(struct k3_cppi_desc_pool *pool) in k3_cppi_desc_pool_avail() argument
141 return gen_pool_avail(pool->gen_pool) / pool->desc_size; in k3_cppi_desc_pool_avail()
145 size_t k3_cppi_desc_pool_desc_size(const struct k3_cppi_desc_pool *pool) in k3_cppi_desc_pool_desc_size() argument
147 return pool->desc_size; in k3_cppi_desc_pool_desc_size()
151 void *k3_cppi_desc_pool_cpuaddr(const struct k3_cppi_desc_pool *pool) in k3_cppi_desc_pool_cpuaddr() argument
153 return pool->cpumem; in k3_cppi_desc_pool_cpuaddr()
157 void k3_cppi_desc_pool_desc_info_set(struct k3_cppi_desc_pool *pool, in k3_cppi_desc_pool_desc_info_set() argument
160 pool->desc_infos[desc_idx] = info; in k3_cppi_desc_pool_desc_info_set()
164 void *k3_cppi_desc_pool_desc_info(const struct k3_cppi_desc_pool *pool, in k3_cppi_desc_pool_desc_info() argument
167 return pool->desc_infos[desc_idx]; in k3_cppi_desc_pool_desc_info()