summaryrefslogtreecommitdiff
path: root/common/memsize.c
AgeCommit message (Collapse)Author
2023-07-11common/memsize.c: Fix get_ram_size() when cache is enabledEmanuele Ghidoli
Ensure that every write is flushed to memory and afterward reads are from memory. Since the algorithm rely on the fact that accessing to not existent memory lead to write at addr / 2 without this modification accesses to aliased (not physically present) addresses are cached and wrong size is returned. This was discovered while working on a TI AM625 based board where cache is normally enabled, see commit c02712a74849 ("arm: mach-k3: Enable dcache in SPL"). Upstream-Status: Submitted [https://lore.kernel.org/all/20230530133327.178278-1-francesco@dolcini.it] Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
2023-01-09Merge branch 'next'Tom Rini
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-01-07common/memsize.c: Check for overflow in get_effective_memsize() only for mpc85xxPali Rohár
This reverts commit 777aaaa706bc ("common/memsize.c: Fix get_effective_memsize() to check for overflow") for non-mpc85xx platforms. The changes to this generic function, which is intended to help with 32bit platforms with large amounts of memory has unintended side effects (which in turn lead to boot failures) on other platforms which were previously functional. For now do overflow check only for powerpc mpc85xx platform. It is needed to prevent crashing of P1/P2 boards with 4GB DDR module in 32-bit mode. Fixes: 777aaaa706bc ("common/memsize.c: Fix get_effective_memsize() to check for overflow") Signed-off-by: Pali Rohár <pali@kernel.org>
2022-12-23global: Migrate CONFIG_MAX_MEM_MAPPED to CFGTom Rini
Perform a simple rename of CONFIG_MAX_MEM_MAPPED to CFG_MAX_MEM_MAPPED Signed-off-by: Tom Rini <trini@konsulko.com>
2022-09-23common/memsize.c: Fix get_effective_memsize() to check for overflowPali Rohár
Ensure that top of RAM can be represented by phys_size_t type. If RAM is too large or RAM base address is too upper then limit RAM size to prevent address space overflow. Signed-off-by: Pali Rohár <pali@kernel.org>
2022-09-23common/memsize.c: Fix get_effective_memsize() to always check for ↵Pali Rohár
CONFIG_MAX_MEM_MAPPED CONFIG_MAX_MEM_MAPPED when defined specifies upper memory mapped limit. So check for it always, and not only when CONFIG_VERY_BIG_RAM is defined. Signed-off-by: Pali Rohár <pali@kernel.org>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2020-01-17common: Move RAM-sizing functions to init.hSimon Glass
These functions relate to memory init so move them into the init header. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-10common/memsize.c: Increase save array for supporting memory size > 4GBTien Fong Chee
In ARM 64-bits, memory size can be supported is more than 4GB, hence increasing save array is needed to cope with testing larger memory. Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-03-13common/memsize.c: restore content of the base addressPatrick Delaunay
For the last return of function get_ram_size(), when size=maxsize, restore the base address (*base) content. Add comment for the remaining case to avoid regression: this case is already correctly handled. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2018-03-13common/memsize.c: prepare get_ram_size updatePatrick Delaunay
Save the content of the base address in a new variable in stack (save_base) to prepare restore this content. This patch don't modified code behavior and stack usage. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2016-02-10Revert "common/memsize.c: Simplify RAM size detection"Hans de Goede
This commit breaks bootup on sunxi boards, the get stuck when running the main u-boot binary at: CPU: Allwinner H3 (SUN8I) I2C: ready DRAM: This reverts commit 8e7cba048baae68ee0916a8f52b4304277328d5e. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-02-08common/memsize.c: Simplify RAM size detectionEddy Petrișor
The case of memory of size 0 is not that different from a memory of any other size, so we remove the duplicate code and treat the small differences when it is the case. Signed-off-by: Eddy Petrișor <eddy.petrisor@gmail.com>
2015-01-14common/memsize.c: Coding style cleanupWolfgang Denk
Prepare code to make later modifications checkpatch-clean. Signed-off-by: Wolfgang Denk <wd@denx.de>
2014-02-21common: Add get_effective_memsize() to memsize.cYork Sun
This function has been around for powerpc. It is used for systems with memory more than CONFIG_MAX_MEM_MAPPED. In case of non-contiguous memory, this feature can limit U-boot to one block without going over the limit. Signed-off-by: York Sun <yorksun@freescale.com> Acked-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
2013-07-24Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
2012-09-21Revert "memsize: Fix for bug in memory sizing code"Tom Rini
After further investigation this change is not correct and results in get_ram_size returning incorrectly large values. Reported first by Gerlando Falauto. This reverts commit b8496cced856ff411f1eb2e4eff20f5abe7080b0. Signed-off-by: Tom Rini <trini@ti.com>
2012-09-18memsize: Fix for bug in memory sizing codeIwo Mergler
The original memory sizing code in get_ram_size clobbers the word at the base address, but forgets to restore it. Signed-off-by: Iwo Mergler <Iwo.Mergler@netcommwireless.com>
2011-07-17Remove volatile qualifier in get_ram_size() callsAlbert ARIBAUD
Checkpatch.pl complains about the volatile qualifier in calls to get_ram_size(). Remove this qualifier in the prototype and in the calls where it is useless, and leave it only in the function body where it is needed. Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
2006-11-06Sequential accesses to non-existent memory must be synchronized,Wolfgang Denk
at least on G2 cores. This fixes get_ram_size() problems on MPC5200 Rev. B boards.
2004-01-06Add a common get_ram_size() function and modify the thewdenk
board-specific files to invoke that common implementation.