summaryrefslogtreecommitdiff
path: root/lib/lmb.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lmb.c')
-rw-r--r--lib/lmb.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/lmb.c b/lib/lmb.c
index 8f12c6ad8e5..a2aeb526e29 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -611,6 +611,7 @@ static __maybe_unused void lmb_reserve_common_spl(void)
static void lmb_add_memory(void)
{
int i;
+ phys_addr_t bank_end;
phys_size_t size;
u64 ram_top = gd->ram_top;
struct bd_info *bd = gd->bd;
@@ -625,8 +626,25 @@ static void lmb_add_memory(void)
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
size = bd->bi_dram[i].size;
- if (size)
+ if (size) {
lmb_add(bd->bi_dram[i].start, size);
+ if (!IS_ENABLED(CONFIG_LMB_LIMIT_DMA_BELOW_4G))
+ continue;
+
+ bank_end = bd->bi_dram[i].start + size;
+
+ /*
+ * Reserve memory above ram_top as
+ * no-overwrite so that it cannot be
+ * allocated
+ */
+ if (bd->bi_dram[i].start >= ram_top)
+ lmb_reserve(bd->bi_dram[i].start, size,
+ LMB_NOOVERWRITE);
+ else if (bank_end > ram_top)
+ lmb_reserve(ram_top, bank_end - ram_top,
+ LMB_NOOVERWRITE);
+ }
}
}