summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorOreoluwa Babatunde <oreoluwa.babatunde@oss.qualcomm.com>2026-01-26 18:13:27 +0100
committerMarek Szyprowski <m.szyprowski@samsung.com>2026-01-29 00:26:36 +0100
commit0fd17e5983337231dc655e9ca0095d2ca3f47405 (patch)
tree85b790559691c628981b458fc392d7ab1143e3c0 /drivers
parentc6ccd098807483762ccd726e1498bac5a71d0005 (diff)
of: reserved_mem: Allow reserved_mem framework detect "cma=" kernel param
When initializing the default cma region, the "cma=" kernel parameter takes priority over a DT defined linux,cma-default region. Hence, give the reserved_mem framework the ability to detect this so that the DT defined cma region can skip initialization accordingly. Signed-off-by: Oreoluwa Babatunde <oreoluwa.babatunde@oss.qualcomm.com> Tested-by: Joy Zou <joy.zou@nxp.com> Acked-by: Rob Herring (Arm) <robh@kernel.org> Fixes: 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory regions are processed") Fixes: 2c223f7239f3 ("of: reserved_mem: Restructure call site for dma_contiguous_early_fixup()") Link: https://lore.kernel.org/r/20251210002027.1171519-1-oreoluwa.babatunde@oss.qualcomm.com [mszyprow: rebased onto v6.19-rc1, added fixes tags, added a stub for cma_skip_dt_default_reserved_mem() if no CONFIG_DMA_CMA is set] Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/of_reserved_mem.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 5619ec917858..a2a13617c6f4 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -157,13 +157,19 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
phys_addr_t base, size;
int i, len;
const __be32 *prop;
- bool nomap;
+ bool nomap, default_cma;
prop = of_flat_dt_get_addr_size_prop(node, "reg", &len);
if (!prop)
return -ENOENT;
nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL;
+ default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL);
+
+ if (default_cma && cma_skip_dt_default_reserved_mem()) {
+ pr_err("Skipping dt linux,cma-default for \"cma=\" kernel param.\n");
+ return -EINVAL;
+ }
for (i = 0; i < len; i++) {
u64 b, s;
@@ -248,10 +254,13 @@ void __init fdt_scan_reserved_mem_reg_nodes(void)
fdt_for_each_subnode(child, fdt, node) {
const char *uname;
+ bool default_cma = of_get_flat_dt_prop(child, "linux,cma-default", NULL);
u64 b, s;
if (!of_fdt_device_is_available(fdt, child))
continue;
+ if (default_cma && cma_skip_dt_default_reserved_mem())
+ continue;
if (!of_flat_dt_get_addr_size(child, "reg", &b, &s))
continue;
@@ -389,7 +398,7 @@ static int __init __reserved_mem_alloc_size(unsigned long node, const char *unam
phys_addr_t base = 0, align = 0, size;
int i, len;
const __be32 *prop;
- bool nomap;
+ bool nomap, default_cma;
int ret;
prop = of_get_flat_dt_prop(node, "size", &len);
@@ -413,6 +422,12 @@ static int __init __reserved_mem_alloc_size(unsigned long node, const char *unam
}
nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL;
+ default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL);
+
+ if (default_cma && cma_skip_dt_default_reserved_mem()) {
+ pr_err("Skipping dt linux,cma-default for \"cma=\" kernel param.\n");
+ return -EINVAL;
+ }
/* Need adjust the alignment to satisfy the CMA requirement */
if (IS_ENABLED(CONFIG_CMA)