From: Juergen Borleis <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 13/15] pstore: pass ramoops configuration to kernel via device tree
Date: Fri, 15 Mar 2019 10:14:51 +0100 [thread overview]
Message-ID: <20190315091453.22393-13-jbe@pengutronix.de> (raw)
In-Reply-To: <20190315091453.22393-1-jbe@pengutronix.de>
From: Philipp Zabel <p.zabel@pengutronix.de>
Instead of setting ramoops module parameters on the kernel command line,
add a /reserved-memory/ramoops node to the device tree via of_fixup.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Documentation-added-by: Juergen Borleis <jbe@pengutronix.de>
---
Documentation/filesystems/pstore.rst | 10 ++--
fs/pstore/ram.c | 98 +++++++++++++++++++++++++++++-------
2 files changed, 86 insertions(+), 22 deletions(-)
diff --git a/Documentation/filesystems/pstore.rst b/Documentation/filesystems/pstore.rst
index c128daae9f..00a5a05537 100644
--- a/Documentation/filesystems/pstore.rst
+++ b/Documentation/filesystems/pstore.rst
@@ -42,10 +42,12 @@ written):
To use pstore/RAMOOPS both Barebox and Kernel have to be compiled with pstore
and RAM backend support. The kernel receives the parameters describing the
-layout over the kernel command line. These parameters are automatically
-generated by Barebox. You can change these parameters in Barebox menuconfig. The
-RAMOOPS parameters for the Kernel are stored in the variable
-global.linux.bootargs.ramoops.
+layout via devicetree or - as a fallback - over the kernel command line.
+To ensure both worlds are using the same memory layout, the required
+configuration data for the kernel is generated on-the-fly prior booting a kernel.
+For the devicetree use case Barebox adapts the kernel's devicetree, for the
+kernel command line fallback the variable ``global.linux.bootargs.ramoops`` is
+created and its content used to build the kernel command line.
You can adapt the *pstore* parameters in Barebox menuconfig.
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index fcf6b3087c..3daec0d0d8 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -468,6 +468,66 @@ static int ramoops_parse_dt(struct device_d *dev,
return 0;
}
+static int ramoops_of_fixup(struct device_node *root, void *data)
+{
+ struct ramoops_platform_data *pdata = data;
+ struct device_node *node;
+ u32 reg[2];
+ int ret;
+
+ node = of_get_child_by_name(root, "reserved-memory");
+ if (!node) {
+ pr_info("Adding reserved-memory node\n");
+ node = of_create_node(root, "/reserved-memory");
+ if (!node)
+ return -ENOMEM;
+
+ of_property_write_u32(node, "#address-cells", 1);
+ of_property_write_u32(node, "#size-cells", 1);
+ of_new_property(node, "ranges", NULL, 0);
+ }
+
+ node = of_get_child_by_name(node, "ramoops");
+ if (!node) {
+ pr_info("Adding ramoops node\n");
+ node = of_create_node(root, "/reserved-memory/ramoops");
+ if (!node)
+ return -ENOMEM;
+ }
+
+ ret = of_property_write_string(node, "compatible", "ramoops");
+ if (ret)
+ return ret;
+ reg[0] = pdata->mem_address;
+ reg[1] = pdata->mem_size;
+ ret = of_property_write_u32_array(node, "reg", reg, 2);
+ if (ret)
+ return ret;
+
+ ret = of_property_write_bool(node, "unbuffered", pdata->mem_type);
+ if (ret)
+ return ret;
+ ret = of_property_write_bool(node, "no-dump-oops", !pdata->dump_oops);
+ if (ret)
+ return ret;
+
+#define store_size(name, field) { \
+ ret = of_property_write_u32(node, name, field); \
+ if (ret < 0) \
+ return ret; \
+ }
+
+ store_size("record-size", pdata->record_size);
+ store_size("console-size", pdata->console_size);
+ store_size("ftrace-size", pdata->ftrace_size);
+ store_size("pmsg-size", pdata->pmsg_size);
+ store_size("ecc-size", pdata->ecc_info.ecc_size);
+
+#undef store_size
+
+ return 0;
+}
+
static int ramoops_probe(struct device_d *dev)
{
struct ramoops_platform_data *pdata = dummy_data;
@@ -574,25 +634,27 @@ static int ramoops_probe(struct device_d *dev)
cxt->size, (unsigned long long)cxt->phys_addr,
cxt->ecc_info.ecc_size, cxt->ecc_info.block_size);
- scnprintf(kernelargs, sizeof(kernelargs),
- "ramoops.record_size=0x%x "
- "ramoops.console_size=0x%x "
- "ramoops.ftrace_size=0x%x "
- "ramoops.pmsg_size=0x%x "
- "ramoops.mem_address=0x%llx "
- "ramoops.mem_size=0x%lx "
- "ramoops.ecc=%d",
- cxt->record_size,
- cxt->console_size,
- cxt->ftrace_size,
- cxt->pmsg_size,
- (unsigned long long)cxt->phys_addr,
- mem_size,
- ramoops_ecc);
- globalvar_add_simple("linux.bootargs.ramoops", kernelargs);
-
- if (IS_ENABLED(CONFIG_OFTREE))
+ if (!IS_ENABLED(CONFIG_OFTREE)) {
+ scnprintf(kernelargs, sizeof(kernelargs),
+ "ramoops.record_size=0x%x "
+ "ramoops.console_size=0x%x "
+ "ramoops.ftrace_size=0x%x "
+ "ramoops.pmsg_size=0x%x "
+ "ramoops.mem_address=0x%llx "
+ "ramoops.mem_size=0x%lx "
+ "ramoops.ecc=%d",
+ cxt->record_size,
+ cxt->console_size,
+ cxt->ftrace_size,
+ cxt->pmsg_size,
+ (unsigned long long)cxt->phys_addr,
+ mem_size,
+ ramoops_ecc);
+ globalvar_add_simple("linux.bootargs.ramoops", kernelargs);
+ } else {
of_add_reserve_entry(cxt->phys_addr, cxt->phys_addr + mem_size);
+ of_register_fixup(ramoops_of_fixup, pdata);
+ }
return 0;
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-03-15 9:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-15 9:14 [PATCH 01/15] ramoops: probe from device tree if OFTREE is enabled Juergen Borleis
2019-03-15 9:14 ` [PATCH 02/15] pstore/ram: add Device Tree bindings Juergen Borleis
2019-03-15 9:14 ` [PATCH 03/15] ramoops: use DT reserved-memory bindings Juergen Borleis
2019-03-15 9:14 ` [PATCH 04/15] pstore: Make ramoops_init_przs generic for other prz arrays Juergen Borleis
2019-03-15 9:14 ` [PATCH 05/15] pstore/ram: Do not use stack VLA for parity workspace Juergen Borleis
2019-03-15 9:14 ` [PATCH 06/15] pstore: improve error report for failed setup Juergen Borleis
2019-03-15 9:14 ` [PATCH 07/15] pstore/ram: Clarify resource reservation labels Juergen Borleis
2019-03-15 9:14 ` [PATCH 08/15] pstore: Extract common arguments into structure Juergen Borleis
2019-03-15 9:14 ` [PATCH 09/15] pstore: add console support Juergen Borleis
2019-03-15 9:14 ` [PATCH 10/15] pstore: Switch pstore_mkfile to pass record Juergen Borleis
2019-03-15 9:14 ` [PATCH 11/15] pstore: Replace arguments for read() API Juergen Borleis
2019-03-15 9:14 ` [PATCH 12/15] pstore: Replace arguments for write() API Juergen Borleis
2019-03-15 9:14 ` Juergen Borleis [this message]
2019-03-15 9:14 ` [PATCH 14/15] pstore: ramoops: allow zapping invalid buffers in read-only mode Juergen Borleis
2019-03-15 9:14 ` [PATCH 15/15] pstore/doc: fix layout Juergen Borleis
2019-03-18 8:44 ` [PATCH 01/15] ramoops: probe from device tree if OFTREE is enabled Sascha Hauer
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=20190315091453.22393-13-jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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