Lines Matching full:dma

12 #include <linux/dma-buf-cache.h>
13 #include <linux/dma-iommu.h>
14 #include <linux/dma-mapping.h>
23 #include <asm/dma-iommu.h>
32 mpp_dma_find_buffer_fd(struct mpp_dma_session *dma, int fd) in mpp_dma_find_buffer_fd() argument
42 mutex_lock(&dma->list_mutex); in mpp_dma_find_buffer_fd()
44 &dma->used_list, link) { in mpp_dma_find_buffer_fd()
54 mutex_unlock(&dma->list_mutex); in mpp_dma_find_buffer_fd()
66 buffer->dma->buffer_count--; in mpp_dma_release_buffer()
67 list_move_tail(&buffer->link, &buffer->dma->unused_list); in mpp_dma_release_buffer()
72 buffer->dma = NULL; in mpp_dma_release_buffer()
85 mpp_dma_remove_extra_buffer(struct mpp_dma_session *dma) in mpp_dma_remove_extra_buffer() argument
91 if (dma->buffer_count > dma->max_buffers) { in mpp_dma_remove_extra_buffer()
92 mutex_lock(&dma->list_mutex); in mpp_dma_remove_extra_buffer()
94 &dma->used_list, in mpp_dma_remove_extra_buffer()
104 mutex_unlock(&dma->list_mutex); in mpp_dma_remove_extra_buffer()
110 int mpp_dma_release(struct mpp_dma_session *dma, in mpp_dma_release() argument
113 mutex_lock(&dma->list_mutex); in mpp_dma_release()
115 mutex_unlock(&dma->list_mutex); in mpp_dma_release()
120 int mpp_dma_release_fd(struct mpp_dma_session *dma, int fd) in mpp_dma_release_fd() argument
122 struct device *dev = dma->dev; in mpp_dma_release_fd()
125 buffer = mpp_dma_find_buffer_fd(dma, fd); in mpp_dma_release_fd()
132 mutex_lock(&dma->list_mutex); in mpp_dma_release_fd()
134 mutex_unlock(&dma->list_mutex); in mpp_dma_release_fd()
179 struct mpp_dma_session *dma, in mpp_dma_import_fd() argument
188 if (!dma) { in mpp_dma_import_fd()
189 mpp_err("dma session is null\n"); in mpp_dma_import_fd()
195 mpp_dma_remove_extra_buffer(dma); in mpp_dma_import_fd()
197 /* Check whether in dma session */ in mpp_dma_import_fd()
198 buffer = mpp_dma_find_buffer_fd(dma, fd); in mpp_dma_import_fd()
204 dev_dbg(dma->dev, "missing the fd %d\n", fd); in mpp_dma_import_fd()
213 /* A new DMA buffer */ in mpp_dma_import_fd()
214 mutex_lock(&dma->list_mutex); in mpp_dma_import_fd()
215 buffer = list_first_entry_or_null(&dma->unused_list, in mpp_dma_import_fd()
220 mutex_unlock(&dma->list_mutex); in mpp_dma_import_fd()
224 mutex_unlock(&dma->list_mutex); in mpp_dma_import_fd()
230 attach = dma_buf_attach(buffer->dmabuf, dma->dev); in mpp_dma_import_fd()
247 buffer->dma = dma; in mpp_dma_import_fd()
255 mutex_lock(&dma->list_mutex); in mpp_dma_import_fd()
256 dma->buffer_count++; in mpp_dma_import_fd()
257 list_add_tail(&buffer->link, &dma->used_list); in mpp_dma_import_fd()
258 mutex_unlock(&dma->list_mutex); in mpp_dma_import_fd()
265 mutex_lock(&dma->list_mutex); in mpp_dma_import_fd()
266 list_add_tail(&buffer->link, &dma->unused_list); in mpp_dma_import_fd()
267 mutex_unlock(&dma->list_mutex); in mpp_dma_import_fd()
273 int mpp_dma_unmap_kernel(struct mpp_dma_session *dma, in mpp_dma_unmap_kernel() argument
291 int mpp_dma_map_kernel(struct mpp_dma_session *dma, in mpp_dma_map_kernel() argument
303 dev_dbg(dma->dev, "can't access the dma buffer\n"); in mpp_dma_map_kernel()
309 dev_dbg(dma->dev, "can't vmap the dma buffer\n"); in mpp_dma_map_kernel()
325 int mpp_dma_session_destroy(struct mpp_dma_session *dma) in mpp_dma_session_destroy() argument
329 if (!dma) in mpp_dma_session_destroy()
332 mutex_lock(&dma->list_mutex); in mpp_dma_session_destroy()
334 &dma->used_list, in mpp_dma_session_destroy()
338 mutex_unlock(&dma->list_mutex); in mpp_dma_session_destroy()
340 kfree(dma); in mpp_dma_session_destroy()
349 struct mpp_dma_session *dma = NULL; in mpp_dma_session_create() local
352 dma = kzalloc(sizeof(*dma), GFP_KERNEL); in mpp_dma_session_create()
353 if (!dma) in mpp_dma_session_create()
356 mutex_init(&dma->list_mutex); in mpp_dma_session_create()
357 INIT_LIST_HEAD(&dma->unused_list); in mpp_dma_session_create()
358 INIT_LIST_HEAD(&dma->used_list); in mpp_dma_session_create()
363 dma->max_buffers = MPP_SESSION_MAX_BUFFERS; in mpp_dma_session_create()
365 dma->max_buffers = max_buffers; in mpp_dma_session_create()
368 for (i = 0; i < ARRAY_SIZE(dma->dma_bufs); i++) { in mpp_dma_session_create()
369 buffer = &dma->dma_bufs[i]; in mpp_dma_session_create()
370 buffer->dma = dma; in mpp_dma_session_create()
372 list_add_tail(&buffer->link, &dma->unused_list); in mpp_dma_session_create()
374 dma->dev = dev; in mpp_dma_session_create()
376 return dma; in mpp_dma_session_create()
386 struct device *dev = buffer->dma->dev; in mpp_dma_buf_sync()