* [U-Boot] [PATCH] fdt: Fixup only valid memory banks
@ 2018-01-30 10:34 Thierry Reding
2018-01-30 11:41 ` Lothar Waßmann
2018-01-30 17:59 ` Stephen Warren
0 siblings, 2 replies; 4+ messages in thread
From: Thierry Reding @ 2018-01-30 10:34 UTC (permalink / raw)
To: u-boot
From: Thierry Reding <treding@nvidia.com>
Memory banks with address 0 and size 0 are empty and should not be
passed to the OS via device tree.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
common/fdt_support.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 724452d75452..8b33f6773d27 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -457,7 +457,7 @@ int fdt_record_loadable(void *blob, u32 index, const char *name,
int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
{
int err, nodeoffset;
- int len;
+ int len, i;
u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size */
if (banks > MEMORY_BANKS_MAX) {
@@ -489,6 +489,12 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
if (!banks)
return 0;
+ for (i = 0; i < banks; i++)
+ if (start[i] == 0 && size[i] == 0)
+ break;
+
+ banks = i;
+
len = fdt_pack_reg(blob, tmp, start, size, banks);
err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);
--
2.15.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] fdt: Fixup only valid memory banks
2018-01-30 10:34 [U-Boot] [PATCH] fdt: Fixup only valid memory banks Thierry Reding
@ 2018-01-30 11:41 ` Lothar Waßmann
2018-01-30 12:09 ` Thierry Reding
2018-01-30 17:59 ` Stephen Warren
1 sibling, 1 reply; 4+ messages in thread
From: Lothar Waßmann @ 2018-01-30 11:41 UTC (permalink / raw)
To: u-boot
Hi,
On Tue, 30 Jan 2018 11:34:17 +0100 Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Memory banks with address 0 and size 0 are empty and should not be
> passed to the OS via device tree.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> common/fdt_support.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 724452d75452..8b33f6773d27 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -457,7 +457,7 @@ int fdt_record_loadable(void *blob, u32 index, const char *name,
> int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
> {
> int err, nodeoffset;
> - int len;
> + int len, i;
> u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size */
>
> if (banks > MEMORY_BANKS_MAX) {
> @@ -489,6 +489,12 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
> if (!banks)
> return 0;
>
> + for (i = 0; i < banks; i++)
> + if (start[i] == 0 && size[i] == 0)
> + break;
> +
> + banks = i;
> +
> len = fdt_pack_reg(blob, tmp, start, size, banks);
>
> err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);
>
Does an empty bank always imply the end of the list, or
Is it a valid scenario to have intervening empty banks?
Lothar Waßmann
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] fdt: Fixup only valid memory banks
2018-01-30 11:41 ` Lothar Waßmann
@ 2018-01-30 12:09 ` Thierry Reding
0 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2018-01-30 12:09 UTC (permalink / raw)
To: u-boot
On Tue, Jan 30, 2018 at 12:41:15PM +0100, Lothar Waßmann wrote:
> Hi,
>
> On Tue, 30 Jan 2018 11:34:17 +0100 Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > Memory banks with address 0 and size 0 are empty and should not be
> > passed to the OS via device tree.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> > common/fdt_support.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/common/fdt_support.c b/common/fdt_support.c
> > index 724452d75452..8b33f6773d27 100644
> > --- a/common/fdt_support.c
> > +++ b/common/fdt_support.c
> > @@ -457,7 +457,7 @@ int fdt_record_loadable(void *blob, u32 index, const char *name,
> > int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
> > {
> > int err, nodeoffset;
> > - int len;
> > + int len, i;
> > u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size */
> >
> > if (banks > MEMORY_BANKS_MAX) {
> > @@ -489,6 +489,12 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
> > if (!banks)
> > return 0;
> >
> > + for (i = 0; i < banks; i++)
> > + if (start[i] == 0 && size[i] == 0)
> > + break;
> > +
> > + banks = i;
> > +
> > len = fdt_pack_reg(blob, tmp, start, size, banks);
> >
> > err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);
> >
> Does an empty bank always imply the end of the list, or
> Is it a valid scenario to have intervening empty banks?
I think it's a fair assumption that there aren't going to be any holes.
The vast majority of boards will only every initialize a single bank or
perhaps two. There's a few odd ones (hisilicon/hikey for example) that
adds more, but they are still all contiguous.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180130/5225481b/attachment.sig>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] fdt: Fixup only valid memory banks
2018-01-30 10:34 [U-Boot] [PATCH] fdt: Fixup only valid memory banks Thierry Reding
2018-01-30 11:41 ` Lothar Waßmann
@ 2018-01-30 17:59 ` Stephen Warren
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Warren @ 2018-01-30 17:59 UTC (permalink / raw)
To: u-boot
On 01/30/2018 03:34 AM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Memory banks with address 0 and size 0 are empty and should not be
> passed to the OS via device tree.
> if (!banks)
> return 0;
>
> + for (i = 0; i < banks; i++)
> + if (start[i] == 0 && size[i] == 0)
> + break;
> +
> + banks = i;
Do we want to move the for loop above the check for if (!banks)?
Should we put braces around the multi-line body of the for loop?
Aside from that,
Acked-by: Stephen Warren <swarren@nvidia.com>
> +
> len = fdt_pack_reg(blob, tmp, start, size, banks);
>
> err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-30 17:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-30 10:34 [U-Boot] [PATCH] fdt: Fixup only valid memory banks Thierry Reding
2018-01-30 11:41 ` Lothar Waßmann
2018-01-30 12:09 ` Thierry Reding
2018-01-30 17:59 ` Stephen Warren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox