diff mbox series

[2/2] dma-heap: Provide accessors so that in-kernel drivers can allocate dmabufs from specific heaps

Message ID 20200505195855.94934-2-john.stultz@linaro.org
State New
Headers show
Series [1/2] dma-heap: Refactor code to allow for future in-kernel users | expand

Commit Message

John Stultz May 5, 2020, 7:58 p.m. UTC
Really early RFC. Basically trying to provide in-kernel accessors
to the DMA-BUF heaps, similar to what the ion interface provided

Before we can push this patch, we need an actual in-kernel user

Signed-off-by: John Stultz <john.stultz@linaro.org>

---
 drivers/dma-buf/dma-heap.c |  8 ++++----
 include/linux/dma-heap.h   | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
index de09a0626a61..f4f699f9c8c4 100644
--- a/drivers/dma-buf/dma-heap.c
+++ b/drivers/dma-buf/dma-heap.c
@@ -48,7 +48,7 @@  static dev_t dma_heap_devt;
 static struct class *dma_heap_class;
 static DEFINE_XARRAY_ALLOC(dma_heap_minors);
 
-static struct dma_heap *dma_heap_find(const char* name)
+struct dma_heap *dma_heap_find(const char* name)
 {
 	struct dma_heap *h;
 
@@ -64,9 +64,9 @@  static struct dma_heap *dma_heap_find(const char* name)
 	return NULL;
 }
 
-static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
-				 unsigned int fd_flags,
-				 unsigned int heap_flags)
+int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
+			  unsigned int fd_flags,
+			  unsigned int heap_flags)
 {
 	if (fd_flags & ~DMA_HEAP_VALID_FD_FLAGS)
 		return -EINVAL;
diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h
index 454e354d1ffb..2971b0b5f223 100644
--- a/include/linux/dma-heap.h
+++ b/include/linux/dma-heap.h
@@ -56,4 +56,22 @@  void *dma_heap_get_drvdata(struct dma_heap *heap);
  */
 struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info);
 
+
+
+/**
+ * dma_heap_find - Returns the registered dma_heap with the specified name
+ * @name: Name of the heap to find
+ */
+struct dma_heap *dma_heap_find(char* name);
+
+/**
+ * dma_heap_buffer_alloc - Allocate dma-buf from a dma_heap
+ * @heap:	dma_heap to allocate from
+ * @len:	size to allocate
+ * @fd_flags:	flags to set on returned dma-buf fd
+ * @heap_flags:	flags to pass to the dma heap
+ */
+int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
+                          unsigned int fd_flags,
+                          unsigned int heap_flags);
 #endif /* _DMA_HEAPS_H */