In function get_ram_size() and for 2 last cases the content of the base address (*base) is not restored even it is correctly saved in stack (in save[i]).
This patch solved this issue. The content of the base address is saved in new variable in stack (save_base) to avoid the need of other information (value of i) and restored in all the cases. Signed-off-by: Patrick Delaunay <patrick.delau...@st.com> Reviewed-by: CITOOLS <smet-aci-revi...@lists.codex.cro.st.com> Reviewed-by: CIBUILD <smet-aci-bui...@lists.codex.cro.st.com> --- issue detected on my custom board with - base = 0xC0000000 - size = maxsize = 0x4000000 The loop is completely executed and the size is correctly detected, but content in 0xC0000000 is not restored So I have 0xC0000000 = 0x0 at the end of the function. That cause issue in my use-case because U-Boot in loaded at 0xC1000000 and some information can be saved by ATF in DDR at 0xC0000000 address. And the content of DDR is modified by this function. common/memsize.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/memsize.c b/common/memsize.c index 0fb9ba5..d632293 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -27,7 +27,8 @@ DECLARE_GLOBAL_DATA_PTR; long get_ram_size(long *base, long maxsize) { volatile long *addr; - long save[32]; + long save[31]; + long save_base; long cnt; long val; long size; @@ -43,7 +44,7 @@ long get_ram_size(long *base, long maxsize) addr = base; sync(); - save[i] = *addr; + save_base = *addr; sync(); *addr = 0; @@ -51,7 +52,7 @@ long get_ram_size(long *base, long maxsize) if ((val = *addr) != 0) { /* Restore the original data before leaving the function. */ sync(); - *addr = save[i]; + *base = save_base; for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) { addr = base + cnt; sync(); @@ -76,9 +77,11 @@ long get_ram_size(long *base, long maxsize) addr = base + cnt; *addr = save[--i]; } + *base = save_base; return (size); } } + *base = save_base; return (maxsize); } -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot