From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
"Claude Sonnet 4.5" <noreply@anthropic.com>
Subject: [PATCH 1/4] of: fdt: implement of_del_reserve_entry
Date: Wed, 21 Jan 2026 12:36:46 +0100 [thread overview]
Message-ID: <20260121113738.1485637-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2026-01-21 11:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 11:36 Ahmad Fatoum [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260121113738.1485637-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=noreply@anthropic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox