Re: [PATCH] mm/cma: report base address of single range correctly
From: Frank van der Linden
Date: Tue Apr 08 2025 - 12:43:02 EST
On Tue, Apr 8, 2025 at 1:06 AM Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
>
> On Mon, 7 Apr 2025 at 18:54, Frank van der Linden <fvdl@xxxxxxxxxx> 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@xxxxxxxxxxxxxx>
> > Closes: https://lore.kernel.org/linux-mm/CAMuHMdVWviQ7O9yBFE3f=ev0eVb1CnsQvR6SKtEROBbM6z7g3w@xxxxxxxxxxxxxx/
> > Signed-off-by: Frank van der Linden <fvdl@xxxxxxxxxx>
>
> Thanks, this fixes the issue!
> Tested-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
>
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -724,8 +724,10 @@ 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)
> > memblock_phys_free(base, size);
> > -
> > - (*res_cma)->nid = nid;
> > + else {
> > + (*res_cma)->nid = nid;
> > + *basep = base;
> > + }
>
> Please add curly braces to the other branch, too.
>
> Or perhaps restructure as:
>
> if (ret) {
> memblock_phys_free(base, size);
> return ret;
> }
>
> (*res_cma)->nid = nid;
> *basep = base;
>
> return 0;
>
> >
> > return ret;
> > }
>
> Gr{oetje,eeting}s,
>
> Geert
>
Thanks for testing - I sent a v2 with the style nit fixed.
Thanks again,
- Frank