lkml.org 
[lkml]   [2023]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 6/6] pstore/ram: Register context with minidump
Date
There are system which does not uses pstore directly but
may have the interest in the context saved by pstore.
Register pstore regions with minidump so that it get
dumped on minidump collection.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
fs/pstore/ram.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index ade66db..038da1a 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -20,6 +20,7 @@
#include <linux/compiler.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <soc/qcom/minidump.h>

#include "internal.h"
#include "ram_internal.h"
@@ -714,6 +715,74 @@ static int ramoops_parse_dt(struct platform_device *pdev,
return 0;
}

+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
+static int ramoops_qcom_minidump_register(struct ramoops_context *cxt)
+{
+ struct qcom_minidump_region pstore_entry;
+ struct persistent_ram_zone *prz;
+ int ret = 0;
+ int i;
+
+ for (i = 0; i < cxt->max_dump_cnt; i++) {
+ prz = cxt->dprzs[i];
+ scnprintf(pstore_entry.name, sizeof(pstore_entry.name),
+ "KDMESG%d", i);
+ pstore_entry.virt_addr = prz->vaddr;
+ pstore_entry.phys_addr = prz->paddr;
+ pstore_entry.size = prz->size;
+ ret = qcom_minidump_region_register(&pstore_entry);
+ if (ret < 0) {
+ pr_err("failed to add dmesg in minidump: err: %d\n", ret);
+ return ret;
+ }
+ }
+
+ if (cxt->console_size) {
+ prz = cxt->cprz;
+ strlcpy(pstore_entry.name, "KCONSOLE", sizeof(pstore_entry.name));
+ pstore_entry.virt_addr = prz->vaddr;
+ pstore_entry.phys_addr = prz->paddr;
+ pstore_entry.size = prz->size;
+ ret = qcom_minidump_region_register(&pstore_entry);
+ if (ret < 0) {
+ pr_err("failed to add console in minidump: err: %d\n", ret);
+ return ret;
+ }
+ }
+
+ for (i = 0; i < cxt->max_ftrace_cnt; i++) {
+ prz = cxt->fprzs[i];
+ scnprintf(pstore_entry.name, sizeof(pstore_entry.name),
+ "KFTRACE%d", i);
+ pstore_entry.virt_addr = prz->vaddr;
+ pstore_entry.phys_addr = prz->paddr;
+ pstore_entry.size = prz->size;
+ ret = qcom_minidump_region_register(&pstore_entry);
+ if (ret < 0) {
+ pr_err("failed to add ftrace in minidump: err: %d\n", ret);
+ return ret;
+ }
+ }
+
+ if (cxt->pmsg_size) {
+ prz = cxt->mprz;
+ strlcpy(pstore_entry.name, "KPMSG", sizeof(pstore_entry.name));
+ pstore_entry.virt_addr = prz->vaddr;
+ pstore_entry.phys_addr = prz->paddr;
+ pstore_entry.size = prz->size;
+ ret = qcom_minidump_region_register(&pstore_entry);
+ if (ret < 0) {
+ pr_err("failed to add pmsg in minidump: err: %d\n", ret);
+ return ret;
+ }
+ }
+
+ return ret;
+}
+#else
+static int ramoops_qcom_minidump_register(struct ramoops_context *cxt) { return 0; }
+#endif
+
static int ramoops_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -724,6 +793,10 @@ static int ramoops_probe(struct platform_device *pdev)
phys_addr_t paddr;
int err = -EINVAL;

+ err = qcom_minidump_ready();
+ if (err && err != -ENODEV)
+ return -EPROBE_DEFER;
+
/*
* Only a single ramoops area allowed at a time, so fail extra
* probes.
@@ -841,6 +914,10 @@ static int ramoops_probe(struct platform_device *pdev)
}
}

+ err = ramoops_qcom_minidump_register(cxt);
+ if (err < 0)
+ goto fail_buf;
+
err = pstore_register(&cxt->pstore);
if (err) {
pr_err("registering with pstore failed\n");
--
2.7.4
\
 
 \ /
  Last update: 2023-03-27 00:29    [W:0.155 / U:1.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site