Skip to content

Commit 8c8c5a4

Browse files
Nicolas Saenz JulienneChristoph Hellwig
authored andcommitted
dma-contiguous: CMA: give precedence to cmdline
Although the device tree might contain a reserved-memory DT node dedicated as the default CMA pool, users might want to change CMA's parameters using the kernel command line for debugging purposes and whatnot. Honor this by bypassing the reserved memory CMA setup, which will ultimately end up freeing the memblock and allow the command line CMA configuration routine to run. Signed-off-by: Nicolas Saenz Julienne <[email protected]> Reviewed-by: Phil Elwell <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent d5226fa commit 8c8c5a4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kernel/dma/contiguous.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,16 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
302302
phys_addr_t align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
303303
phys_addr_t mask = align - 1;
304304
unsigned long node = rmem->fdt_node;
305+
bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL);
305306
struct cma *cma;
306307
int err;
307308

309+
if (size_cmdline != -1 && default_cma) {
310+
pr_info("Reserved memory: bypass %s node, using cmdline CMA params instead\n",
311+
rmem->name);
312+
return -EBUSY;
313+
}
314+
308315
if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
309316
of_get_flat_dt_prop(node, "no-map", NULL))
310317
return -EINVAL;
@@ -322,7 +329,7 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
322329
/* Architecture specific contiguous memory fixup. */
323330
dma_contiguous_early_fixup(rmem->base, rmem->size);
324331

325-
if (of_get_flat_dt_prop(node, "linux,cma-default", NULL))
332+
if (default_cma)
326333
dma_contiguous_set_default(cma);
327334

328335
rmem->ops = &rmem_cma_ops;

0 commit comments

Comments
 (0)