u-boot/arch/arm/cpu
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
..
arm720t kbuild: use SoC-specific CONFIG to descend into SoC directory 2014-11-23 06:49:02 -05:00
arm920t kbuild: use SoC-specific CONFIG to descend into SoC directory 2014-11-23 06:49:02 -05:00
arm926ejs mx25: Fix boot hang by avoiding vector relocation 2015-01-08 13:50:17 -05:00
arm946es arm: move exception handling out of start.S files 2014-05-15 16:24:53 +02:00
arm1136 kbuild: use SoC-specific CONFIG to descend into SoC directory 2014-11-23 06:49:02 -05:00
arm1176 kbuild: use SoC-specific CONFIG to descend into SoC directory 2014-11-23 06:49:02 -05:00
armv7 sunxi: Fix buggy sun6i/sun8i DRAM size detection logic 2015-01-14 14:56:37 +01:00
armv8 kbuild: use SoC-specific CONFIG to descend into SoC directory 2014-11-23 06:49:02 -05:00
at91-common arm, spl, at91: add at91sam9260 and at91sam9g45 spl support 2014-11-17 08:47:17 -05:00
pxa arm: move exception handling out of start.S files 2014-05-15 16:24:53 +02:00
sa1100 arm: move exception handling out of start.S files 2014-05-15 16:24:53 +02:00
tegra-common ARM: tegra: Implement XUSB pad controller 2014-12-18 13:19:20 -07:00
tegra20-common ARM: tegra: Provide PCIEXCLK reset ID 2014-12-18 13:19:20 -07:00
tegra30-common ARM: tegra: Provide PCIEXCLK reset ID 2014-12-18 13:19:20 -07:00
tegra114-common ARM: tegra: Tegra114 pinmux cleanup 2014-04-17 08:41:06 -07:00
tegra124-common ARM: tegra: Implement XUSB pad controller 2014-12-18 13:19:20 -07:00
Makefile kbuild: use boolean macros to select tegra*-common directory 2014-04-17 17:44:35 -04:00
u-boot-spl.lds arm: spl: Add I2C linker list in generic .lds 2014-12-11 09:38:35 -08:00
u-boot.lds ARM: HYP/non-sec: add separate section for secure code 2014-07-28 17:07:23 +02:00