Lines Matching +full:dma +full:- +full:pool

1 // SPDX-License-Identifier: GPL-2.0
3 * DMA memory management for framework level HCD code (hc_driver)
17 #include <linux/dma-mapping.h>
25 * DMA-Coherent Buffers
28 /* FIXME tune these based on pool statistics ... */
44 pool_max[0] = 0; /* Don't use this pool */ in usb_init_pool_max()
52 * hcd_buffer_create - initialize buffer pools
57 * Call this as part of initializing a host controller that uses the dma
58 * memory allocators. It initializes some pools of dma-coherent memory that
70 if (hcd->localmem_pool || !hcd_uses_dma(hcd)) in hcd_buffer_create()
77 snprintf(name, sizeof(name), "buffer-%d", size); in hcd_buffer_create()
78 hcd->pool[i] = dma_pool_create(name, hcd->self.sysdev, in hcd_buffer_create()
80 if (!hcd->pool[i]) { in hcd_buffer_create()
82 return -ENOMEM; in hcd_buffer_create()
90 * hcd_buffer_destroy - deallocate buffer pools
105 dma_pool_destroy(hcd->pool[i]); in hcd_buffer_destroy()
106 hcd->pool[i] = NULL; in hcd_buffer_destroy()
119 dma_addr_t *dma in hcd_buffer_alloc() argument
128 if (hcd->localmem_pool) in hcd_buffer_alloc()
129 return gen_pool_dma_alloc(hcd->localmem_pool, size, dma); in hcd_buffer_alloc()
133 *dma = ~(dma_addr_t) 0; in hcd_buffer_alloc()
139 return dma_pool_alloc(hcd->pool[i], mem_flags, dma); in hcd_buffer_alloc()
141 return dma_alloc_coherent(hcd->self.sysdev, size, dma, mem_flags); in hcd_buffer_alloc()
148 dma_addr_t dma in hcd_buffer_free() argument
157 if (hcd->localmem_pool) { in hcd_buffer_free()
158 gen_pool_free(hcd->localmem_pool, (unsigned long)addr, size); in hcd_buffer_free()
169 dma_pool_free(hcd->pool[i], addr, dma); in hcd_buffer_free()
173 dma_free_coherent(hcd->self.sysdev, size, addr, dma); in hcd_buffer_free()
177 size_t size, gfp_t mem_flags, dma_addr_t *dma) in hcd_buffer_alloc_pages() argument
182 if (hcd->localmem_pool) in hcd_buffer_alloc_pages()
183 return gen_pool_dma_alloc_align(hcd->localmem_pool, in hcd_buffer_alloc_pages()
184 size, dma, PAGE_SIZE); in hcd_buffer_alloc_pages()
188 *dma = DMA_MAPPING_ERROR; in hcd_buffer_alloc_pages()
193 return dma_alloc_coherent(hcd->self.sysdev, in hcd_buffer_alloc_pages()
194 size, dma, mem_flags); in hcd_buffer_alloc_pages()
198 size_t size, void *addr, dma_addr_t dma) in hcd_buffer_free_pages() argument
203 if (hcd->localmem_pool) { in hcd_buffer_free_pages()
204 gen_pool_free(hcd->localmem_pool, in hcd_buffer_free_pages()
214 dma_free_coherent(hcd->self.sysdev, size, addr, dma); in hcd_buffer_free_pages()