mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] of: fdt: implement of_del_reserve_entry
@ 2026-01-21 11:36 Ahmad Fatoum
  2026-01-21 11:36 ` [PATCH 2/4] ARM: sm: fix repeated call to of_add_reserve_entry on every fixup Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-01-21 11:36 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, Claude Sonnet 4.5

OF_MAX_RESERVE_MAP is only 16 and we have instances in the code that add
reserve entries in device tree fixups, which means it can be exhausted
when fixups are applied repeatedly.

Whether it's still apt in 2026 to use reserve entries is a different
discussion, but let's just add a way to delete reserved entries again in
cleanup code.

Co-developed-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/fdt.c | 24 ++++++++++++++++++++++++
 include/of.h     |  1 +
 2 files changed, 25 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index f2f4aa03de2d..ea763cf7a52a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -651,6 +651,30 @@ int of_add_reserve_entry(resource_size_t start, resource_size_t end)
 	return 0;
 }
 
+void of_del_reserve_entry(resource_size_t start, resource_size_t end)
+{
+	int i, index = -1;
+
+	/* Find the entry with matching start and end addresses */
+	for (i = 0; i < of_reserve_map.num_entries; i++) {
+		if (of_reserve_map.start[i] == start && of_reserve_map.end[i] == end) {
+			index = i;
+			break;
+		}
+	}
+
+	if (index < 0)
+		return;
+
+	/* Shift all subsequent entries up to close the gap */
+	for (i = index; i < of_reserve_map.num_entries - 1; i++) {
+		of_reserve_map.start[i] = of_reserve_map.start[i + 1];
+		of_reserve_map.end[i] = of_reserve_map.end[i + 1];
+	}
+
+	of_reserve_map.num_entries--;
+}
+
 struct of_reserve_map *of_get_reserve_map(void)
 {
 	return &of_reserve_map;
diff --git a/include/of.h b/include/of.h
index ef4430c52862..ba8d1e358d41 100644
--- a/include/of.h
+++ b/include/of.h
@@ -77,6 +77,7 @@ struct of_reserve_map {
 };
 
 int of_add_reserve_entry(resource_size_t start, resource_size_t end);
+void of_del_reserve_entry(resource_size_t start, resource_size_t end);
 void of_clean_reserve_map(void);
 void fdt_add_reserve_map(void *fdt);
 void fdt_print_reserve_map(const void *fdt);
-- 
2.47.3




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

end of thread, other threads:[~2026-01-21 11:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21 11:36 [PATCH 1/4] of: fdt: implement of_del_reserve_entry Ahmad Fatoum
2026-01-21 11:36 ` [PATCH 2/4] ARM: sm: fix repeated call to of_add_reserve_entry on every fixup Ahmad Fatoum
2026-01-21 11:36 ` [PATCH 3/4] bootm: delete initrd reserve entry on bootm_boot return Ahmad Fatoum
2026-01-21 11:36 ` [PATCH 4/4] video: stmfb: add screen base only once Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox