]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Revert "spl: Drop bd_info in the data section"
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Thu, 8 Apr 2021 16:56:11 +0000 (11:56 -0500)
committerTom Rini <trini@konsulko.com>
Mon, 19 Apr 2021 15:34:01 +0000 (11:34 -0400)
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
common/spl/Kconfig
common/spl/spl.c
include/spl.h

index 5b43a2a23168df19fac6340304794d362d8f1b7c..b3f1148f9dfd6df1ced6e0c42f1a111d6037d6a2 100644 (file)
@@ -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
index 0f528f346f35b8afb55f8ba2a323006138c211c3..df5468f1ac291932f004ef0987404e7d5008b712 100644 (file)
@@ -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
index 8c4cd933cf5180c50e077de1725bb53fdfba07ea..a0a608fd7725bd9e248bb228d53bc5696f93b042 100644 (file)
@@ -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
index 4f6e0e53f5d4f67a18c94e276162ca3c5c7a4faf..cee9a42ddb5e5dbda1ebe64b677e85671969a98a 100644 (file)
@@ -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