diff mbox

[U-Boot,v2] fdt_support: Check for bank size before updating memory node

Message ID 1445685744-21616-1-git-send-email-lokeshvutla@ti.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Lokesh Vutla Oct. 24, 2015, 11:22 a.m. UTC
In case if one of the bank that is passed is of size zero, then u-boot
will be updating memory node with a bank of size zero. There is no need
to update memory node if size is zero, so check for bank size before
updating.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
Changes since v1:
- Fixed a typo in commit message.

 common/fdt_support.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Simon Glass Oct. 29, 2015, 5:16 p.m. UTC | #1
On 24 October 2015 at 05:22, Lokesh Vutla <lokeshvutla@ti.com> wrote:
> In case if one of the bank that is passed is of size zero, then u-boot
> will be updating memory node with a bank of size zero. There is no need
> to update memory node if size is zero, so check for bank size before
> updating.
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> ---
> Changes since v1:
> - Fixed a typo in commit message.
>
>  common/fdt_support.c | 3 +++
>  1 file changed, 3 insertions(+)

Acked-by: Simon Glass <sjg@chromium.org>
Tom Rini Nov. 13, 2015, 1:31 a.m. UTC | #2
On Sat, Oct 24, 2015 at 04:52:24PM +0530, Lokesh Vutla wrote:

> In case if one of the bank that is passed is of size zero, then u-boot
> will be updating memory node with a bank of size zero. There is no need
> to update memory node if size is zero, so check for bank size before
> updating.
> 
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> Acked-by: Simon Glass <sjg@chromium.org>

So, I thought about this more, and looked at device trees, more, and
concluded, we're stuck with the interface we have.  Today there's still
many boards (such as the whole Beaglebone family!) that are setting
incorrect sizes in the DTS but being correctly fixed up.  We'll need to
continue with the other tricks that can be done to pass in more memory
in the memory node.
diff mbox

Patch

diff --git a/common/fdt_support.c b/common/fdt_support.c
index f86365e..0019eef 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -401,6 +401,9 @@  static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
 	char *p = buf;
 
 	for (i = 0; i < n; i++) {
+		if (size[i] == 0)
+			continue;
+
 		if (address_cells == 2)
 			*(fdt64_t *)p = cpu_to_fdt64(address[i]);
 		else