Commit f850371997fb3688885a814902fed07d22f113ef

Authored by Marek Vasut
Committed by Tom Rini
1 parent 792b204798

fdt: fix get_next_memory_node()

The get_next_memory_node() always sets mem to -1 , which is incorrect,
because then every iteration of memory bank parsing will start from the
first memory bank instead of the previous one.

On systems with 1 memory bank defined in DT and CONFIG_NR_DRAM_BANKS=4 ,
like ie. r8a77965-salvator-x , this will result in U-Boot incorrectly
reporting four identical memory banks with the same memory configuration.

Fix this by setting mem to startoffset value, which restores the behavior
before the fixed patch was applied.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Fixes: 452bc121027d ("fdt: fix fdtdec_setup_memory_banksize()")
Tested-by: Michal Simek <michal.simek@xilinx.com> [on ZynqMP}

Showing 1 changed file with 1 additions and 3 deletions Side-by-side Diff

... ... @@ -1182,10 +1182,8 @@
1182 1182  
1183 1183 #if defined(CONFIG_NR_DRAM_BANKS)
1184 1184  
1185   -static int get_next_memory_node(const void *blob, int startoffset)
  1185 +static int get_next_memory_node(const void *blob, int mem)
1186 1186 {
1187   - int mem = -1;
1188   -
1189 1187 do {
1190 1188 mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem,
1191 1189 "device_type", "memory", 7);