• Home
  • Raw
  • Download

Lines Matching full:heap

13  drivers/dma-buf/dma-heap.c                   | 223 +++++--
19 drivers/dma-buf/heaps/heap-helpers.c | 1 -
26 include/linux/dma-heap.h | 62 +-
262 diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
264 --- a/drivers/dma-buf/dma-heap.c
265 +++ b/drivers/dma-buf/dma-heap.c
273 #include <linux/dma-heap.h>
275 * @heap_devt heap device node
277 * @heap_cdev heap char device
278 + * @heap_dev heap device struct
280 * Represents a heap of memory from which buffers can be made.
295 -static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
322 +struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
340 return heap->ops->allocate(heap, len, fd_flags, heap_flags);
344 +int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len,
351 + dmabuf = dma_heap_buffer_alloc(heap, len, fd_flags, heap_flags);
378 - fd = dma_heap_buffer_alloc(heap, heap_allocation->len,
381 + fd = dma_heap_bufferfd_alloc(heap, heap_allocation->len,
395 @@ -189,6 +240,47 @@ void *dma_heap_get_drvdata(struct dma_heap *heap)
397 return heap->priv;
403 + struct dma_heap *heap = container_of(ref, struct dma_heap, refcount);
404 + int minor = MINOR(heap->heap_devt);
407 + list_del(&heap->list);
409 + device_destroy(dma_heap_class, heap->heap_devt);
410 + cdev_del(&heap->heap_cdev);
413 + kfree(heap);
429 + * dma_heap_get_dev() - get device struct for the heap
430 + * @heap: DMA-Heap to retrieve device struct from
433 + * The device struct for the heap.
435 +struct device *dma_heap_get_dev(struct dma_heap *heap)
437 + return heap->heap_dev;
442 * dma_heap_get_name() - get heap name
443 @@ -201,11 +293,11 @@ const char *dma_heap_get_name(struct dma_heap *heap)
445 return heap->name;
451 - struct dma_heap *heap, *h, *err_ret;
453 + struct dma_heap *heap, *err_ret;
465 - pr_err("dma_heap: Already registered heap named %s\n",
469 + heap = dma_heap_find(exp_info->name);
470 + if (heap) {
471 + pr_err("dma_heap: Already registered heap named %s\n",
473 + dma_heap_put(heap);
478 heap = kzalloc(sizeof(*heap), GFP_KERNEL);
479 if (!heap)
482 + kref_init(&heap->refcount);
483 heap->name = exp_info->name;
484 heap->ops = exp_info->ops;
485 heap->priv = exp_info->priv;
492 - heap->heap_devt,
494 - heap->name);
496 + heap->heap_dev = device_create(dma_heap_class,
498 + heap->heap_devt,
500 + heap->name);
501 + if (IS_ERR(heap->heap_dev)) {
504 + err_ret = ERR_CAST(heap->heap_dev);
509 + heap->heap_dev = get_device(heap->heap_dev);
511 /* Add heap to the list */
513 list_add(&heap->list, &heap_list);
515 kfree(heap);
528 + struct dma_heap *heap;
532 + list_for_each_entry(heap, &heap_list, list) {
533 + if (heap->ops->get_pool_size)
534 + total_pool_size += heap->ops->get_pool_size(heap);
622 - bool "DMA-BUF System Heap"
624 + tristate "DMA-BUF System Heap"
627 Choose this option to enable the system dmabuf heap. The system heap
631 - bool "DMA-BUF CMA Heap"
632 + tristate "DMA-BUF CMA Heap"
635 Choose this option to enable dma-buf CMA heap. This heap is backed
642 -obj-y += heap-helpers.o
653 * DMABUF CMA heap exporter
659 + * Also utilizing parts of Andrew Davis' SRAM heap:
667 #include <linux/dma-heap.h>
681 -#include "heap-helpers.h"
684 struct dma_heap *heap;
690 + struct cma_heap *heap;
758 - struct cma_heap *cma_heap = dma_heap_get_drvdata(buffer->heap);
905 + struct cma_heap *cma_heap = buffer->heap;
920 -/* dmabuf heap CMA operations functions */
921 -static int cma_heap_allocate(struct dma_heap *heap,
938 +static struct dma_buf *cma_heap_allocate(struct dma_heap *heap,
943 struct cma_heap *cma_heap = dma_heap_get_drvdata(heap);
971 - helper_buffer->heap = heap;
989 @@ -85,7 +315,6 @@ static int cma_heap_allocate(struct dma_heap *heap,
997 @@ -93,44 +322,41 @@ static int cma_heap_allocate(struct dma_heap *heap,
1018 + buffer->heap = cma_heap;
1023 + exp_info.exp_name = dma_heap_get_name(heap);
1271 diff --git a/drivers/dma-buf/heaps/heap-helpers.c b/drivers/dma-buf/heaps/heap-helpers.c
1273 --- a/drivers/dma-buf/heaps/heap-helpers.c
1274 +++ b/drivers/dma-buf/heaps/heap-helpers.c
1279 - exp_info.exp_name = dma_heap_get_name(buffer->heap);
1602 * DMABUF System heap exporter
1608 + * Portions based off of Andrew Davis' SRAM heap:
1629 + struct dma_heap *heap;
1647 -#include "heap-helpers.h"
1699 -static int system_heap_allocate(struct dma_heap *heap,
1756 - helper_buffer->heap = heap;
2025 +static struct dma_buf *system_heap_do_allocate(struct dma_heap *heap,
2048 + buffer->heap = heap;
2090 + exp_info.exp_name = dma_heap_get_name(heap);
2109 + dma_map_sgtable(dma_heap_get_dev(heap), table, DMA_BIDIRECTIONAL, 0);
2110 + dma_unmap_sgtable(dma_heap_get_dev(heap), table, DMA_BIDIRECTIONAL, 0);
2143 +static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
2148 + return system_heap_do_allocate(heap, len, fd_flags, heap_flags, false);
2152 +static long system_get_pool_size(struct dma_heap *heap)
2172 +static struct dma_buf *system_uncached_heap_allocate(struct dma_heap *heap,
2177 + return system_heap_do_allocate(heap, len, fd_flags, heap_flags, true);
2181 +static struct dma_buf *system_uncached_heap_not_initialized(struct dma_heap *heap,
2339 diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h
2341 --- a/include/linux/dma-heap.h
2342 +++ b/include/linux/dma-heap.h
2346 * struct dma_heap_ops - ops to operate on a given heap
2349 + * @get_pool_size: if heap maintains memory pools, get pool size in bytes
2355 - int (*allocate)(struct dma_heap *heap,
2356 + struct dma_buf *(*allocate)(struct dma_heap *heap,
2360 + long (*get_pool_size)(struct dma_heap *heap);
2366 void *dma_heap_get_drvdata(struct dma_heap *heap);
2369 + * dma_heap_get_dev() - get device struct for the heap
2370 + * @heap: DMA-Heap to retrieve device struct from
2373 + * The device struct for the heap.
2375 +struct device *dma_heap_get_dev(struct dma_heap *heap);
2378 * dma_heap_get_name() - get heap name
2379 * @heap: DMA-Heap to retrieve private data for
2380 @@ -65,4 +76,49 @@ const char *dma_heap_get_name(struct dma_heap *heap);
2386 + * @heap: heap pointer
2388 +void dma_heap_put(struct dma_heap *heap);
2392 + * @name: Name of the heap to find
2401 + * @heap: dma_heap to allocate from
2404 + * @heap_flags: flags to pass to the dma heap
2408 +struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
2421 + * @heap: dma_heap to allocate from
2424 + * @heap_flags: flags to pass to the dma heap
2426 +int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len,