U-Boot adds a ramoops reserved-memory node to the OS device tree when
CONFIG_CMD_PSTORE is enabled. Some kernels register the same region
themselves, for example Qualcomm downstream kernels through the
ramoops_memreserve=4M command line parameter; a second ramoops device
in the device tree then makes the kernel hang while populating
platform devices.

Add CONFIG_CMD_PSTORE_FDT, defaulting to y to keep the existing
behaviour, and return early from fdt_fixup_pstore() when it is
disabled. The pstore command remains available to display or save
records.

Signed-off-by: Qing Li <[email protected]>
---
 cmd/Kconfig              |  8 ++++++++
 cmd/pstore.c             |  3 +++
 doc/usage/cmd/pstore.rst | 10 +++++++---
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 049f6397a70..37b72e10491 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2604,6 +2604,14 @@ config CMD_PSTORE
 
 if CMD_PSTORE
 
+config CMD_PSTORE_FDT
+       bool "Add ramoops node to the OS device tree"
+       default y
+       help
+         Add a ramoops reserved-memory node to the OS device tree using the
+         PStore parameters. Disable this if the kernel registers its own
+         ramoops device. The pstore command remains available to read records.
+
 config CMD_PSTORE_MEM_ADDR
        hex "Memory Address"
        depends on CMD_PSTORE
diff --git a/cmd/pstore.c b/cmd/pstore.c
index f2c0034abbe..5d1890fa5e7 100644
--- a/cmd/pstore.c
+++ b/cmd/pstore.c
@@ -491,6 +491,9 @@ void fdt_fixup_pstore(void *blob)
        u32 addr_cells;
        u32 size_cells;
 
+       if (!IS_ENABLED(CONFIG_CMD_PSTORE_FDT))
+               return;
+
        nodeoffset = fdt_path_offset(blob, "/");
        if (nodeoffset < 0) {
                /* Not found or something else bad happened. */
diff --git a/doc/usage/cmd/pstore.rst b/doc/usage/cmd/pstore.rst
index b8e2a478421..bcf912aa89c 100644
--- a/doc/usage/cmd/pstore.rst
+++ b/doc/usage/cmd/pstore.rst
@@ -36,9 +36,13 @@ i.e.::
     ramoops.mem_address=0x30000000 ramoops.mem_size=0x100000 
ramoops.record_size=0x2000 ramoops.console_size=0x2000 
memmap=0x100000$0x30000000
 
 The same values should be set in U-Boot to be able to retrieve the records.
-This values can be set at build time in U-Boot configuration file, or at 
runtime.
-U-Boot automatically patches the Device Tree to pass the Ramoops parameters to
-the kernel.
+These values can be set at build time in the U-Boot configuration file, or at
+runtime. With ``CONFIG_CMD_PSTORE_FDT`` enabled, U-Boot automatically adds a
+ramoops reserved-memory node to the OS Device Tree using these parameters.
+This option defaults to enabled when ``CONFIG_CMD_PSTORE`` is enabled. Disable
+it when the kernel registers its own ramoops device, for example through
+board-specific kernel parameters. The ``pstore`` command remains available to
+read or save records when this option is disabled.
 
 The PStore configuration parameters are:
 
-- 
2.50.1 (Apple Git-155)

Reply via email to