* [U-Boot] [PATCH v2] fdt_support: Use VLA instead of MEMORY_BANKS_MAX
2018-08-12 20:46 [U-Boot] [PATCH v2] fdt_support: Use VLA instead of MEMORY_BANKS_MAX Ramon Fried
@ 2018-08-12 20:01 ` Lukasz Majewski
2018-08-13 5:23 ` Ramon Fried
0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Majewski @ 2018-08-12 20:01 UTC (permalink / raw)
To: u-boot
Hi Ramon,
> Instead of relaying on user to configure MEMORY_BANKS_MAX
> correctly, use VLA (variable length array) to accommodate the
> required banks.
>
> Fixes: 2a1f4f1758b5 ("Revert "fdt_support: Use CONFIG_NR_DRAM_BANKS if
> defined"")
>
> Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
> ---
> Resending same patch but with the right email address
> 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 34d2bd59c4..e8982367a0 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 */
Why cannot we read the RAM size from "memory" DTS property?
SDRAM is continuous - there are no "holes" in it.
The memory banks and their sizes are going to be replaced by DTS
"memory" description anyway.
>
> - 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) {
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180812/869857a3/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] fdt_support: Use VLA instead of MEMORY_BANKS_MAX
@ 2018-08-12 20:46 Ramon Fried
2018-08-12 20:01 ` Lukasz Majewski
0 siblings, 1 reply; 3+ messages in thread
From: Ramon Fried @ 2018-08-12 20:46 UTC (permalink / raw)
To: u-boot
Instead of relaying on user to configure MEMORY_BANKS_MAX
correctly, use VLA (variable length array) to accommodate the
required banks.
Fixes: 2a1f4f1758b5 ("Revert "fdt_support: Use CONFIG_NR_DRAM_BANKS if
defined"")
Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---
Resending same patch but with the right email address
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 34d2bd59c4..e8982367a0 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.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] fdt_support: Use VLA instead of MEMORY_BANKS_MAX
2018-08-12 20:01 ` Lukasz Majewski
@ 2018-08-13 5:23 ` Ramon Fried
0 siblings, 0 replies; 3+ messages in thread
From: Ramon Fried @ 2018-08-13 5:23 UTC (permalink / raw)
To: u-boot
On Sun, Aug 12, 2018 at 11:02 PM Lukasz Majewski <lukma@denx.de> wrote:
>
> Hi Ramon,
>
> > Instead of relaying on user to configure MEMORY_BANKS_MAX
> > correctly, use VLA (variable length array) to accommodate the
> > required banks.
> >
> > Fixes: 2a1f4f1758b5 ("Revert "fdt_support: Use CONFIG_NR_DRAM_BANKS if
> > defined"")
> >
> > Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
> > ---
> > Resending same patch but with the right email address
> > 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 34d2bd59c4..e8982367a0 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 */
>
> Why cannot we read the RAM size from "memory" DTS property?
> SDRAM is continuous - there are no "holes" in it.
>
> The memory banks and their sizes are going to be replaced by DTS
> "memory" description anyway.
>
I'm not sure I understand what your suggesting.
The whole purpose of this function is to fixup the DTS, so how can we
read the information from it ?
> >
> > - 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) {
>
>
>
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-13 5:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-12 20:46 [U-Boot] [PATCH v2] fdt_support: Use VLA instead of MEMORY_BANKS_MAX Ramon Fried
2018-08-12 20:01 ` Lukasz Majewski
2018-08-13 5:23 ` Ramon Fried
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.