The CMA code, in addition to the reserved-memory regions in the device
tree, will also register a default CMA region if the device tree doesn't
provide any, with its size and position coming from either the kernel
command-line or configuration.

Let's register that one for use to create a heap for it.

Reviewed-by: T.J. Mercier <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
 kernel/dma/contiguous.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 
d67e95094749d45f43c1809c175e491a3f55b2e1..d8fd6f779f797f711b8e0fd628f868d644b8f784
 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -240,17 +240,23 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
                selected_size = max(size_bytes, cma_early_percent_memory());
 #endif
        }
 
        if (selected_size && !dma_contiguous_default_area) {
+               int ret;
+
                pr_debug("%s: reserving %ld MiB for global area\n", __func__,
                         (unsigned long)selected_size / SZ_1M);
 
                dma_contiguous_reserve_area(selected_size, selected_base,
                                            selected_limit,
                                            &dma_contiguous_default_area,
                                            fixed);
+
+               ret = dma_heap_cma_register_heap(dma_contiguous_default_area);
+               if (ret)
+                       pr_warn("Couldn't register default CMA heap.");
        }
 }
 
 void __weak
 dma_contiguous_early_fixup(phys_addr_t base, unsigned long size)

-- 
2.51.0

Reply via email to