U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] common/memsize.c: Fix get_ram_size() original data restore
@ 2025-03-14 10:06 Stefan Eichenberger
  2025-03-14 13:28 ` Francesco Dolcini
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Stefan Eichenberger @ 2025-03-14 10:06 UTC (permalink / raw)
  To: trini, stefan.eichenberger, s-k6, w.egorov, n-francis,
	emanuele.ghidoli, francesco.dolcini
  Cc: u-boot

From: Stefan Eichenberger <stefan.eichenberger@toradex.com>

The get_ram_size() function fails to restore the original RAM data when
the data cache is enabled. This issue was observed on an AM625 R5 SPL
with 512MB of RAM and is a regression that became visible with
commit bc07851897bd ("board: ti: Pull redundant DDR functions to a common
location and Fixup DDR size when ECC is enabled").

Observed boot failure messages:
  Warning: Did not detect image signing certificate. Skipping authentication to prevent boot failure. This will fail on Security Enforcing(HS-SE) devices
  Authentication passed
  Starting ATF on ARM64 core...

The system then hangs. This indicates that without a data cache flush,
data in the cache is not coherent with RAM, preventing the system from
booting. This was verified by printing the content of this address when
the issue occurs.

Add a data cache flush after each restore operation to resolve this
issue.

Fixes: bc07851897bd ("board: ti: Pull redundant DDR functions to a common location and Fixup DDR size when ECC is enabled")
Fixes: 1c64b98c1ec4 ("common/memsize.c: Fix get_ram_size() when cache is enabled")
Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
 common/memsize.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/common/memsize.c b/common/memsize.c
index 86109579c95..8fa1b0e2a00 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -82,6 +82,8 @@ long get_ram_size(long *base, long maxsize)
 			addr  = base + cnt;
 			sync();
 			*addr = save[--i];
+			if (dcache_en)
+				dcache_flush_invalidate(addr);
 		}
 		return (0);
 	}
@@ -90,6 +92,8 @@ long get_ram_size(long *base, long maxsize)
 		addr = base + cnt;	/* pointer arith! */
 		val = *addr;
 		*addr = save[--i];
+		if (dcache_en)
+			dcache_flush_invalidate(addr);
 		if (val != ~cnt) {
 			size = cnt * sizeof(long);
 			/*
@@ -101,6 +105,8 @@ long get_ram_size(long *base, long maxsize)
 			     cnt <<= 1) {
 				addr  = base + cnt;
 				*addr = save[--i];
+				if (dcache_en)
+					dcache_flush_invalidate(addr);
 			}
 			/* warning: don't restore save_base in this case,
 			 * it is already done in the loop because
@@ -112,6 +118,8 @@ long get_ram_size(long *base, long maxsize)
 		}
 	}
 	*base = save_base;
+	if (dcache_en)
+		dcache_flush_invalidate(base);
 
 	return (maxsize);
 }
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-03-02 22:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-14 10:06 [PATCH v1] common/memsize.c: Fix get_ram_size() original data restore Stefan Eichenberger
2025-03-14 13:28 ` Francesco Dolcini
2025-03-14 16:34 ` Tom Rini
2025-03-17 14:25   ` Stefan Eichenberger
2026-02-26  7:05 ` Francesco Dolcini
2026-02-26 14:23   ` Tom Rini
2026-02-26 16:11     ` Francesco Dolcini
2026-02-26 16:30       ` Stefan Eichenberger
2026-02-26 16:31         ` Tom Rini
2026-02-27 10:13           ` Francis, Neha
2026-02-27 10:39             ` Emanuele Ghidoli
2026-02-27 17:39               ` Tom Rini
2026-03-02 11:13                 ` Emanuele Ghidoli
2026-02-27 10:40             ` Francesco Dolcini
2026-03-02  7:41 ` Francesco Dolcini
2026-03-02 22:10 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox