[U-Boot] [PATCH] fdt_support: Use VLA instead of MEMORY_BANKS_MAX

Tom Rini trini at konsulko.com
Mon Aug 13 14:52:05 UTC 2018


On Mon, Aug 13, 2018 at 08:20:03AM +0100, Peter Robinson wrote:

> On Sun, Aug 12, 2018 at 9:37 PM, Ramon Fried <ramon.fried at gmail.com> wrote:
> > From: Ramon Fried <ramon.fried at intel.com>
> >
> > Instead of relaying on user to configure MEMORY_BANKS_MAX
> > correctly, use VLA (variable length array) to accommodate the
> > required banks.
> 
> With the kernel actively removing VLAs [1] does it make sense for us
> to use them?

Agreed.

Also, why is the answer NOT to go back to the way things were with
5e5745465c94 and increase CONFIG_NR_DRAM_BANKS when needed?  It seems
like the problem may be platforms setting this to 1 when really it
should be higher _even_if_ the memory space in question is contiguous.
Yes, you've always been able to say we have 1 bank of N physical chips
and it's been OK, but now I guess we're finally hitting the point where
that doesn't work.

> 
> [1] https://lwn.net/Articles/749064/
> 
> > Fixes: 2a1f4f1758b5 ("Revert "fdt_support: Use CONFIG_NR_DRAM_BANKS if
> > defined"")
> >
> > Signed-off-by: Ramon Fried <ramon.fried at intel.com>
> > ---
> >  common/fdt_support.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/common/fdt_support.c b/common/fdt_support.c
> > index 34d2bd5..e898236 100644
> > --- a/common/fdt_support.c
> > +++ b/common/fdt_support.c
> > @@ -409,19 +409,14 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
> >         return p - (char *)buf;
> >  }
> >
> > -#define MEMORY_BANKS_MAX 4
> >  int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
> >  {
> >         int err, nodeoffset;
> >         int len, i;
> > -       u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size */
> > +       u8 tmp[banks * 16]; /* Up to 64-bit address + 64-bit size */
> >
> > -       if (banks > MEMORY_BANKS_MAX) {
> > -               printf("%s: num banks %d exceeds hardcoded limit %d."
> > -                      " Recompile with higher MEMORY_BANKS_MAX?\n",
> > -                      __FUNCTION__, banks, MEMORY_BANKS_MAX);
> > +       if (!banks)
> >                 return -1;
> > -       }
> >
> >         err = fdt_check_header(blob);
> >         if (err < 0) {
> > --
> > 2.7.4
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > https://lists.denx.de/listinfo/u-boot

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180813/49254a37/attachment.sig>


More information about the U-Boot mailing list