Re: [PATCH v3 12/18] soc: qcom: Register pstore frontend region with minidump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



FYI the following comments also apply to the downstream driver, as the same bogus logic is implemented.

On 03/05/23 19:02, Mukesh Ojha wrote:

Since qcom_pstore_minidump driver creates platform device
for qualcomm devices, so it knows the physical addresses
of the frontend region now. Let's register the regions
with qcom_minidump driver.

Signed-off-by: Mukesh Ojha <quic_mojha@xxxxxxxxxxx>
---
  drivers/soc/qcom/qcom_pstore_minidump.c | 80 ++++++++++++++++++++++++++++++++-
  1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
index 8d58500..c2bba4e 100644
--- a/drivers/soc/qcom/qcom_pstore_minidump.c
+++ b/drivers/soc/qcom/qcom_pstore_minidump.c
@@ -11,6 +11,8 @@
  #include <linux/pstore_ram.h>
  #include <soc/qcom/qcom_minidump.h>
+#define QCOM_PSTORE_TYPE_MAX 4
Unused
+
  struct qcom_ramoops_config {
  	unsigned long	record_size;
  	unsigned long	console_size;
@@ -24,6 +26,11 @@ struct qcom_ramoops_config {
  struct qcom_ramoops_dd {
  	struct ramoops_platform_data qcom_ramoops_pdata;
  	struct platform_device *ramoops_pdev;
+	struct device *dev;
+	struct qcom_apss_minidump_region *record_region;

In the pstore driver record_size is used to split the KDMESG region into different chunks.

There's no "record" region anywhere in RAM that should be preserved, it should instead be the dmesg_region.

+	struct qcom_apss_minidump_region *console_region;
+	struct qcom_apss_minidump_region *pmsg_region;
+	struct qcom_apss_minidump_region *ftrace_region;
  };
static struct qcom_ramoops_config default_ramoops_config = {
@@ -35,6 +42,64 @@ static struct qcom_ramoops_config default_ramoops_config = {
  };
static struct qcom_ramoops_dd *qcom_rdd;
+
+static int
+__qcom_ramoops_minidump_region_register(struct qcom_apss_minidump_region *md_region,
+					const char *name, phys_addr_t phys_addr,
+					unsigned long size)
+{
+	int ret;
+
+	if (!size)
+		return 0;
+
+	md_region = devm_kzalloc(qcom_rdd->dev, sizeof(*md_region), GFP_KERNEL);
+	if (!md_region)
+		return -ENOMEM;
+
+	strlcpy(md_region->name, name, sizeof(md_region->name));
+	md_region->phys_addr = phys_addr;
+	md_region->virt_addr = phys_to_virt(phys_addr);
+	md_region->size = size;
+	ret = qcom_apss_minidump_region_register(md_region);
+	if (ret)
+		dev_err(qcom_rdd->dev,
+			"failed to add %s in minidump: err: %d\n", name, ret);
+
+	return ret;
+}
+
+static int
+qcom_ramoops_minidump_region_register(struct ramoops_platform_data *qcom_ramoops_data)
+{
+	phys_addr_t phys_addr;
+	int ret = 0;
+
+	phys_addr = qcom_ramoops_data->mem_address;
+	ret = __qcom_ramoops_minidump_region_register(qcom_rdd->record_region,
+			"KDMESG", phys_addr, qcom_ramoops_data->record_size);

You can't use record_size here as it's not the actual size of the dmesg region.

The size is calculated in fs/pstore/ram.c as mem_size - console_size - ftrace_size - pmsg_size, where mem_size is the size on the ramoops memory region in the devicetree.

Since the actual size is never exposed by the pstore driver you have to re-purpose the same logic in this driver, hoping it never changes.

+	if (ret)
+		return ret;
+
+	phys_addr += qcom_ramoops_data->record_size;
+	ret = __qcom_ramoops_minidump_region_register(qcom_rdd->console_region,
+			"KCONSOLE", phys_addr, qcom_ramoops_data->console_size);
+	if (ret)
+		return ret;
+
+	phys_addr += qcom_ramoops_data->console_size;
+	ret = __qcom_ramoops_minidump_region_register(qcom_rdd->pmsg_region,
+			"KPMSG", phys_addr, qcom_ramoops_data->pmsg_size);
+	if (ret)
+		return ret;
+
+	phys_addr += qcom_ramoops_data->pmsg_size;
+	ret = __qcom_ramoops_minidump_region_register(qcom_rdd->ftrace_region,
+			"KFTRACE", phys_addr, qcom_ramoops_data->ftrace_size);
+
+	return ret;
+}
+
  static int qcom_ramoops_probe(struct platform_device *pdev)
  {
  	struct device_node *of_node = pdev->dev.of_node;
@@ -59,6 +124,7 @@ static int qcom_ramoops_probe(struct platform_device *pdev)
  	if (!qcom_rdd)
  		return -ENOMEM;
+ qcom_rdd->dev = &pdev->dev;
  	cfg = of_device_get_match_data(&pdev->dev);
  	if (!cfg) {
  		dev_err(&pdev->dev, "failed to get supported matched data\n");
@@ -81,13 +147,25 @@ static int qcom_ramoops_probe(struct platform_device *pdev)
  		ret = PTR_ERR(qcom_rdd->ramoops_pdev);
  		dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
  		qcom_rdd->ramoops_pdev = NULL;
+		return ret;
  	}
- return ret;
+	return qcom_ramoops_minidump_region_register(pdata);
  }
static int qcom_ramoops_remove(struct platform_device *pdev)
  {
+	struct ramoops_platform_data *pdata;
+
+	pdata = &qcom_rdd->qcom_ramoops_pdata;
+	if (pdata->record_size)
+		qcom_apss_minidump_region_unregister(qcom_rdd->record_region);
+	if (pdata->console_size)
+		qcom_apss_minidump_region_unregister(qcom_rdd->console_region);
+	if (pdata->pmsg_size)
+		qcom_apss_minidump_region_unregister(qcom_rdd->pmsg_region);
+	if (pdata->ftrace_size)
+		qcom_apss_minidump_region_unregister(qcom_rdd->ftrace_region);
  	platform_device_unregister(qcom_rdd->ramoops_pdev);
  	qcom_rdd->ramoops_pdev = NULL;

Regards,

Luca Stefani




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux