dma/contiguous: Fix broken build
Subsystems (4)
PATCH 1/1 dma/contiguous: Fix broken build
Commit 3a236f6a5cf2 ("dma: contiguous: Turn heap registration logic around") didn't remove one last call to dma_heap_cma_register_heap() that it removed, thus breaking the build.
That last call is in dma_contiguous_reserve(), to handle the registration of the default CMA region heap instance if it's declared in the device tree.
However, the default CMA region instance is already handled by retrieving it through dev_get_cma_area() in the CMA heap driver, so the call to dma_heap_cma_register_heap() wasn't actually needed.
Let's remove this call, the now unused function definition, its now empty header, and all includes of this header.
--- drivers/dma-buf/heaps/cma_heap.c | 1 - include/linux/dma-buf/heaps/cma.h | 16 ---------------- kernel/dma/contiguous.c | 5 ----- 3 files changed, 22 deletions(-)
drivers/dma-buf/heaps/cma_heap.c +0 -1
@@ -12,11 +12,10 @@#define pr_fmt (fmt) "cma_heap: " fmt#include <linux/cma.h> #include <linux/dma-buf.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-heap.h> #include <linux/dma-map-ops.h> #include <linux/err.h> #include <linux/highmem.h> #include <linux/io.h>
include/linux/dma-buf/heaps/cma.h deleted +0 -16
@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef DMA_BUF_HEAP_CMA_H_ -#define DMA_BUF_HEAP_CMA_H_ - -struct cma ; - -#ifdef CONFIG_DMABUF_HEAPS_CMA -int dma_heap_cma_register_heap (struct cma *cma); -#else -static inline int dma_heap_cma_register_heap (struct cma *cma) -{ -return 0 ; -} -#endif // CONFIG_DMABUF_HEAPS_CMA - -#endif // DMA_BUF_HEAP_CMA_H_
kernel/dma/contiguous.c +0 -5
@@ -40,11 +40,10 @@#include <asm/page.h> #include <linux/memblock.h> #include <linux/err.h> #include <linux/sizes.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-map-ops.h> #include <linux/cma.h> #include <linux/nospec.h> #ifdef CONFIG_CMA_SIZE_MBYTES
@@ -270,14 +269,10 @@ void __init dma_contiguous_reserve(phys_addr_t limit) selected_limit, &dma_contiguous_default_area, fixed);if (ret)return ; - - 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)
---
base-commit: f3948c8ed5ea206e87ea2375aebdbabc2064356a
change-id: 20260330-dma-build-fix-706a4feb0e0f
Best regards,
Signature · 1 line
Maxime Ripard <[email protected]>
Marek Szyprowski
maintainerQuoted 80 lines · Maxime Ripard
Commit
3a236f6a5cf2("dma: contiguous: Turn heap registration logic around") didn't remove one last call todma_heap_cma_register_heap()that it removed, thus breaking the build.That last call is in
dma_contiguous_reserve(), to handle the registration of the default CMA region heap instance if it's declared in the device tree.However, the default CMA region instance is already handled by retrieving it through
dev_get_cma_area()in the CMA heap driver, so the call todma_heap_cma_register_heap()wasn't actually needed.Let's remove this call, the now unused function definition, its now empty header, and all includes of this header.
Fixes 3a236f6a5cf2 ("dma: contiguous: Turn heap registration logic around")Reported-by Mark Brown <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- drivers/dma-buf/heaps/cma_heap.c | 1 - include/linux/dma-buf/heaps/cma.h | 16 ---------------- kernel/dma/contiguous.c | 5 ----- 3 files changed, 22 deletions(-)drivers/dma-buf/heaps/cma_heap.c +0
-1@@ -12,11 +12,10 @@#define pr_fmt (fmt) "cma_heap: " fmt#include <linux/cma.h> #include <linux/dma-buf.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-heap.h> #include <linux/dma-map-ops.h> #include <linux/err.h> #include <linux/highmem.h> #include <linux/io.h> include/linux/dma-buf/heaps/cma.h deleted +0
-16@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef DMA_BUF_HEAP_CMA_H_ -#define DMA_BUF_HEAP_CMA_H_ - -struct cma ; - -#ifdef CONFIG_DMABUF_HEAPS_CMA -int dma_heap_cma_register_heap (struct cma *cma); -#else -static inline int dma_heap_cma_register_heap (struct cma *cma) -{ -return 0 ; -} -#endif // CONFIG_DMABUF_HEAPS_CMA - -#endif // DMA_BUF_HEAP_CMA_H_ kernel/dma/contiguous.c +0
-1@@ -40,11 +40,10 @@#include <asm/page.h> #include <linux/memblock.h> #include <linux/err.h> #include <linux/sizes.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-map-ops.h> #include <linux/cma.h> #include <linux/nospec.h> #ifdef CONFIG_CMA_SIZE_MBYTES
kernel/dma/contiguous.c void __init dma_contiguous_reserve(phys_addr_t limit) · line 278
Quoted 9 lines
kernel/dma/contiguous.c +0
-4@@ -270,14 +269,10 @@ void __init dma_contiguous_reserve(phys_addr_t limit) selected_limit, &dma_contiguous_default_area, fixed);if (ret)return ; - - ret =dma_heap_cma_register_heap (dma_contiguous_default_area); -if (ret) -pr_warn ("Couldn't register default CMA heap." );
After this change no dma-buf heap for the default CMA area is created if it has not been specified in device-tree. This might be especially a problem for the non-dt systems.
kernel/dma/contiguous.c void __init dma_contiguous_reserve(phys_addr_t limit) · line 278
Quoted 7 lines
kernel/dma/contiguous.c +0
-0} }void __weak dma_contiguous_early_fixup (phys_addr_t base,unsigned long size)
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Quoted 79 lines · Marek Szyprowski
Quoted 78 lines · Maxime Ripard
Commit
3a236f6a5cf2("dma: contiguous: Turn heap registration logic around") didn't remove one last call todma_heap_cma_register_heap()that it removed, thus breaking the build.That last call is in
dma_contiguous_reserve(), to handle the registration of the default CMA region heap instance if it's declared in the device tree.However, the default CMA region instance is already handled by retrieving it through
dev_get_cma_area()in the CMA heap driver, so the call todma_heap_cma_register_heap()wasn't actually needed.Let's remove this call, the now unused function definition, its now empty header, and all includes of this header.
Fixes 3a236f6a5cf2 ("dma: contiguous: Turn heap registration logic around")Reported-by Mark Brown <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- drivers/dma-buf/heaps/cma_heap.c | 1 - include/linux/dma-buf/heaps/cma.h | 16 ---------------- kernel/dma/contiguous.c | 5 ----- 3 files changed, 22 deletions(-)drivers/dma-buf/heaps/cma_heap.c +0
-1@@ -12,11 +12,10 @@#define pr_fmt (fmt) "cma_heap: " fmt#include <linux/cma.h> #include <linux/dma-buf.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-heap.h> #include <linux/dma-map-ops.h> #include <linux/err.h> #include <linux/highmem.h> #include <linux/io.h> include/linux/dma-buf/heaps/cma.h deleted +0
-16@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef DMA_BUF_HEAP_CMA_H_ -#define DMA_BUF_HEAP_CMA_H_ - -struct cma ; - -#ifdef CONFIG_DMABUF_HEAPS_CMA -int dma_heap_cma_register_heap (struct cma *cma); -#else -static inline int dma_heap_cma_register_heap (struct cma *cma) -{ -return 0 ; -} -#endif // CONFIG_DMABUF_HEAPS_CMA - -#endif // DMA_BUF_HEAP_CMA_H_ kernel/dma/contiguous.c +0
-1@@ -40,11 +40,10 @@#include <asm/page.h> #include <linux/memblock.h> #include <linux/err.h> #include <linux/sizes.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-map-ops.h> #include <linux/cma.h> #include <linux/nospec.h>
Quoted 15 lines
kernel/dma/contiguous.c void __init dma_contiguous_reserve(phys_addr_t limit) · line 278
Quoted 11 lines
kernel/dma/contiguous.c +0
-4#ifdef CONFIG_CMA_SIZE_MBYTES @@ -270,14 +269,10 @@ void __init dma_contiguous_reserve(phys_addr_t limit) selected_limit, &dma_contiguous_default_area, fixed);if (ret)return ; - - ret =dma_heap_cma_register_heap (dma_contiguous_default_area); -if (ret) -pr_warn ("Couldn't register default CMA heap." );After this change no dma-buf heap for the default CMA area is created if it has not been specified in device-tree. This might be especially a problem for the non-dt systems.
I don't think that's the case? My understanding is that dma_contiguous_reserve() is called by the arch code, and will create that region only if it hasn't be set by the DT (that excerpt above is run only if !dma_contiguous_default_area).
However, for the DT case, dma_contiguous_default_area will be set by rmem_cma_setup() a bit below if linux,cma-default is set in the DT.
dma_contiguous_reserved() is called (on arm64 at least) through bootmem_init(), called as part of setup_arch().
rmem_cma_setup() is called through RESERVEDMEM_OF_DECLARE, so through __reserved_mem_init_node(), so, if we consider only the public functions, through:
* fdt_scan_reserved_mem_reg_nodes(), called by unflatten_device_tree(), called right before bootmem_init() in setup_arch();
* or fdt_scan_reserved_mem() and then early_init_fdt_scan_reserved_mem(), called in arm64_memblock_init(), itself called in setup_arch() earlier than both unflatten_device_tree(), and bootmem_init().
Thus, the DT case will run first and set dma_contiguous_default_area if relevant on that platform, and if it's not set, the non-DT case will set it up. Either way, dma_contiguous_default_area will be set.
The CMA heap runs much later using a regular module_init. It will retrieve dma_contiguous_default_area through dev_get_cma_area(), and will create a heap instance for the default area.
Am I misunderstanding something?
Maxime
Marek Szyprowski
maintainerQuoted 122 lines · Maxime Ripard
Quoted 79 lines · Marek Szyprowski
Quoted 78 lines · Maxime Ripard
Commit
3a236f6a5cf2("dma: contiguous: Turn heap registration logic around") didn't remove one last call todma_heap_cma_register_heap()that it removed, thus breaking the build.That last call is in
dma_contiguous_reserve(), to handle the registration of the default CMA region heap instance if it's declared in the device tree.However, the default CMA region instance is already handled by retrieving it through
dev_get_cma_area()in the CMA heap driver, so the call todma_heap_cma_register_heap()wasn't actually needed.Let's remove this call, the now unused function definition, its now empty header, and all includes of this header.
Fixes 3a236f6a5cf2 ("dma: contiguous: Turn heap registration logic around")Reported-by Mark Brown <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- drivers/dma-buf/heaps/cma_heap.c | 1 - include/linux/dma-buf/heaps/cma.h | 16 ---------------- kernel/dma/contiguous.c | 5 ----- 3 files changed, 22 deletions(-)drivers/dma-buf/heaps/cma_heap.c +0
-1@@ -12,11 +12,10 @@#define pr_fmt (fmt) "cma_heap: " fmt#include <linux/cma.h> #include <linux/dma-buf.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-heap.h> #include <linux/dma-map-ops.h> #include <linux/err.h> #include <linux/highmem.h> #include <linux/io.h> include/linux/dma-buf/heaps/cma.h deleted +0
-16@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef DMA_BUF_HEAP_CMA_H_ -#define DMA_BUF_HEAP_CMA_H_ - -struct cma ; - -#ifdef CONFIG_DMABUF_HEAPS_CMA -int dma_heap_cma_register_heap (struct cma *cma); -#else -static inline int dma_heap_cma_register_heap (struct cma *cma) -{ -return 0 ; -} -#endif // CONFIG_DMABUF_HEAPS_CMA - -#endif // DMA_BUF_HEAP_CMA_H_ kernel/dma/contiguous.c +0
-1@@ -40,11 +40,10 @@#include <asm/page.h> #include <linux/memblock.h> #include <linux/err.h> #include <linux/sizes.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-map-ops.h> #include <linux/cma.h> #include <linux/nospec.h> Quoted 14 lines
kernel/dma/contiguous.c void __init dma_contiguous_reserve(phys_addr_t limit) · line 278
Quoted 11 lines
kernel/dma/contiguous.c +0
-4#ifdef CONFIG_CMA_SIZE_MBYTES @@ -270,14 +269,10 @@ void __init dma_contiguous_reserve(phys_addr_t limit) selected_limit, &dma_contiguous_default_area, fixed);if (ret)return ; - - ret =dma_heap_cma_register_heap (dma_contiguous_default_area); -if (ret) -pr_warn ("Couldn't register default CMA heap." );After this change no dma-buf heap for the default CMA area is created if it has not been specified in device-tree. This might be especially a problem for the non-dt systems.
I don't think that's the case? My understanding is that
dma_contiguous_reserve()is called by the arch code, and will create that region only if it hasn't be set by the DT (that excerpt above is run only if !dma_contiguous_default_area).However, for the DT case,
dma_contiguous_default_areawill be set byrmem_cma_setup()a bit below if linux,cma-default is set in the DT.
dma_contiguous_reserved()is called (on arm64 at least) throughbootmem_init(), called as part ofsetup_arch().
rmem_cma_setup()is called throughRESERVEDMEM_OF_DECLARE, so through__reserved_mem_init_node(), so, if we consider only the public functions, through:*
fdt_scan_reserved_mem_reg_nodes(), called byunflatten_device_tree(), called right beforebootmem_init()insetup_arch();* or
fdt_scan_reserved_mem()and thenearly_init_fdt_scan_reserved_mem(), called inarm64_memblock_init(), itself called insetup_arch()earlier than bothunflatten_device_tree(), andbootmem_init().Thus, the DT case will run first and set
dma_contiguous_default_areaif relevant on that platform, and if it's not set, the non-DT case will set it up. Either way,dma_contiguous_default_areawill be set.
Quoted 5 lines
The CMA heap runs much later using a regular
module_init. It will retrievedma_contiguous_default_areathroughdev_get_cma_area(), and will create a heap instance for the default area.Am I misunderstanding something?
The default CMA area is also optional for DT platforms.
If DT doesn't provide such, it will be created based on the kernel cmdline cma= parameter or the default configuration defined in the kernel .config (this is also true for the non-dt platforms). I know that for most Android GKI systems the default CMA area will be defined in DT, but I see no reason to disable dma-buf heap support for the default CMA area if it has been instantiated from kernel cmdline or .config.
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Quoted 131 lines · Marek Szyprowski
Quoted 122 lines · Maxime Ripard
Quoted 79 lines · Marek Szyprowski
Quoted 78 lines · Maxime Ripard
Commit
3a236f6a5cf2("dma: contiguous: Turn heap registration logic around") didn't remove one last call todma_heap_cma_register_heap()that it removed, thus breaking the build.That last call is in
dma_contiguous_reserve(), to handle the registration of the default CMA region heap instance if it's declared in the device tree.However, the default CMA region instance is already handled by retrieving it through
dev_get_cma_area()in the CMA heap driver, so the call todma_heap_cma_register_heap()wasn't actually needed.Let's remove this call, the now unused function definition, its now empty header, and all includes of this header.
Fixes 3a236f6a5cf2 ("dma: contiguous: Turn heap registration logic around")Reported-by Mark Brown <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- drivers/dma-buf/heaps/cma_heap.c | 1 - include/linux/dma-buf/heaps/cma.h | 16 ---------------- kernel/dma/contiguous.c | 5 ----- 3 files changed, 22 deletions(-)drivers/dma-buf/heaps/cma_heap.c +0
-1@@ -12,11 +12,10 @@#define pr_fmt (fmt) "cma_heap: " fmt#include <linux/cma.h> #include <linux/dma-buf.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-heap.h> #include <linux/dma-map-ops.h> #include <linux/err.h> #include <linux/highmem.h> #include <linux/io.h> include/linux/dma-buf/heaps/cma.h deleted +0
-16@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef DMA_BUF_HEAP_CMA_H_ -#define DMA_BUF_HEAP_CMA_H_ - -struct cma ; - -#ifdef CONFIG_DMABUF_HEAPS_CMA -int dma_heap_cma_register_heap (struct cma *cma); -#else -static inline int dma_heap_cma_register_heap (struct cma *cma) -{ -return 0 ; -} -#endif // CONFIG_DMABUF_HEAPS_CMA - -#endif // DMA_BUF_HEAP_CMA_H_ kernel/dma/contiguous.c +0
-1@@ -40,11 +40,10 @@#include <asm/page.h> #include <linux/memblock.h> #include <linux/err.h> #include <linux/sizes.h> -#include <linux/dma-buf/heaps/cma.h> #include <linux/dma-map-ops.h> #include <linux/cma.h> #include <linux/nospec.h> Quoted 14 lines
kernel/dma/contiguous.c void __init dma_contiguous_reserve(phys_addr_t limit) · line 278
Quoted 11 lines
kernel/dma/contiguous.c +0
-4#ifdef CONFIG_CMA_SIZE_MBYTES @@ -270,14 +269,10 @@ void __init dma_contiguous_reserve(phys_addr_t limit) selected_limit, &dma_contiguous_default_area, fixed);if (ret)return ; - - ret =dma_heap_cma_register_heap (dma_contiguous_default_area); -if (ret) -pr_warn ("Couldn't register default CMA heap." );After this change no dma-buf heap for the default CMA area is created if it has not been specified in device-tree. This might be especially a problem for the non-dt systems.
I don't think that's the case? My understanding is that
dma_contiguous_reserve()is called by the arch code, and will create that region only if it hasn't be set by the DT (that excerpt above is run only if !dma_contiguous_default_area).However, for the DT case,
dma_contiguous_default_areawill be set byrmem_cma_setup()a bit below if linux,cma-default is set in the DT.
dma_contiguous_reserved()is called (on arm64 at least) throughbootmem_init(), called as part ofsetup_arch().
rmem_cma_setup()is called throughRESERVEDMEM_OF_DECLARE, so through__reserved_mem_init_node(), so, if we consider only the public functions, through:*
fdt_scan_reserved_mem_reg_nodes(), called byunflatten_device_tree(), called right beforebootmem_init()insetup_arch();* or
fdt_scan_reserved_mem()and thenearly_init_fdt_scan_reserved_mem(), called inarm64_memblock_init(), itself called insetup_arch()earlier than bothunflatten_device_tree(), andbootmem_init().Thus, the DT case will run first and set
dma_contiguous_default_areaif relevant on that platform, and if it's not set, the non-DT case will set it up. Either way,dma_contiguous_default_areawill be set.Quoted 5 lines
The CMA heap runs much later using a regular
module_init. It will retrievedma_contiguous_default_areathroughdev_get_cma_area(), and will create a heap instance for the default area.Am I misunderstanding something?
The default CMA area is also optional for DT platforms.
Quoted 7 lines
If DT doesn't provide such, it will be created based on the kernel cmdline cma= parameter or the default configuration defined in the kernel .config (this is also true for the non-dt platforms). I know that for most Android GKI systems the default CMA area will be defined in DT, but I see no reason to disable dma-buf heap support for the default CMA area if it has been instantiated from kernel cmdline or .config.
I think I see what you mean now, thanks! Sending a v2.
Maxime