bcm27xx-userland: update to latest version
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0636-dma-contiguous-CMA-give-precedence-to-cmdline.patch
1 From cf40e83d2b6fb6857b13df4c8d69cc4c45395ea2 Mon Sep 17 00:00:00 2001
2 From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
3 Date: Fri, 10 Jan 2020 18:19:33 +0100
4 Subject: [PATCH] dma-contiguous: CMA: give precedence to cmdline
5
6 commit 8c8c5a4994a306c217fd061cbfc5903399fd4c1c upstream.
7
8 Although the device tree might contain a reserved-memory DT node
9 dedicated as the default CMA pool, users might want to change CMA's
10 parameters using the kernel command line for debugging purposes and
11 whatnot. Honor this by bypassing the reserved memory CMA setup, which
12 will ultimately end up freeing the memblock and allow the command line
13 CMA configuration routine to run.
14
15 Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
16 Reviewed-by: Phil Elwell <phil@raspberrypi.org>
17 Signed-off-by: Christoph Hellwig <hch@lst.de>
18 ---
19 kernel/dma/contiguous.c | 9 ++++++++-
20 1 file changed, 8 insertions(+), 1 deletion(-)
21
22 --- a/kernel/dma/contiguous.c
23 +++ b/kernel/dma/contiguous.c
24 @@ -301,9 +301,16 @@ static int __init rmem_cma_setup(struct
25 phys_addr_t align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
26 phys_addr_t mask = align - 1;
27 unsigned long node = rmem->fdt_node;
28 + bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL);
29 struct cma *cma;
30 int err;
31
32 + if (size_cmdline != -1 && default_cma) {
33 + pr_info("Reserved memory: bypass %s node, using cmdline CMA params instead\n",
34 + rmem->name);
35 + return -EBUSY;
36 + }
37 +
38 if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
39 of_get_flat_dt_prop(node, "no-map", NULL))
40 return -EINVAL;
41 @@ -321,7 +328,7 @@ static int __init rmem_cma_setup(struct
42 /* Architecture specific contiguous memory fixup. */
43 dma_contiguous_early_fixup(rmem->base, rmem->size);
44
45 - if (of_get_flat_dt_prop(node, "linux,cma-default", NULL))
46 + if (default_cma)
47 dma_contiguous_set_default(cma);
48
49 rmem->ops = &rmem_cma_ops;