* [PATCH master] ARM: i.MX8M: romapi: reserve scratch space
@ 2023-09-05 14:26 Ahmad Fatoum
2023-09-05 14:35 ` Ahmad Fatoum
2023-09-06 14:16 ` Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-09-05 14:26 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We have 32K of RAM at the end of the initial memory, where a
prebootloader can place data for future use. i.MX8M is currently the
only user and currently uses it to save the ROM API log, which is
located in SRAM and is inaccessible by the time barebox proper runs
in EL2. This area was so far not reserved, which can lead to clobbering
it when chainloading barebox. Avoid this by requesting the region.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-imx/romapi.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm/mach-imx/romapi.c b/arch/arm/mach-imx/romapi.c
index 2fd803b0d998..aef0ff0534c9 100644
--- a/arch/arm/mach-imx/romapi.c
+++ b/arch/arm/mach-imx/romapi.c
@@ -10,6 +10,8 @@
#include <mach/imx/xload.h>
#include <asm/barebox-arm.h>
#include <zero_page.h>
+#include <memory.h>
+#include <init.h>
#include <pbl.h>
static int imx8m_bootrom_load(struct rom_api *rom_api, void *adr, size_t size)
@@ -84,6 +86,14 @@ const u32 *imx8m_get_bootrom_log(void)
return NULL;
}
+static int imx8m_reserve_scratch_area(void)
+{
+ return PTR_ERR_OR_ZERO(request_sdram_region("scratch area",
+ (ulong)arm_mem_scratch_get(),
+ sizeof(struct imx_scratch_space)));
+}
+device_initcall(imx8m_reserve_scratch_area);
+
void imx8m_save_bootrom_log(void *dest)
{
const u32 *rom_log;
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH master] ARM: i.MX8M: romapi: reserve scratch space
2023-09-05 14:26 [PATCH master] ARM: i.MX8M: romapi: reserve scratch space Ahmad Fatoum
@ 2023-09-05 14:35 ` Ahmad Fatoum
2023-09-06 14:16 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-09-05 14:35 UTC (permalink / raw)
To: Ahmad Fatoum, barebox
On 05.09.23 16:26, Ahmad Fatoum wrote:
> We have 32K of RAM at the end of the initial memory, where a
> prebootloader can place data for future use. i.MX8M is currently the
> only user and currently uses it to save the ROM API log, which is
> located in SRAM and is inaccessible by the time barebox proper runs
> in EL2. This area was so far not reserved, which can lead to clobbering
> it when chainloading barebox. Avoid this by requesting the region.
Please only apply after <20230905093210.2067770-1-m.felsch@pengutronix.de>,
otherwise a chainloaded barebox on systems with >6G would end up completely
in >4G space, which triggers a bug that will be fixed separately (but is
worked around by Marco's patch above).
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> arch/arm/mach-imx/romapi.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arch/arm/mach-imx/romapi.c b/arch/arm/mach-imx/romapi.c
> index 2fd803b0d998..aef0ff0534c9 100644
> --- a/arch/arm/mach-imx/romapi.c
> +++ b/arch/arm/mach-imx/romapi.c
> @@ -10,6 +10,8 @@
> #include <mach/imx/xload.h>
> #include <asm/barebox-arm.h>
> #include <zero_page.h>
> +#include <memory.h>
> +#include <init.h>
> #include <pbl.h>
>
> static int imx8m_bootrom_load(struct rom_api *rom_api, void *adr, size_t size)
> @@ -84,6 +86,14 @@ const u32 *imx8m_get_bootrom_log(void)
> return NULL;
> }
>
> +static int imx8m_reserve_scratch_area(void)
> +{
> + return PTR_ERR_OR_ZERO(request_sdram_region("scratch area",
> + (ulong)arm_mem_scratch_get(),
> + sizeof(struct imx_scratch_space)));
> +}
> +device_initcall(imx8m_reserve_scratch_area);
> +
> void imx8m_save_bootrom_log(void *dest)
> {
> const u32 *rom_log;
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH master] ARM: i.MX8M: romapi: reserve scratch space
2023-09-05 14:26 [PATCH master] ARM: i.MX8M: romapi: reserve scratch space Ahmad Fatoum
2023-09-05 14:35 ` Ahmad Fatoum
@ 2023-09-06 14:16 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-09-06 14:16 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Tue, Sep 05, 2023 at 04:26:48PM +0200, Ahmad Fatoum wrote:
> We have 32K of RAM at the end of the initial memory, where a
> prebootloader can place data for future use. i.MX8M is currently the
> only user and currently uses it to save the ROM API log, which is
> located in SRAM and is inaccessible by the time barebox proper runs
> in EL2. This area was so far not reserved, which can lead to clobbering
> it when chainloading barebox. Avoid this by requesting the region.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> arch/arm/mach-imx/romapi.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/arch/arm/mach-imx/romapi.c b/arch/arm/mach-imx/romapi.c
> index 2fd803b0d998..aef0ff0534c9 100644
> --- a/arch/arm/mach-imx/romapi.c
> +++ b/arch/arm/mach-imx/romapi.c
> @@ -10,6 +10,8 @@
> #include <mach/imx/xload.h>
> #include <asm/barebox-arm.h>
> #include <zero_page.h>
> +#include <memory.h>
> +#include <init.h>
> #include <pbl.h>
>
> static int imx8m_bootrom_load(struct rom_api *rom_api, void *adr, size_t size)
> @@ -84,6 +86,14 @@ const u32 *imx8m_get_bootrom_log(void)
> return NULL;
> }
>
> +static int imx8m_reserve_scratch_area(void)
> +{
> + return PTR_ERR_OR_ZERO(request_sdram_region("scratch area",
> + (ulong)arm_mem_scratch_get(),
> + sizeof(struct imx_scratch_space)));
> +}
> +device_initcall(imx8m_reserve_scratch_area);
> +
> void imx8m_save_bootrom_log(void *dest)
> {
> const u32 *rom_log;
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-06 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 14:26 [PATCH master] ARM: i.MX8M: romapi: reserve scratch space Ahmad Fatoum
2023-09-05 14:35 ` Ahmad Fatoum
2023-09-06 14:16 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox