* [PATCH v2] mm/cma: report base address of single range correctly
@ 2025-04-08 16:40 Frank van der Linden
2025-04-08 21:03 ` Andrew Morton
2025-04-17 7:35 ` Geert Uytterhoeven
0 siblings, 2 replies; 4+ messages in thread
From: Frank van der Linden @ 2025-04-08 16:40 UTC (permalink / raw)
To: akpm, muchun.song, linux-mm, linux-kernel
Cc: Frank van der Linden, Geert Uytterhoeven
The cma_declare_contiguous_nid code was refactored by
commit c009da4258f9 ("mm, cma: support multiple contiguous
ranges, if requested"), so that it could use an internal
function to attempt a single range area first, and then
try a multi-range one.
However, that meant that the actual base address used for
the !fixed case (base == 0) wasn't available one level up
to be printed in the informational message, and it would
always end up printing a base address of 0 in the boot
message.
Make the internal function take a phys_addr_t pointer to
the base address, so that the value is available to the
caller.
Fixes: c009da4258f9 ("mm, cma: support multiple contiguous ranges, if requested")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/linux-mm/CAMuHMdVWviQ7O9yBFE3f=ev0eVb1CnsQvR6SKtEROBbM6z7g3w@mail.gmail.com/
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Frank van der Linden <fvdl@google.com>
---
mm/cma.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/mm/cma.c b/mm/cma.c
index b06d5fe73399..15632939f20a 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -35,7 +35,7 @@
struct cma cma_areas[MAX_CMA_AREAS];
unsigned int cma_area_count;
-static int __init __cma_declare_contiguous_nid(phys_addr_t base,
+static int __init __cma_declare_contiguous_nid(phys_addr_t *basep,
phys_addr_t size, phys_addr_t limit,
phys_addr_t alignment, unsigned int order_per_bit,
bool fixed, const char *name, struct cma **res_cma,
@@ -370,7 +370,7 @@ int __init cma_declare_contiguous_multi(phys_addr_t total_size,
phys_addr_t align, unsigned int order_per_bit,
const char *name, struct cma **res_cma, int nid)
{
- phys_addr_t start, end;
+ phys_addr_t start = 0, end;
phys_addr_t size, sizesum, sizeleft;
struct cma_init_memrange *mrp, *mlp, *failed;
struct cma_memrange *cmrp;
@@ -384,7 +384,7 @@ int __init cma_declare_contiguous_multi(phys_addr_t total_size,
/*
* First, try it the normal way, producing just one range.
*/
- ret = __cma_declare_contiguous_nid(0, total_size, 0, align,
+ ret = __cma_declare_contiguous_nid(&start, total_size, 0, align,
order_per_bit, false, name, res_cma, nid);
if (ret != -ENOMEM)
goto out;
@@ -580,7 +580,7 @@ int __init cma_declare_contiguous_nid(phys_addr_t base,
{
int ret;
- ret = __cma_declare_contiguous_nid(base, size, limit, alignment,
+ ret = __cma_declare_contiguous_nid(&base, size, limit, alignment,
order_per_bit, fixed, name, res_cma, nid);
if (ret != 0)
pr_err("Failed to reserve %ld MiB\n",
@@ -592,14 +592,14 @@ int __init cma_declare_contiguous_nid(phys_addr_t base,
return ret;
}
-static int __init __cma_declare_contiguous_nid(phys_addr_t base,
+static int __init __cma_declare_contiguous_nid(phys_addr_t *basep,
phys_addr_t size, phys_addr_t limit,
phys_addr_t alignment, unsigned int order_per_bit,
bool fixed, const char *name, struct cma **res_cma,
int nid)
{
phys_addr_t memblock_end = memblock_end_of_DRAM();
- phys_addr_t highmem_start;
+ phys_addr_t highmem_start, base = *basep;
int ret;
/*
@@ -722,12 +722,15 @@ static int __init __cma_declare_contiguous_nid(phys_addr_t base,
}
ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
- if (ret)
+ if (ret) {
memblock_phys_free(base, size);
+ return ret;
+ }
(*res_cma)->nid = nid;
+ *basep = base;
- return ret;
+ return 0;
}
static void cma_debug_show_areas(struct cma *cma)
--
2.49.0.504.g3bcea36a83-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mm/cma: report base address of single range correctly
2025-04-08 16:40 [PATCH v2] mm/cma: report base address of single range correctly Frank van der Linden
@ 2025-04-08 21:03 ` Andrew Morton
2025-04-08 21:08 ` Frank van der Linden
2025-04-17 7:35 ` Geert Uytterhoeven
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2025-04-08 21:03 UTC (permalink / raw)
To: Frank van der Linden
Cc: muchun.song, linux-mm, linux-kernel, Geert Uytterhoeven
On Tue, 8 Apr 2025 16:40:00 +0000 Frank van der Linden <fvdl@google.com> wrote:
> The cma_declare_contiguous_nid code was refactored by
> commit c009da4258f9 ("mm, cma: support multiple contiguous
> ranges, if requested"), so that it could use an internal
> function to attempt a single range area first, and then
> try a multi-range one.
>
> However, that meant that the actual base address used for
> the !fixed case (base == 0) wasn't available one level up
> to be printed in the informational message, and it would
> always end up printing a base address of 0 in the boot
> message.
>
> Make the internal function take a phys_addr_t pointer to
> the base address, so that the value is available to the
> caller.
Changes from v1 are:
--- a/mm/cma.c~mm-cma-report-base-address-of-single-range-correctly-v2
+++ a/mm/cma.c
@@ -722,14 +722,15 @@ static int __init __cma_declare_contiguo
}
ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
- if (ret)
+ if (ret) {
memblock_phys_free(base, size);
- else {
- (*res_cma)->nid = nid;
- *basep = base;
+ return ret;
}
- return ret;
+ (*res_cma)->nid = nid;
+ *basep = base;
+
+ return 0;
}
static void cma_debug_show_areas(struct cma *cma)
_
Which appears to be just a little cleanup?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mm/cma: report base address of single range correctly
2025-04-08 21:03 ` Andrew Morton
@ 2025-04-08 21:08 ` Frank van der Linden
0 siblings, 0 replies; 4+ messages in thread
From: Frank van der Linden @ 2025-04-08 21:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: muchun.song, linux-mm, linux-kernel, Geert Uytterhoeven
On Tue, Apr 8, 2025 at 2:03 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Tue, 8 Apr 2025 16:40:00 +0000 Frank van der Linden <fvdl@google.com> wrote:
>
> > The cma_declare_contiguous_nid code was refactored by
> > commit c009da4258f9 ("mm, cma: support multiple contiguous
> > ranges, if requested"), so that it could use an internal
> > function to attempt a single range area first, and then
> > try a multi-range one.
> >
> > However, that meant that the actual base address used for
> > the !fixed case (base == 0) wasn't available one level up
> > to be printed in the informational message, and it would
> > always end up printing a base address of 0 in the boot
> > message.
> >
> > Make the internal function take a phys_addr_t pointer to
> > the base address, so that the value is available to the
> > caller.
>
> Changes from v1 are:
>
> --- a/mm/cma.c~mm-cma-report-base-address-of-single-range-correctly-v2
> +++ a/mm/cma.c
> @@ -722,14 +722,15 @@ static int __init __cma_declare_contiguo
> }
>
> ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
> - if (ret)
> + if (ret) {
> memblock_phys_free(base, size);
> - else {
> - (*res_cma)->nid = nid;
> - *basep = base;
> + return ret;
> }
>
> - return ret;
> + (*res_cma)->nid = nid;
> + *basep = base;
> +
> + return 0;
> }
>
> static void cma_debug_show_areas(struct cma *cma)
> _
>
> Which appears to be just a little cleanup?
Correct, it just fixes a style nit that Geert pointed out.
- Frank
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mm/cma: report base address of single range correctly
2025-04-08 16:40 [PATCH v2] mm/cma: report base address of single range correctly Frank van der Linden
2025-04-08 21:03 ` Andrew Morton
@ 2025-04-17 7:35 ` Geert Uytterhoeven
1 sibling, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2025-04-17 7:35 UTC (permalink / raw)
To: Frank van der Linden; +Cc: akpm, muchun.song, linux-mm, linux-kernel
Hi Frank,
On Tue, 8 Apr 2025 at 18:40, Frank van der Linden <fvdl@google.com> wrote:
> The cma_declare_contiguous_nid code was refactored by
> commit c009da4258f9 ("mm, cma: support multiple contiguous
> ranges, if requested"), so that it could use an internal
> function to attempt a single range area first, and then
> try a multi-range one.
>
> However, that meant that the actual base address used for
> the !fixed case (base == 0) wasn't available one level up
> to be printed in the informational message, and it would
> always end up printing a base address of 0 in the boot
> message.
>
> Make the internal function take a phys_addr_t pointer to
> the base address, so that the value is available to the
> caller.
>
> Fixes: c009da4258f9 ("mm, cma: support multiple contiguous ranges, if requested")
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Closes: https://lore.kernel.org/linux-mm/CAMuHMdVWviQ7O9yBFE3f=ev0eVb1CnsQvR6SKtEROBbM6z7g3w@mail.gmail.com/
Thanks for your patch, which is now commit 60580e0bd587b1df ("mm/cma:
report base address of single range correctly") upstream.
> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
FTR, the email addres in this tag does not match the tag given in
https://lore.kernel.org/all/CAMuHMdUeGjbOx-aJTvwOVBWdUFmY7wU-p3mKaCbEzQ4PbJDqNg@mail.gmail.com
> Signed-off-by: Frank van der Linden <fvdl@google.com>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-17 7:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-08 16:40 [PATCH v2] mm/cma: report base address of single range correctly Frank van der Linden
2025-04-08 21:03 ` Andrew Morton
2025-04-08 21:08 ` Frank van der Linden
2025-04-17 7:35 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox