* [PATCH v2] nios2: Only use built-in devicetree blob if configured to do so
@ 2024-03-22 6:54 Guenter Roeck
2024-03-27 21:37 ` Rob Herring
2024-04-03 19:36 ` Rob Herring
0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2024-03-22 6:54 UTC (permalink / raw)
To: Dinh Nguyen
Cc: linux-kernel, Guenter Roeck, Frank Rowand, Stephen Boyd, Rob Herring
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>
---
v2: Mark 'dtb' as __maybe_unused
arch/nios2/kernel/prom.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c
index 8d98af5c7201..9a8393e6b4a8 100644
--- a/arch/nios2/kernel/prom.c
+++ b/arch/nios2/kernel/prom.c
@@ -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);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nios2: Only use built-in devicetree blob if configured to do so
2024-03-22 6:54 [PATCH v2] nios2: Only use built-in devicetree blob if configured to do so Guenter Roeck
@ 2024-03-27 21:37 ` Rob Herring
2024-04-03 19:36 ` Rob Herring
1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2024-03-27 21:37 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Dinh Nguyen, linux-kernel, Frank Rowand, Stephen Boyd
On Fri, Mar 22, 2024 at 1:54 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> 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>
> ---
> v2: Mark 'dtb' as __maybe_unused
>
> arch/nios2/kernel/prom.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
I don't love the ifdef, but seems to be the least invasive for 6.9.
Reviewed-by: Rob Herring <robh@kernel.org>
I have a somewhat more invasive change which checks for top-level
compatible existing to decide whether to use the built-in. That's more
risky as it would affect everyone. We're already doing that elsewhere
and found 1 board that didn't have one.
Rob
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nios2: Only use built-in devicetree blob if configured to do so
2024-03-22 6:54 [PATCH v2] nios2: Only use built-in devicetree blob if configured to do so Guenter Roeck
2024-03-27 21:37 ` Rob Herring
@ 2024-04-03 19:36 ` Rob Herring
1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2024-04-03 19:36 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Frank Rowand, Stephen Boyd, linux-kernel, Dinh Nguyen
On Thu, 21 Mar 2024 23:54:19 -0700, Guenter Roeck wrote:
> 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>
> ---
> v2: Mark 'dtb' as __maybe_unused
>
> arch/nios2/kernel/prom.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
As Dinh has not yet picked this up, I applied it, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-03 19:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 6:54 [PATCH v2] nios2: Only use built-in devicetree blob if configured to do so Guenter Roeck
2024-03-27 21:37 ` Rob Herring
2024-04-03 19:36 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).