All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lmb: prohibit allocations above ram_top even from same bank
@ 2024-12-02  7:06 Sughosh Ganu
  2024-12-02 11:58 ` Andreas Schwab
  2024-12-07 15:57 ` Tom Rini
  0 siblings, 2 replies; 20+ messages in thread
From: Sughosh Ganu @ 2024-12-02  7:06 UTC (permalink / raw)
  To: u-boot; +Cc: Heinrich Schuchardt, E Shattow, Tom Rini, Sughosh Ganu

There are platforms which set the value of ram_top based on certain
restrictions that the platform might have in accessing memory above
ram_top, even when the memory region is in the same DRAM bank. So,
even though the LMB allocator works as expected, when trying to
allocate memory above ram_top, prohibit this by marking all memory
above ram_top as reserved, even if the said memory region is from the
same bank.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 lib/lmb.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/lmb.c b/lib/lmb.c
index 14b9b8466ff..be168dfb8dc 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -615,6 +615,7 @@ static __maybe_unused void lmb_reserve_common_spl(void)
 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;
@@ -628,6 +629,8 @@ void lmb_add_memory(void)
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		size = bd->bi_dram[i].size;
+		bank_end = bd->bi_dram[i].start + size;
+
 		if (size) {
 			lmb_add(bd->bi_dram[i].start, size);
 
@@ -639,6 +642,9 @@ void lmb_add_memory(void)
 			if (bd->bi_dram[i].start >= ram_top)
 				lmb_reserve_flags(bd->bi_dram[i].start, size,
 						  LMB_NOOVERWRITE);
+			else if (bank_end > ram_top)
+				lmb_reserve_flags(ram_top, bank_end - ram_top,
+						  LMB_NOOVERWRITE);
 		}
 	}
 }
-- 
2.34.1


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

end of thread, other threads:[~2024-12-13 10:09 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02  7:06 [PATCH] lmb: prohibit allocations above ram_top even from same bank Sughosh Ganu
2024-12-02 11:58 ` Andreas Schwab
     [not found]   ` <CANV2PTNmUp013xDT1bqKYcyo=aP4NXtLN_u01pXmdNM417RygQ@mail.gmail.com>
2024-12-02 16:48     ` Sughosh Ganu
2024-12-07 15:57 ` Tom Rini
2024-12-11 16:18   ` Patrice CHOTARD
2024-12-11 16:27     ` Sughosh Ganu
2024-12-11 16:44       ` Patrice CHOTARD
2024-12-11 18:16         ` Sughosh Ganu
2024-12-12  8:23           ` Patrice CHOTARD
2024-12-12 12:33             ` Mark Kettenis
2024-12-12 13:32               ` Sughosh Ganu
2024-12-12 14:38                 ` Mark Kettenis
2024-12-12 14:54                   ` Sughosh Ganu
2024-12-12 23:21                     ` Mark Kettenis
2024-12-12 13:23             ` Sughosh Ganu
2024-12-12 19:18     ` Tom Rini
2024-12-12 19:50       ` Sughosh Ganu
2024-12-13  9:13         ` Patrice CHOTARD
2024-12-13  9:54           ` Sughosh Ganu
2024-12-13 10:06             ` Patrice CHOTARD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.