linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: cmd-db: Add debugfs dumping file
@ 2020-03-09 18:57 Stephen Boyd
  2020-04-14 21:50 ` Lina Iyer
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2020-03-09 18:57 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson
  Cc: linux-kernel, linux-arm-msm, Lina Iyer, Maulik Shah

It's useful for kernel devs to understand what resources and data is
stored inside command db. Add a file in debugufs called 'cmd-db' to dump
the memory contents and strings for resources along with their
addresses. E.g.

 Command DB DUMP
 Slave ARC (v16.0)
 -------------------------
 0x00030000: cx.lvl [00 00 10 00 40 00 80 00 c0 00 00 01 80 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]
 0x00030004: cx.tmr
 0x00030010: mx.lvl [00 00 10 00 00 01 80 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]
 0x00030014: mx.tmr

Cc: Lina Iyer <ilina@codeaurora.org>
Cc: Maulik Shah <mkshah@codeaurora.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/soc/qcom/cmd-db.c | 79 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 77 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index f6c3d17b05c7..6c308f92a13c 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -1,12 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */
 
+#include <linux/debugfs.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_platform.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
+#include <linux/seq_file.h>
 #include <linux/types.h>
 
 #include <soc/qcom/cmd-db.h>
@@ -236,6 +237,78 @@ enum cmd_db_hw_type cmd_db_read_slave_id(const char *id)
 }
 EXPORT_SYMBOL(cmd_db_read_slave_id);
 
+#ifdef CONFIG_DEBUG_FS
+static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
+{
+	int i, j;
+	const struct rsc_hdr *rsc;
+	const struct entry_header *ent;
+	const char *name;
+	u16 len, version;
+	u8 major, minor;
+
+	seq_puts(seq, "Command DB DUMP\n");
+
+	for (i = 0; i < MAX_SLV_ID; i++) {
+
+		rsc = &cmd_db_header->header[i];
+		if (!rsc->slv_id)
+			break;
+
+		switch (rsc->slv_id) {
+		case CMD_DB_HW_ARC:
+			name = "ARC";
+			break;
+		case CMD_DB_HW_VRM:
+			name = "VRM";
+			break;
+		case CMD_DB_HW_BCM:
+			name = "BCM";
+			break;
+		default:
+			name = "Unknown";
+			break;
+		}
+
+		version = le16_to_cpu(rsc->version);
+		major = version >> 8;
+		minor = version;
+
+		seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor);
+		seq_puts(seq, "-------------------------\n");
+
+		ent = rsc_to_entry_header(rsc);
+		for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
+			seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
+				   sizeof(ent->id), ent->id);
+
+			len = le16_to_cpu(ent->len);
+			if (len) {
+				seq_printf(seq, " [%*ph]",
+					   len, rsc_offset(rsc, ent));
+			}
+			seq_putc(seq, '\n');
+		}
+	}
+
+	return 0;
+}
+
+static int open_cmd_db_debugfs(struct inode *inode, struct file *file)
+{
+	return single_open(file, cmd_db_debugfs_dump, inode->i_private);
+}
+#endif
+
+static const struct file_operations cmd_db_debugfs_ops = {
+#ifdef CONFIG_DEBUG_FS
+	.open = open_cmd_db_debugfs,
+#endif
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
 static int cmd_db_dev_probe(struct platform_device *pdev)
 {
 	struct reserved_mem *rmem;
@@ -259,12 +332,14 @@ static int cmd_db_dev_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	debugfs_create_file("cmd-db", 0400, NULL, NULL, &cmd_db_debugfs_ops);
+
 	return 0;
 }
 
 static const struct of_device_id cmd_db_match_table[] = {
 	{ .compatible = "qcom,cmd-db" },
-	{ },
+	{ }
 };
 
 static struct platform_driver cmd_db_dev_driver = {

base-commit: 2c523b344dfa65a3738e7039832044aa133c75fb
-- 
Sent by a computer, using git, on the internet


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: Add debugfs dumping file
  2020-03-09 18:57 [PATCH] soc: qcom: cmd-db: Add debugfs dumping file Stephen Boyd
@ 2020-04-14 21:50 ` Lina Iyer
  2020-04-15  6:30   ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Lina Iyer @ 2020-04-14 21:50 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Andy Gross, Bjorn Andersson, linux-kernel, linux-arm-msm, Maulik Shah

On Mon, Mar 09 2020 at 12:57 -0600, Stephen Boyd wrote:
>It's useful for kernel devs to understand what resources and data is
>stored inside command db. Add a file in debugufs called 'cmd-db' to dump
>the memory contents and strings for resources along with their
>addresses. E.g.
>
> Command DB DUMP
> Slave ARC (v16.0)
> -------------------------
> 0x00030000: cx.lvl [00 00 10 00 40 00 80 00 c0 00 00 01 80 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]
> 0x00030004: cx.tmr
> 0x00030010: mx.lvl [00 00 10 00 00 01 80 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]
> 0x00030014: mx.tmr
>
>Cc: Lina Iyer <ilina@codeaurora.org>
>Cc: Maulik Shah <mkshah@codeaurora.org>
>Signed-off-by: Stephen Boyd <swboyd@chromium.org>
>---
> drivers/soc/qcom/cmd-db.c | 79 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 77 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
>index f6c3d17b05c7..6c308f92a13c 100644
>--- a/drivers/soc/qcom/cmd-db.c
>+++ b/drivers/soc/qcom/cmd-db.c
>@@ -1,12 +1,13 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */
>
>+#include <linux/debugfs.h>
> #include <linux/kernel.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
>-#include <linux/of_platform.h>
> #include <linux/of_reserved_mem.h>
> #include <linux/platform_device.h>
>+#include <linux/seq_file.h>
> #include <linux/types.h>
>
> #include <soc/qcom/cmd-db.h>
>@@ -236,6 +237,78 @@ enum cmd_db_hw_type cmd_db_read_slave_id(const char *id)
> }
> EXPORT_SYMBOL(cmd_db_read_slave_id);
>
>+#ifdef CONFIG_DEBUG_FS
>+static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
>+{
>+	int i, j;
>+	const struct rsc_hdr *rsc;
>+	const struct entry_header *ent;
>+	const char *name;
>+	u16 len, version;
>+	u8 major, minor;
>+
>+	seq_puts(seq, "Command DB DUMP\n");
>+
>+	for (i = 0; i < MAX_SLV_ID; i++) {
>+
>+		rsc = &cmd_db_header->header[i];
>+		if (!rsc->slv_id)
>+			break;
>+
>+		switch (rsc->slv_id) {
>+		case CMD_DB_HW_ARC:
>+			name = "ARC";
>+			break;
>+		case CMD_DB_HW_VRM:
>+			name = "VRM";
>+			break;
>+		case CMD_DB_HW_BCM:
>+			name = "BCM";
>+			break;
>+		default:
>+			name = "Unknown";
>+			break;
>+		}
>+
>+		version = le16_to_cpu(rsc->version);
>+		major = version >> 8;
>+		minor = version;
>+
>+		seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor);
>+		seq_puts(seq, "-------------------------\n");
>+
>+		ent = rsc_to_entry_header(rsc);
>+		for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
>+			seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
0x%05x is what we would have for a resource address.
>+				   sizeof(ent->id), ent->id);
>+
>+			len = le16_to_cpu(ent->len);
>+			if (len) {
>+				seq_printf(seq, " [%*ph]",
>+					   len, rsc_offset(rsc, ent));
>+			}
>+			seq_putc(seq, '\n');
>+		}
>+	}
>+
>+	return 0;
>+}
>+
>+static int open_cmd_db_debugfs(struct inode *inode, struct file *file)
>+{
>+	return single_open(file, cmd_db_debugfs_dump, inode->i_private);
>+}
>+#endif
>+
>+static const struct file_operations cmd_db_debugfs_ops = {
>+#ifdef CONFIG_DEBUG_FS
>+	.open = open_cmd_db_debugfs,
>+#endif
>+	.read = seq_read,
>+	.llseek = seq_lseek,
>+	.release = single_release,
>+};
>+
> static int cmd_db_dev_probe(struct platform_device *pdev)
> {
> 	struct reserved_mem *rmem;
>@@ -259,12 +332,14 @@ static int cmd_db_dev_probe(struct platform_device *pdev)
> 		return -EINVAL;
> 	}
>
>+	debugfs_create_file("cmd-db", 0400, NULL, NULL, &cmd_db_debugfs_ops);
>+
> 	return 0;
> }
>
> static const struct of_device_id cmd_db_match_table[] = {
> 	{ .compatible = "qcom,cmd-db" },
>-	{ },
>+	{ }
> };
>
> static struct platform_driver cmd_db_dev_driver = {
>
>base-commit: 2c523b344dfa65a3738e7039832044aa133c75fb
>--
>Sent by a computer, using git, on the internet
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: Add debugfs dumping file
  2020-04-14 21:50 ` Lina Iyer
@ 2020-04-15  6:30   ` Stephen Boyd
  2020-04-15 14:17     ` Lina Iyer
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2020-04-15  6:30 UTC (permalink / raw)
  To: Lina Iyer
  Cc: Andy Gross, Bjorn Andersson, linux-kernel, linux-arm-msm, Maulik Shah

Quoting Lina Iyer (2020-04-14 14:50:15)
> On Mon, Mar 09 2020 at 12:57 -0600, Stephen Boyd wrote:
> >+              seq_puts(seq, "-------------------------\n");
> >+
> >+              ent = rsc_to_entry_header(rsc);
> >+              for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
> >+                      seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
> 0x%05x is what we would have for a resource address.

Sorry I totally missed this because the mail wasn't trimmed at all and
it was really hard to find the one line that wasn't quoted!

5 vs. 8 sounds OK to me. Send a patch? Or I can do it if you prefer.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: Add debugfs dumping file
  2020-04-15  6:30   ` Stephen Boyd
@ 2020-04-15 14:17     ` Lina Iyer
  2020-04-15 19:22       ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Lina Iyer @ 2020-04-15 14:17 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Andy Gross, Bjorn Andersson, linux-kernel, linux-arm-msm, Maulik Shah

On Tue, Apr 14 2020 at 00:30 -0600, Stephen Boyd wrote:
>Quoting Lina Iyer (2020-04-14 14:50:15)
>> On Mon, Mar 09 2020 at 12:57 -0600, Stephen Boyd wrote:
>> >+              seq_puts(seq, "-------------------------\n");
>> >+
>> >+              ent = rsc_to_entry_header(rsc);
>> >+              for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
>> >+                      seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
>> 0x%05x is what we would have for a resource address.
>
>Sorry I totally missed this because the mail wasn't trimmed at all and
>it was really hard to find the one line that wasn't quoted!
>
Sorry, my bad. Somehow didn't notice the quoting has changed.

>5 vs. 8 sounds OK to me. Send a patch? Or I can do it if you prefer.
Apart from the nit, I think the patch looks good. Feel free to add -

Reviewed-by: Lina Iyer <ilina@codeaurora.org>
Tested-by: Lina Iyer <ilina@codeaurora.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: Add debugfs dumping file
  2020-04-15 14:17     ` Lina Iyer
@ 2020-04-15 19:22       ` Stephen Boyd
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2020-04-15 19:22 UTC (permalink / raw)
  To: Lina Iyer
  Cc: Andy Gross, Bjorn Andersson, linux-kernel, linux-arm-msm, Maulik Shah

Quoting Lina Iyer (2020-04-15 07:17:54)
> On Tue, Apr 14 2020 at 00:30 -0600, Stephen Boyd wrote:
> >Quoting Lina Iyer (2020-04-14 14:50:15)
> >> On Mon, Mar 09 2020 at 12:57 -0600, Stephen Boyd wrote:
> >> >+              seq_puts(seq, "-------------------------\n");
> >> >+
> >> >+              ent = rsc_to_entry_header(rsc);
> >> >+              for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
> >> >+                      seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
> >> 0x%05x is what we would have for a resource address.
> >
> >Sorry I totally missed this because the mail wasn't trimmed at all and
> >it was really hard to find the one line that wasn't quoted!
> >
> Sorry, my bad. Somehow didn't notice the quoting has changed.
> 
> >5 vs. 8 sounds OK to me. Send a patch? Or I can do it if you prefer.
> Apart from the nit, I think the patch looks good. Feel free to add -
> 
> Reviewed-by: Lina Iyer <ilina@codeaurora.org>
> Tested-by: Lina Iyer <ilina@codeaurora.org>

Cool thanks. I'll send a patch given that Bjorn has already picked it
into the qcom tree.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-15 19:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 18:57 [PATCH] soc: qcom: cmd-db: Add debugfs dumping file Stephen Boyd
2020-04-14 21:50 ` Lina Iyer
2020-04-15  6:30   ` Stephen Boyd
2020-04-15 14:17     ` Lina Iyer
2020-04-15 19:22       ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).