]> git.dujemihanovic.xyz Git - linux.git/commitdiff
nios2: Only use built-in devicetree blob if configured to do so
authorGuenter Roeck <linux@roeck-us.net>
Fri, 22 Mar 2024 06:54:19 +0000 (23:54 -0700)
committerRob Herring <robh@kernel.org>
Wed, 3 Apr 2024 19:35:53 +0000 (14:35 -0500)
Starting with commit 7b937cc243e5 ("of: Create of_root if no dtb provided
by firmware"), attempts to boot nios2 images with an external devicetree
blob result in a crash.

Kernel panic - not syncing: early_init_dt_alloc_memory_arch:
Failed to allocate 72 bytes align=0x40

For nios2, a built-in devicetree blob always overrides devicetree blobs
provided by ROMMON/BIOS. This includes the new dummy devicetree blob.
Result is that the dummy devicetree blob is used even if an external
devicetree blob is provided. Since the dummy devicetree blob does not
include any memory information, memory allocations fail, resulting in
the crash.

To fix the problem, only use the built-in devicetree blob if
CONFIG_NIOS2_DTB_SOURCE_BOOL is enabled.

Fixes: 7b937cc243e5 ("of: Create of_root if no dtb provided by firmware")
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20240322065419.162416-1-linux@roeck-us.net
Signed-off-by: Rob Herring <robh@kernel.org>
arch/nios2/kernel/prom.c

index 8d98af5c7201bb34570d97876d53d663e9068964..9a8393e6b4a85ecdb22691720c6a266eb5d7aa2d 100644 (file)
@@ -21,7 +21,8 @@
 
 void __init early_init_devtree(void *params)
 {
-       __be32 *dtb = (u32 *)__dtb_start;
+       __be32 __maybe_unused *dtb = (u32 *)__dtb_start;
+
 #if defined(CONFIG_NIOS2_DTB_AT_PHYS_ADDR)
        if (be32_to_cpup((__be32 *)CONFIG_NIOS2_DTB_PHYS_ADDR) ==
                 OF_DT_HEADER) {
@@ -30,8 +31,11 @@ void __init early_init_devtree(void *params)
                return;
        }
 #endif
+
+#ifdef CONFIG_NIOS2_DTB_SOURCE_BOOL
        if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
                params = (void *)__dtb_start;
+#endif
 
        early_init_dt_scan(params);
 }