[PATCH v3 6/6] dma-buf: heaps: coherent: Turn heap into a module

From: Albert Esteve

Date: Fri Mar 06 2026 - 05:40:41 EST


Following the current efforts to make CMA heap as module,
we can do the same and turn the Coherent heap into
a module as well, by changing the Kconfig into a tristate
and importing the proper dma-buf namespaces.

This heap won't be able to unload (same as happens with
the CMA heap), since we're missing a big part of the
infrastructure that would allow to make it safe.

Signed-off-by: Albert Esteve <aesteve@xxxxxxxxxx>
---
drivers/dma-buf/heaps/Kconfig | 2 +-
drivers/dma-buf/heaps/coherent_heap.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/heaps/Kconfig b/drivers/dma-buf/heaps/Kconfig
index aeb475e585048..2f84a1018b900 100644
--- a/drivers/dma-buf/heaps/Kconfig
+++ b/drivers/dma-buf/heaps/Kconfig
@@ -14,7 +14,7 @@ config DMABUF_HEAPS_CMA
regions, you should say Y here.

config DMABUF_HEAPS_COHERENT
- bool "DMA-BUF Coherent Reserved-Memory Heap"
+ tristate "DMA-BUF Coherent Reserved-Memory Heap"
depends on DMABUF_HEAPS && OF_RESERVED_MEM && DMA_DECLARE_COHERENT
help
Choose this option to enable coherent reserved-memory dma-buf heaps.
diff --git a/drivers/dma-buf/heaps/coherent_heap.c b/drivers/dma-buf/heaps/coherent_heap.c
index 55f53f87c4c15..fdb3f5d907e88 100644
--- a/drivers/dma-buf/heaps/coherent_heap.c
+++ b/drivers/dma-buf/heaps/coherent_heap.c
@@ -412,3 +412,6 @@ static int __init coherent_heap_register(void)
}
module_init(coherent_heap_register);
MODULE_DESCRIPTION("DMA-BUF heap for coherent reserved-memory regions");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("DMA_BUF");
+MODULE_IMPORT_NS("DMA_BUF_HEAP");

--
2.52.0