From: xiaobo <peterwillcn@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH] Revert "spl: Drop bd_info in the data section"
Date: Tue, 20 Apr 2021 22:17:19 +0800 [thread overview]
Message-ID: <20210420141719.45182-1-peterwillcn@gmail.com> (raw)
From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This reverts commit 38d6b7ebdaee3e0e8426ef1b9df88bdce8ae2e75.
struct global_data contains a pointer to the bd_info structure. This
pointer was populated spl_set_bd() to a pre-allocated bd_info in the
".data" section. The referenced commit replaced this mechanism to one
that uses malloc(). That new mechanism is only used if SPL_ALLOC_BD=y.
which very few boards do.
The result is that (struct global_data)->bd is NULL in SPL on most
platforms. This breaks falcon mode, since arch_fixup_fdt() tries to
access (struct global_data)->bd and set the "/memory" node in the
devicetree. The result is that the "/memory" node contains garbage
values, causing linux to panic() as it sets up the page table.
Instead of trying to fix the mess, potentially causing other issues,
revert to the code that worked, while this change is reworked.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
arch/arm/cpu/armv8/fsl-layerscape/spl.c | 5 +----
common/spl/Kconfig | 9 ---------
common/spl/spl.c | 20 ++++++++------------
include/spl.h | 10 +---------
4 files changed, 10 insertions(+), 34 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
index 5b43a2a231..b3f1148f9d 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
@@ -41,9 +41,6 @@ u32 spl_boot_device(void)
#ifdef CONFIG_SPL_BUILD
-/* Define board data structure */
-static struct bd_info bdata __attribute__ ((section(".data")));
-
void spl_board_init(void)
{
#if defined(CONFIG_NXP_ESBC) && defined(CONFIG_FSL_LSCH2)
@@ -89,7 +86,7 @@ void board_init_f(ulong dummy)
get_clocks();
preloader_console_init();
- gd->bd = &bdata;
+ spl_set_bd();
#ifdef CONFIG_SYS_I2C
#ifdef CONFIG_SPL_I2C_SUPPORT
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 0f528f346f..df5468f1ac 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -113,15 +113,6 @@ config SPL_FSL_PBL
Create boot binary having SPL binary in PBI format concatenated with
u-boot binary.
-config SPL_ALLOC_BD
- bool "Allocate memory for bd_info"
- default y if X86 || SANDBOX
- help
- Some boards don't allocate space for this in their board_init_f()
- code. In this case U-Boot can allocate space for gd->bd in the
- standard SPL flow (board_init_r()). Enable this option to support
- this feature.
-
endmenu
config HANDOFF
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 8c4cd933cf..a0a608fd77 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -55,6 +55,9 @@ binman_sym_declare(ulong, spl, image_pos);
binman_sym_declare(ulong, spl, size);
#endif
+/* Define board data structure */
+static struct bd_info bdata __attribute__ ((section(".data")));
+
/*
* Board-specific Platform code can reimplement show_boot_progress () if needed
*/
@@ -490,19 +493,14 @@ static int spl_common_init(bool setup_malloc)
return 0;
}
-int spl_alloc_bd(void)
+void spl_set_bd(void)
{
/*
* NOTE: On some platforms (e.g. x86) bdata may be in flash and not
* writeable.
*/
- if (!gd->bd) {
- gd->bd = malloc(sizeof(*gd->bd));
- if (!gd->bd)
- return -ENOMEM;
- }
-
- return 0;
+ if (!gd->bd)
+ gd->bd = &bdata;
}
int spl_early_init(void)
@@ -652,6 +650,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
+ spl_set_bd();
+
#if defined(CONFIG_SYS_SPL_MALLOC_START)
mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
CONFIG_SYS_SPL_MALLOC_SIZE);
@@ -661,10 +661,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
if (spl_init())
hang();
}
- if (IS_ENABLED(CONFIG_SPL_ALLOC_BD) && spl_alloc_bd()) {
- puts("Cannot alloc bd\n");
- hang();
- }
#if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6)
/*
* timer_init() does not exist on PPC systems. The timer is initialized
diff --git a/include/spl.h b/include/spl.h
index 4f6e0e53f5..cee9a42ddb 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -357,15 +357,7 @@ u32 spl_mmc_boot_mode(const u32 boot_device);
* If not overridden, it is weakly defined in common/spl/spl_mmc.c.
*/
int spl_mmc_boot_partition(const u32 boot_device);
-
-/**
- * spl_alloc_bd() - Allocate space for bd_info
- *
- * This sets up the gd->bd pointer by allocating memory for it
- *
- * @return 0 if OK, -ENOMEM if out of memory
- */
-int spl_alloc_bd(void);
+void spl_set_bd(void);
/**
* spl_set_header_raw_uboot() - Set up a standard SPL image structure
--
2.31.1
next reply other threads:[~2021-04-20 14:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 14:17 xiaobo [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-04-08 16:56 [PATCH] Revert "spl: Drop bd_info in the data section" Alexandru Gagniuc
2021-04-08 23:55 ` Simon Glass
2021-04-09 19:20 ` Alex G.
2021-04-09 20:24 ` Adam Ford
2021-04-09 20:53 ` Tom Rini
2021-04-10 0:29 ` Tim Harvey
2021-04-12 13:25 ` Tom Rini
2021-04-12 13:51 ` Alex G.
2021-04-12 14:40 ` Tom Rini
2021-04-12 15:21 ` Alex G.
2021-04-12 16:26 ` Tom Rini
2021-04-12 17:49 ` Simon Glass
2021-04-12 18:18 ` Tom Rini
2021-04-12 18:26 ` Simon Glass
2021-04-12 18:38 ` Tom Rini
2021-04-12 18:44 ` Simon Glass
2021-04-16 20:40 ` Tim Harvey
2021-04-16 23:16 ` Adam Ford
2021-04-19 2:26 ` Alex G.
2021-04-19 15:32 ` Tom Rini
2021-04-19 17:33 ` Tom Rini
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=20210420141719.45182-1-peterwillcn@gmail.com \
--to=peterwillcn@gmail.com \
--cc=u-boot@lists.denx.de \
/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