drivers/of/of_reserved_mem.c | 14 +++++++++++--- kernel/dma/contiguous.c | 2 -- 2 files changed, 11 insertions(+), 5 deletions(-)
Restructure the call site for dma_contiguous_early_fixup() to
where the reserved_mem nodes are being parsed from the DT so that
dma_mmu_remap[] is populated before dma_contiguous_remap() is called.
Fixes: 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory regions are processed")
Signed-off-by: Oreoluwa Babatunde <oreoluwa.babatunde@oss.qualcomm.com>
---
drivers/of/of_reserved_mem.c | 14 +++++++++++---
kernel/dma/contiguous.c | 2 --
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 77016c0cc296..132d2c66cafc 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -25,6 +25,7 @@
#include <linux/memblock.h>
#include <linux/kmemleak.h>
#include <linux/cma.h>
+#include <linux/dma-map-ops.h>
#include "of_private.h"
@@ -175,13 +176,17 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
base = dt_mem_next_cell(dt_root_addr_cells, &prop);
size = dt_mem_next_cell(dt_root_size_cells, &prop);
- if (size &&
- early_init_dt_reserve_memory(base, size, nomap) == 0)
+ if (size && early_init_dt_reserve_memory(base, size, nomap) == 0) {
+ /* Architecture specific contiguous memory fixup. */
+ if (of_flat_dt_is_compatible(node, "shared-dma-pool"))
+ dma_contiguous_early_fixup(base, size);
+
pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n",
uname, &base, (unsigned long)(size / SZ_1M));
- else
+ } else {
pr_err("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n",
uname, &base, (unsigned long)(size / SZ_1M));
+ }
len -= t_len;
}
@@ -472,6 +477,9 @@ static int __init __reserved_mem_alloc_size(unsigned long node, const char *unam
uname, (unsigned long)(size / SZ_1M));
return -ENOMEM;
}
+ /* Architecture specific contiguous memory fixup. */
+ if (of_flat_dt_is_compatible(node, "shared-dma-pool"))
+ dma_contiguous_early_fixup(base, size);
/* Save region in the reserved_mem array */
fdt_reserved_mem_save_node(node, uname, base, size);
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 8df0dfaaca18..9e5d63efe7c5 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -480,8 +480,6 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
pr_err("Reserved memory: unable to setup CMA region\n");
return err;
}
- /* Architecture specific contiguous memory fixup. */
- dma_contiguous_early_fixup(rmem->base, rmem->size);
if (default_cma)
dma_contiguous_default_area = cma;
--
2.34.1
Hi Oreoluwa, kernel test robot noticed the following build errors: [auto build test ERROR on robh/for-next] [also build test ERROR on linus/master v6.16-rc5 next-20250708] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Oreoluwa-Babatunde/of-reserved_mem-Restructure-call-site-for-dma_contiguous_early_fixup/20250709-005858 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20250708165627.845295-1-oreoluwa.babatunde%40oss.qualcomm.com patch subject: [PATCH] of: reserved_mem: Restructure call site for dma_contiguous_early_fixup() config: i386-buildonly-randconfig-003-20250709 (https://download.01.org/0day-ci/archive/20250709/202507091614.ZsQ9sH7n-lkp@intel.com/config) compiler: clang version 20.1.7 (https://github.com/llvm/llvm-project 6146a88f60492b520a36f8f8f3231e15f3cc6082) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250709/202507091614.ZsQ9sH7n-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202507091614.ZsQ9sH7n-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/of/of_reserved_mem.c:182:5: error: call to undeclared function 'dma_contiguous_early_fixup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 182 | dma_contiguous_early_fixup(base, size); | ^ drivers/of/of_reserved_mem.c:482:3: error: call to undeclared function 'dma_contiguous_early_fixup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 482 | dma_contiguous_early_fixup(base, size); | ^ 2 errors generated. vim +/dma_contiguous_early_fixup +182 drivers/of/of_reserved_mem.c 150 151 /* 152 * __reserved_mem_reserve_reg() - reserve all memory described in 'reg' property 153 */ 154 static int __init __reserved_mem_reserve_reg(unsigned long node, 155 const char *uname) 156 { 157 int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); 158 phys_addr_t base, size; 159 int len; 160 const __be32 *prop; 161 bool nomap; 162 163 prop = of_get_flat_dt_prop(node, "reg", &len); 164 if (!prop) 165 return -ENOENT; 166 167 if (len && len % t_len != 0) { 168 pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n", 169 uname); 170 return -EINVAL; 171 } 172 173 nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; 174 175 while (len >= t_len) { 176 base = dt_mem_next_cell(dt_root_addr_cells, &prop); 177 size = dt_mem_next_cell(dt_root_size_cells, &prop); 178 179 if (size && early_init_dt_reserve_memory(base, size, nomap) == 0) { 180 /* Architecture specific contiguous memory fixup. */ 181 if (of_flat_dt_is_compatible(node, "shared-dma-pool")) > 182 dma_contiguous_early_fixup(base, size); 183 184 pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n", 185 uname, &base, (unsigned long)(size / SZ_1M)); 186 } else { 187 pr_err("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n", 188 uname, &base, (unsigned long)(size / SZ_1M)); 189 } 190 191 len -= t_len; 192 } 193 return 0; 194 } 195 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On 08/07/2025 5:56 pm, Oreoluwa Babatunde wrote: > Restructure the call site for dma_contiguous_early_fixup() to > where the reserved_mem nodes are being parsed from the DT so that > dma_mmu_remap[] is populated before dma_contiguous_remap() is called. > > Fixes: 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory regions are processed") > Signed-off-by: Oreoluwa Babatunde <oreoluwa.babatunde@oss.qualcomm.com> > --- > drivers/of/of_reserved_mem.c | 14 +++++++++++--- > kernel/dma/contiguous.c | 2 -- > 2 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c > index 77016c0cc296..132d2c66cafc 100644 > --- a/drivers/of/of_reserved_mem.c > +++ b/drivers/of/of_reserved_mem.c > @@ -25,6 +25,7 @@ > #include <linux/memblock.h> > #include <linux/kmemleak.h> > #include <linux/cma.h> > +#include <linux/dma-map-ops.h> > > #include "of_private.h" > > @@ -175,13 +176,17 @@ static int __init __reserved_mem_reserve_reg(unsigned long node, > base = dt_mem_next_cell(dt_root_addr_cells, &prop); > size = dt_mem_next_cell(dt_root_size_cells, &prop); > > - if (size && > - early_init_dt_reserve_memory(base, size, nomap) == 0) > + if (size && early_init_dt_reserve_memory(base, size, nomap) == 0) { > + /* Architecture specific contiguous memory fixup. */ > + if (of_flat_dt_is_compatible(node, "shared-dma-pool")) Surely this is now going to call the fixup for *all* "shared-dma-pool" reservations, rather than just the ones which are specifically CMA regions? That seems potentially bad in a number of ways. Thanks, Robin. > + dma_contiguous_early_fixup(base, size); > + > pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n", > uname, &base, (unsigned long)(size / SZ_1M)); > - else > + } else { > pr_err("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n", > uname, &base, (unsigned long)(size / SZ_1M)); > + } > > len -= t_len; > } > @@ -472,6 +477,9 @@ static int __init __reserved_mem_alloc_size(unsigned long node, const char *unam > uname, (unsigned long)(size / SZ_1M)); > return -ENOMEM; > } > + /* Architecture specific contiguous memory fixup. */ > + if (of_flat_dt_is_compatible(node, "shared-dma-pool")) > + dma_contiguous_early_fixup(base, size); > > /* Save region in the reserved_mem array */ > fdt_reserved_mem_save_node(node, uname, base, size); > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c > index 8df0dfaaca18..9e5d63efe7c5 100644 > --- a/kernel/dma/contiguous.c > +++ b/kernel/dma/contiguous.c > @@ -480,8 +480,6 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) > pr_err("Reserved memory: unable to setup CMA region\n"); > return err; > } > - /* Architecture specific contiguous memory fixup. */ > - dma_contiguous_early_fixup(rmem->base, rmem->size); > > if (default_cma) > dma_contiguous_default_area = cma;
On 7/8/2025 10:17 AM, Robin Murphy wrote: > On 08/07/2025 5:56 pm, Oreoluwa Babatunde wrote: >> Restructure the call site for dma_contiguous_early_fixup() to >> where the reserved_mem nodes are being parsed from the DT so that >> dma_mmu_remap[] is populated before dma_contiguous_remap() is called. >> >> Fixes: 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory regions are processed") >> Signed-off-by: Oreoluwa Babatunde <oreoluwa.babatunde@oss.qualcomm.com> >> --- >> drivers/of/of_reserved_mem.c | 14 +++++++++++--- >> kernel/dma/contiguous.c | 2 -- >> 2 files changed, 11 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c >> index 77016c0cc296..132d2c66cafc 100644 >> --- a/drivers/of/of_reserved_mem.c >> +++ b/drivers/of/of_reserved_mem.c >> @@ -25,6 +25,7 @@ >> #include <linux/memblock.h> >> #include <linux/kmemleak.h> >> #include <linux/cma.h> >> +#include <linux/dma-map-ops.h> >> #include "of_private.h" >> @@ -175,13 +176,17 @@ static int __init __reserved_mem_reserve_reg(unsigned long node, >> base = dt_mem_next_cell(dt_root_addr_cells, &prop); >> size = dt_mem_next_cell(dt_root_size_cells, &prop); >> - if (size && >> - early_init_dt_reserve_memory(base, size, nomap) == 0) >> + if (size && early_init_dt_reserve_memory(base, size, nomap) == 0) { >> + /* Architecture specific contiguous memory fixup. */ >> + if (of_flat_dt_is_compatible(node, "shared-dma-pool")) > > Surely this is now going to call the fixup for *all* "shared-dma-pool" reservations, rather than just the ones which are specifically CMA regions? That seems potentially bad in a number of ways. > > Thanks, > Robin. Hi Robin, Thanks for pointing that out. I believe if we add a check for of_get_flat_dt_prop(node, "reusable", NULL) that should help limit this to only the regions that are meant to be cma. Please let me know if there's something else that I'm missing. Thanks, Oreoluwa > >> + dma_contiguous_early_fixup(base, size); >> + >> pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n", >> uname, &base, (unsigned long)(size / SZ_1M)); >> - else >> + } else { >> pr_err("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n", >> uname, &base, (unsigned long)(size / SZ_1M)); >> + } >> len -= t_len; >> } >> @@ -472,6 +477,9 @@ static int __init __reserved_mem_alloc_size(unsigned long node, const char *unam >> uname, (unsigned long)(size / SZ_1M)); >> return -ENOMEM; >> } >> + /* Architecture specific contiguous memory fixup. */ >> + if (of_flat_dt_is_compatible(node, "shared-dma-pool")) >> + dma_contiguous_early_fixup(base, size); >> /* Save region in the reserved_mem array */ >> fdt_reserved_mem_save_node(node, uname, base, size); >> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c >> index 8df0dfaaca18..9e5d63efe7c5 100644 >> --- a/kernel/dma/contiguous.c >> +++ b/kernel/dma/contiguous.c >> @@ -480,8 +480,6 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) >> pr_err("Reserved memory: unable to setup CMA region\n"); >> return err; >> } >> - /* Architecture specific contiguous memory fixup. */ >> - dma_contiguous_early_fixup(rmem->base, rmem->size); >> if (default_cma) >> dma_contiguous_default_area = cma;
© 2016 - 2025 Red Hat, Inc.