Skip to content

Commit 80a4062

Browse files
MrVanShawn Guo
authored andcommitted
firmware: imx: sm-misc: Dump syslog info
Add debugfs interface to read System Manager syslog info Signed-off-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
1 parent 4fa62e8 commit 80a4062

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

drivers/firmware/imx/sm-misc.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
* Copyright 2024 NXP
44
*/
55

6+
#include <linux/debugfs.h>
7+
#include <linux/device/devres.h>
68
#include <linux/firmware/imx/sm.h>
79
#include <linux/module.h>
810
#include <linux/of.h>
911
#include <linux/platform_device.h>
1012
#include <linux/scmi_protocol.h>
1113
#include <linux/scmi_imx_protocol.h>
14+
#include <linux/seq_file.h>
15+
#include <linux/sizes.h>
1216

1317
static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops;
1418
static struct scmi_protocol_handle *ph;
@@ -44,10 +48,38 @@ static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb,
4448
return 0;
4549
}
4650

51+
static int syslog_show(struct seq_file *file, void *priv)
52+
{
53+
/* 4KB is large enough for syslog */
54+
void *syslog __free(kfree) = kmalloc(SZ_4K, GFP_KERNEL);
55+
/* syslog API use num words, not num bytes */
56+
u16 size = SZ_4K / 4;
57+
int ret;
58+
59+
if (!ph)
60+
return -ENODEV;
61+
62+
ret = imx_misc_ctrl_ops->misc_syslog(ph, &size, syslog);
63+
if (ret)
64+
return ret;
65+
66+
seq_hex_dump(file, " ", DUMP_PREFIX_NONE, 16, sizeof(u32), syslog, size * 4, false);
67+
seq_putc(file, '\n');
68+
69+
return 0;
70+
}
71+
DEFINE_SHOW_ATTRIBUTE(syslog);
72+
73+
static void scmi_imx_misc_put(void *p)
74+
{
75+
debugfs_remove((struct dentry *)p);
76+
}
77+
4778
static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
4879
{
4980
const struct scmi_handle *handle = sdev->handle;
5081
struct device_node *np = sdev->dev.of_node;
82+
struct dentry *scmi_imx_dentry;
5183
u32 src_id, flags;
5284
int ret, i, num;
5385

@@ -98,7 +130,10 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
98130
}
99131
}
100132

101-
return 0;
133+
scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL);
134+
debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops);
135+
136+
return devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry);
102137
}
103138

104139
static const struct scmi_device_id scmi_id_table[] = {

0 commit comments

Comments
 (0)