u-boot-brain/arch/arm/cpu/armv7
Siarhei Siamashka c3d2b963c6 sunxi: Fix buggy sun6i/sun8i DRAM size detection logic
After reboot, reset or even short power off, DRAM typically retains
the old stale data for some period of time (for this type of memory,
the bits of data are stored in slowly discharging capacitors).

The current sun6i/sun8i DRAM size detection logic, which is
inherited from the Allwinner code, relies on using a large magic
signature with the hope that it is unique enough and unlikely to
ever accidentally match this leftover garbage data in RAM. But
this approach is inherently unsafe, as can be demonstrated using
the following test program:

/***** A testcase for reproducing the problem ******/

void main(int argc, char *argv[])
{
    size_t size, i;
    uint32_t *buf;
    /* Allocate the buffer */
    if (argc < 2 || !(size = (size_t)atoi(argv[1]) * 1048576) ||
                    !(buf = malloc(size))) {
        printf("Need buffer size in MiB as a cmdline argument\n");
        exit(1);
    }
    /* Fill it with the Allwinner DRAM "magic" values */
    for (i = 0; i < size / 4; i++)
        buf[i] = 0xaa55aa55 + ((uintptr_t)&buf[i] / 4) % 64;
    /* Try to reboot */
    system("reboot");
    /* And wait */
    for (;;) {}
}
/***************************************************/

If this test program is run on the device (giving it a large
chunk of memory), then the DRAM size detection logic in u-boot
gets confused after reboot and fails to initialize DRAM properly.

A better approach is not to rely on luck and abstain from making
any assumptions about the properties of the leftover garbage
data in RAM. Instead just use a more reliable code for testing
whether two different addresses refer to the same memory location.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2015-01-14 14:56:37 +01:00
..
am33xx am33xx: Drop timer_init call from s_init 2015-01-05 15:13:45 -05:00
armada-xp arm: armada-xp: Add basic support for Marvell Armada XP SoC 2014-10-23 09:59:21 -04:00
at91 ARM: atmel: add sama5d4ek board support 2014-11-17 08:47:18 -05:00
bcm281xx bcm281xx: add support for "USB OTG clock" 2014-12-29 16:31:23 -05:00
bcmcygnus arm: bcmcygnus: Add bcmcygnus u-architecture 2014-08-30 07:46:40 -04:00
bcmnsp arm: bcmnsp: Add bcmnsp u-architecture 2014-08-30 07:46:40 -04:00
exynos arm: exynos: clock: support SPLL as mmc source clock for exynos5420 2014-12-24 10:56:24 +09:00
highbank kconfig: arm: introduce symbol for ARM CPUs 2014-10-29 09:02:09 -04:00
iproc-common arm: iproc: Initial commit of iproc architecture code 2014-08-30 07:46:40 -04:00
keystone keystone: set default pci mode to root complex 2015-01-05 15:13:47 -05:00
kona-common bcm281xx: add support for "USB OTG clock" 2014-12-29 16:31:23 -05:00
ls102xa ls1021a: adding a secondary core boot address and kick functions 2014-12-11 09:41:53 -08:00
mx5 imx: consolidate set_chipselect_size function 2014-11-20 10:30:19 +01:00
mx6 Merge branch 'master' of git://git.denx.de/u-boot-spi 2015-01-02 07:42:58 -05:00
omap3 omap3: cm-t3517: add basic board support 2014-11-06 11:04:41 -05:00
omap4 Revert "ARM: omap4: Update sdram setting for panda rev A6" 2015-01-05 15:13:45 -05:00
omap5 beagle_x15: add board support for Beagle x15 2014-12-04 11:04:39 -05:00
omap-common arm: omap: reset sata on boot 2015-01-05 15:13:47 -05:00
rmobile arm: rmobile: Add support gose board 2014-11-10 09:43:48 +09:00
s5p-common armv7: convert makefiles to Kbuild style 2013-10-31 12:53:39 -04:00
s5pc1xx kconfig: arm: introduce symbol for ARM CPUs 2014-10-29 09:02:09 -04:00
socfpga socfpga: Drop redundant save_boot_params 2015-01-05 15:13:44 -05:00
stv0991 stv0991: enable ethernet support 2014-12-09 15:16:19 -05:00
sunxi sunxi: Fix buggy sun6i/sun8i DRAM size detection logic 2015-01-14 14:56:37 +01:00
tegra20 linux/kernel.h: sync min, max, min3, max3 macros with Linux 2014-11-23 06:48:30 -05:00
tegra30 tegra: do not descend into empty directories 2014-11-23 06:49:02 -05:00
tegra114 tegra: do not descend into empty directories 2014-11-23 06:49:02 -05:00
tegra124 ARM: tegra: Add support for nyan-big board 2014-12-11 13:18:44 -07:00
tegra-common kconfig: arm: select CPU_V7 for some new boards 2014-11-13 08:37:18 -05:00
u8500 armv7: convert makefiles to Kbuild style 2013-10-31 12:53:39 -04:00
uniphier ARM: UniPhier: add UART initialization routine for low-level debug 2015-01-08 23:01:56 +09:00
vf610 arm: vf610: improve evaluation of reset source 2014-12-01 10:20:22 +01:00
zynq Merge branch 'zynq' of git://www.denx.de/git/u-boot-microblaze 2014-11-13 08:38:17 -05:00
arch_timer.c arm: add support for arch timer 2014-04-17 17:24:38 -04:00
cache_v7.c ARM: cache_v7: Various minor cleanups 2014-11-12 07:25:41 +01:00
config.mk Merge branch 'master' of git://git.denx.de/u-boot-arm 2014-02-26 16:49:58 -05:00
cpu.c Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
Kconfig ARM: bootm: Allow booting in secure mode on hyp capable systems 2014-11-24 09:09:52 +01:00
lowlevel_init.S arm: use canonical sub mnemonic 2014-01-14 12:38:47 +01:00
Makefile stv0991: Add basic stv0991 architecture support 2014-12-09 15:16:01 -05:00
nonsec_virt.S ARM: HYP/non-sec: Fix the ARCH Timer frequency setting. 2014-12-11 09:41:45 -08:00
psci.S ARM: HYP/non-sec: add generic ARMv7 PSCI code 2014-07-28 17:19:18 +02:00
start.S arm: relocate the exception vectors 2014-10-29 09:02:50 -04:00
syslib.c ARM: OMAP: hide custom bit manipulation function sr32() 2014-04-17 14:39:54 -04:00
virt-dt.c ARM: bootm: do not add PSCI to fdt when booting in secure mode. 2015-01-05 15:02:03 -05:00
virt-v7.c ARM: HYP/non-sec: remove MIDR check to validate CBAR 2014-07-28 17:19:55 +02:00