* [PATCH] dma-contiguous: CMA: give precedence to cmdline
@ 2020-01-10 17:19 Nicolas Saenz Julienne
2020-01-10 17:36 ` Phil Elwell
2020-01-30 13:42 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2020-01-10 17:19 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy
Cc: phil, Nicolas Saenz Julienne, iommu, linux-kernel
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 <nsaenzjulienne@suse.de>
---
NOTE: Tested this on arm and arm64 with the Raspberry Pi 4.
kernel/dma/contiguous.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index daa4e6eefdde..8bc6f2d670f9 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -302,9 +302,16 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
phys_addr_t align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
phys_addr_t mask = align - 1;
unsigned long node = rmem->fdt_node;
+ bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL);
struct cma *cma;
int err;
+ if (size_cmdline != -1 && default_cma) {
+ pr_info("Reserved memory: bypass %s node, using cmdline CMA params instead\n",
+ rmem->name);
+ return -EBUSY;
+ }
+
if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
of_get_flat_dt_prop(node, "no-map", NULL))
return -EINVAL;
@@ -322,7 +329,7 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
/* Architecture specific contiguous memory fixup. */
dma_contiguous_early_fixup(rmem->base, rmem->size);
- if (of_get_flat_dt_prop(node, "linux,cma-default", NULL))
+ if (default_cma)
dma_contiguous_set_default(cma);
rmem->ops = &rmem_cma_ops;
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] dma-contiguous: CMA: give precedence to cmdline
2020-01-10 17:19 [PATCH] dma-contiguous: CMA: give precedence to cmdline Nicolas Saenz Julienne
@ 2020-01-10 17:36 ` Phil Elwell
2020-01-30 13:42 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Phil Elwell @ 2020-01-10 17:36 UTC (permalink / raw)
To: Nicolas Saenz Julienne, Christoph Hellwig, Marek Szyprowski,
Robin Murphy
Cc: iommu, linux-kernel
Hi Nicolas,
On 10/01/2020 17:19, Nicolas Saenz Julienne wrote:
> 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 <nsaenzjulienne@suse.de>
> ---
>
> NOTE: Tested this on arm and arm64 with the Raspberry Pi 4.
>
> kernel/dma/contiguous.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index daa4e6eefdde..8bc6f2d670f9 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -302,9 +302,16 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
> phys_addr_t align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
> phys_addr_t mask = align - 1;
> unsigned long node = rmem->fdt_node;
> + bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL);
> struct cma *cma;
> int err;
>
> + if (size_cmdline != -1 && default_cma) {
> + pr_info("Reserved memory: bypass %s node, using cmdline CMA params instead\n",
> + rmem->name);
> + return -EBUSY;
> + }
> +
> if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
> of_get_flat_dt_prop(node, "no-map", NULL))
> return -EINVAL;
> @@ -322,7 +329,7 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
> /* Architecture specific contiguous memory fixup. */
> dma_contiguous_early_fixup(rmem->base, rmem->size);
>
> - if (of_get_flat_dt_prop(node, "linux,cma-default", NULL))
> + if (default_cma)
> dma_contiguous_set_default(cma);
>
> rmem->ops = &rmem_cma_ops;
>
For what it's worth,
Reviewed-by: Phil Elwell <phil@raspberrypi.org>
Phil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dma-contiguous: CMA: give precedence to cmdline
2020-01-10 17:19 [PATCH] dma-contiguous: CMA: give precedence to cmdline Nicolas Saenz Julienne
2020-01-10 17:36 ` Phil Elwell
@ 2020-01-30 13:42 ` Christoph Hellwig
2020-01-30 16:11 ` Nicolas Saenz Julienne
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2020-01-30 13:42 UTC (permalink / raw)
To: Nicolas Saenz Julienne
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, phil, iommu,
linux-kernel
I've picked this up for Linux 5.6, sorry for the delay.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dma-contiguous: CMA: give precedence to cmdline
2020-01-30 13:42 ` Christoph Hellwig
@ 2020-01-30 16:11 ` Nicolas Saenz Julienne
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2020-01-30 16:11 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, phil, iommu,
linux-kernel
On Thu Jan 30, 2020 at 2:42 PM, Christoph Hellwig wrote:
> I've picked this up for Linux 5.6, sorry for the delay.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-30 16:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 17:19 [PATCH] dma-contiguous: CMA: give precedence to cmdline Nicolas Saenz Julienne
2020-01-10 17:36 ` Phil Elwell
2020-01-30 13:42 ` Christoph Hellwig
2020-01-30 16:11 ` Nicolas Saenz Julienne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).