From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4iva-0004sP-5G for barebox@lists.infradead.org; Fri, 15 Mar 2019 09:15:01 +0000 From: Juergen Borleis Date: Fri, 15 Mar 2019 10:14:51 +0100 Message-Id: <20190315091453.22393-13-jbe@pengutronix.de> In-Reply-To: <20190315091453.22393-1-jbe@pengutronix.de> References: <20190315091453.22393-1-jbe@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 13/15] pstore: pass ramoops configuration to kernel via device tree To: barebox@lists.infradead.org From: Philipp Zabel 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 Documentation-added-by: Juergen Borleis --- 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