public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Fix unreliable detection of DRAM size on Orange Pi 3
@ 2019-07-28 23:39 megous at megous.com
  2019-08-24 20:07 ` Ondřej Jirman
  0 siblings, 1 reply; 9+ messages in thread
From: megous at megous.com @ 2019-07-28 23:39 UTC (permalink / raw)
  To: u-boot

From: Ondrej Jirman <megous@megous.com>

Orange Pi 3 has 2 GiB of DRAM, that sometime get misdetected
as 4 GiB, due to false negative result from mctl_mem_matches()
when detecting number of column address bits. This leads to
u-boot detecting more address bits than there are and the
boot process hangs shortly after.

In mctl_mem_matches() we need to wait for each write to finish,
separately. Without this, the check is not reliable for some
unknown reason, probably having to do with unpredictable memory
access ordering.

Patch was made with help from André Przywara, who noticed that
my original idea about detection failing due to read-back from
cache without involving DRAM was false, because data cache is
still of at the time of the DRAM size autodetection.

Signed-off-by: Ondrej Jirman <megous@megous.com>
Cc: André Przywara <andre.przywara@arm.com>
---
 arch/arm/mach-sunxi/dram_helpers.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/dram_helpers.c b/arch/arm/mach-sunxi/dram_helpers.c
index 239ab421a8..6dba448638 100644
--- a/arch/arm/mach-sunxi/dram_helpers.c
+++ b/arch/arm/mach-sunxi/dram_helpers.c
@@ -30,6 +30,7 @@ bool mctl_mem_matches(u32 offset)
 {
 	/* Try to write different values to RAM at two addresses */
 	writel(0, CONFIG_SYS_SDRAM_BASE);
+	dsb();
 	writel(0xaa55aa55, (ulong)CONFIG_SYS_SDRAM_BASE + offset);
 	dsb();
 	/* Check if the same value is actually observed when reading back */
-- 
2.22.0

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

end of thread, other threads:[~2019-08-30 20:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-28 23:39 [U-Boot] [PATCH] Fix unreliable detection of DRAM size on Orange Pi 3 megous at megous.com
2019-08-24 20:07 ` Ondřej Jirman
2019-08-25 14:41   ` Siarhei Siamashka
2019-08-25 16:12     ` Ondřej Jirman
2019-08-25 23:36       ` Siarhei Siamashka
2019-08-30  0:44     ` André Przywara
2019-08-30 10:56       ` Ondřej Jirman
2019-08-30 16:19         ` Andre Przywara
2019-08-30 20:40           ` Ondřej Jirman

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