From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 1/6] memory: add support for requesting barebox area as a whole
Date: Fri, 17 May 2024 08:45:06 +0200 [thread overview]
Message-ID: <20240517064511.3307462-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240517064511.3307462-1-a.fatoum@pengutronix.de>
barebox-specific code and data is normally located at the end of
early-known memory. To ensure it's not overwritten, parts of it are
reserved with request_sdram_region at different places.
Gaps in the reservation lead to multiple issues in the past.
So for documentation purposes and to avoid functiosn like
memory_bank_first_find_space finding vacant area where there isn't,
allow architectures call register_barebox_area to do one full
SDRAM request for the area.
Region requests for subsets of this area will be switched in the
follow-up commit to use the new request_barebox_region, which allocates
a subregion if it lies inside a registered barebox area and defers
to request_sdram_region otherwise.
The motivation for this patch is that with the addition of handoff data,
doing separate memory reservation for every accounting structure (cookie
and linked list) in addition to the data could make iomem output a bit
unwieldy, but we really want to avoid anyone else overwriting it.
While at it, we also rename the regions for barebox code and bss to be
more descriptive.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
- new patch
---
common/memory.c | 38 ++++++++++++++++++++++++++++++++++++--
include/memory.h | 6 ++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/common/memory.c b/common/memory.c
index 583843cc34c0..8e68b5e8bb20 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -57,6 +57,40 @@ void mem_malloc_init(void *start, void *end)
mem_malloc_initialized = 1;
}
+static struct resource *barebox_res;
+static resource_size_t barebox_start;
+static resource_size_t barebox_size;
+
+void register_barebox_area(resource_size_t start,
+ resource_size_t size)
+{
+ barebox_start = start,
+ barebox_size = size;
+}
+
+static int mem_register_barebox(void)
+{
+ if (barebox_start && barebox_size)
+ barebox_res = request_sdram_region("barebox", barebox_start,
+ barebox_size);
+ return 0;
+}
+postmem_initcall(mem_register_barebox);
+
+struct resource *request_barebox_region(const char *name,
+ resource_size_t start,
+ resource_size_t size)
+{
+ resource_size_t end = start + size - 1;
+
+ if (barebox_res && barebox_res->start <= start &&
+ end <= barebox_res->end)
+ return __request_region(barebox_res, start, end,
+ name, IORESOURCE_MEM);
+
+ return request_sdram_region(name, start, size);
+}
+
static int mem_malloc_resource(void)
{
#if !defined __SANDBOX__
@@ -69,7 +103,7 @@ static int mem_malloc_resource(void)
request_sdram_region("malloc space",
malloc_start,
malloc_end - malloc_start + 1);
- request_sdram_region("barebox",
+ request_sdram_region("barebox code",
(unsigned long)&_stext,
(unsigned long)&_etext -
(unsigned long)&_stext);
@@ -77,7 +111,7 @@ static int mem_malloc_resource(void)
(unsigned long)&_sdata,
(unsigned long)&_edata -
(unsigned long)&_sdata);
- request_sdram_region("bss",
+ request_sdram_region("barebox bss",
(unsigned long)&__bss_start,
(unsigned long)&__bss_stop -
(unsigned long)&__bss_start);
diff --git a/include/memory.h b/include/memory.h
index d8691972ec9b..571effd3b0d6 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -61,4 +61,10 @@ static inline u64 memory_sdram_size(unsigned int cols,
return (u64)banks * width << (rows + cols);
}
+void register_barebox_area(resource_size_t start, resource_size_t size);
+
+struct resource *request_barebox_region(const char *name,
+ resource_size_t start,
+ resource_size_t size);
+
#endif
--
2.39.2
next prev parent reply other threads:[~2024-05-17 6:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-17 6:45 [PATCH v2 0/6] add PBL handoff-data support Ahmad Fatoum
2024-05-17 6:45 ` Ahmad Fatoum [this message]
2024-05-17 6:45 ` [PATCH v2 2/6] treewide: use request_barebox_region for possible barebox memory regions Ahmad Fatoum
2024-05-17 6:45 ` [PATCH v2 3/6] ARM: cpu: start: register barebox memory area Ahmad Fatoum
2024-05-17 6:45 ` [PATCH v2 4/6] ARM: move blob_is_arm_boarddata() to include Ahmad Fatoum
2024-05-17 6:45 ` [PATCH v2 5/6] add handoff-data support Ahmad Fatoum
2024-05-17 6:45 ` [PATCH v2 6/6] ARM: pass handoff data from PBL to proper Ahmad Fatoum
2024-05-21 7:14 ` [PATCH v2 0/6] add PBL handoff-data support Sascha Hauer
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=20240517064511.3307462-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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