Skip to contentSkip to conversation

firmware: arm_scmi/imx: Support dump syslog

PATCH Applied Peng Fan 4 participants 10 messages Oct 29, 2025 – Jan 17

Subsystems (3)
lore
Share & tools
lore

Peng Fan

author maintainer
#0 lore raw

v3 cover firmware: arm_scmi/imx: Support dump syslog

This is the patch 5 and 6 from patchset [1] with switching to using raw dump, per check with Sudeep and NXP i.MX SM firmware owner

System Manager firmware provides API to dump system log information. So add the interface for Linux to retrieve the information.

In patch 1, I drop the two structures compared to patch 5 in [1]:
struct scmi_imx_misc_sys_sleep_rec
struct scmi_imx_misc_syslog
No other changes in this patch.

In patch 2, I switched to use debugfs to do raw dump the syslog, compared with patch 6 in [1].

[1] https://lore.kernel.org/arm-scmi/PAXPR04MB845937237E3C1AF5A2ABA8FA880CA@PAXPR04MB8459.eurprd04.prod.outlook.com/T/#m6ed303ac9c584c6e2ab39f89359f3131b
dfcc9e5

---
Changes in v3:
- Rebased to next-20251028
- Drop unused variable to avoid build warning reported by kernel test robot
- Link to v2: https://lore.kernel.org/arm-scmi/[email protected]/

Changes in v2:
- Rebased to next-20251010
- Patch 2: Remove the IS_ERR check for debugfs_create_dir per Dan Carpenter Change 'return 0' to 'return devm_add_action_or_reset'
Drop the size check
Include 'linux/sizes.h' to avoid build break
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Peng Fan (2):
firmware: arm_scmi: imx: Support getting syslog of MISC protocol
firmware: imx: sm-misc: Dump syslog info

 .../firmware/arm_scmi/vendors/imx/imx-sm-misc.c    | 83 ++++++++++++++++++++++
 drivers/firmware/imx/sm-misc.c                     | 37 +++++++++-
 include/linux/scmi_imx_protocol.h                  |  2 +
 3 files changed, 121 insertions(+), 1 deletion(-)

---
base-commit: f7d2388eeec24966fc4d5cf32d706f0514f29ac5
change-id: 20251029-sm-syslog-v3-0143f85b0ce6

Best regards,

Signature · 1 line
Peng Fan <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/2 firmware: arm_scmi: imx: Support getting syslog of MISC protocol

MISC protocol supports getting system log regarding system sleep latency, wakeup interrupt and etc. Add the API for user to retrieve the information from SM.

---
 .../firmware/arm_scmi/vendors/imx/imx-sm-misc.c    | 83 ++++++++++++++++++++++
 include/linux/scmi_imx_protocol.h                  |  2 +
 2 files changed, 85 insertions(+)
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c +83 -0
index 700a3f24f4efc153ca4a9ef1a9e50a7ece492a18..eae0b0562f6cf1931be612852ba2651f60820e6d 100644
@@ -28,6 +28,7 @@ enum scmi_imx_misc_protocol_cmd {
 	SCMI_IMX_MISC_DISCOVER_BUILD_INFO = 0x6,
 	SCMI_IMX_MISC_CTRL_NOTIFY = 0x8,
 	SCMI_IMX_MISC_CFG_INFO_GET = 0xC,
+	SCMI_IMX_MISC_SYSLOG_GET = 0xD,
 	SCMI_IMX_MISC_BOARD_INFO = 0xE,
 };
 
@@ -89,6 +90,19 @@ struct scmi_imx_misc_cfg_info_out {
 	u8 cfgname[MISC_MAX_CFGNAME];
 };
 
+struct scmi_imx_misc_syslog_in {
+	__le32 flags;
+	__le32 index;
+};
+
+#define REMAINING(x)	le32_get_bits((x), GENMASK(31, 20))
+#define RETURNED(x)	le32_get_bits((x), GENMASK(11, 0))
+
+struct scmi_imx_misc_syslog_out {
+	__le32 numlogflags;
+	__le32 syslog[];
+};
+
 static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph,
 					struct scmi_imx_misc_info *mi)
 {
@@ -371,10 +385,79 @@ static int scmi_imx_misc_cfg_info_get(const struct scmi_protocol_handle *ph)
 	return ret;
 }
 
+struct scmi_imx_misc_syslog_ipriv {
+	u32 *array;
+	u16 *size;
+};
+
+static void iter_misc_syslog_prepare_message(void *message, u32 desc_index,
+					     const void *priv)
+{
+	struct scmi_imx_misc_syslog_in *msg = message;
+
+	msg->flags = cpu_to_le32(0);
+	msg->index = cpu_to_le32(desc_index);
+}
+
+static int iter_misc_syslog_update_state(struct scmi_iterator_state *st,
+					 const void *response, void *priv)
+{
+	const struct scmi_imx_misc_syslog_out *r = response;
+	struct scmi_imx_misc_syslog_ipriv *p = priv;
+
+	st->num_returned = RETURNED(r->numlogflags);
+	st->num_remaining = REMAINING(r->numlogflags);
+	*p->size = st->num_returned + st->num_remaining;
+
+	return 0;
+}
+
+static int
+iter_misc_syslog_process_response(const struct scmi_protocol_handle *ph,
+				  const void *response,
+				  struct scmi_iterator_state *st, void *priv)
+{
+	const struct scmi_imx_misc_syslog_out *r = response;
+	struct scmi_imx_misc_syslog_ipriv *p = priv;
+
+	p->array[st->desc_index + st->loop_idx] =
+		le32_to_cpu(r->syslog[st->loop_idx]);
+
+	return 0;
+}
+
+static int scmi_imx_misc_syslog_get(const struct scmi_protocol_handle *ph, u16 *size,
+				    void *array)
+{
+	struct scmi_iterator_ops ops = {
+		.prepare_message = iter_misc_syslog_prepare_message,
+		.update_state = iter_misc_syslog_update_state,
+		.process_response = iter_misc_syslog_process_response,
+	};
+	struct scmi_imx_misc_syslog_ipriv ipriv = {
+		.array = array,
+		.size = size,
+	};
+	void *iter;
+
+	if (!array || !size || !*size)
+		return -EINVAL;
+
+	iter = ph->hops->iter_response_init(ph, &ops, *size, SCMI_IMX_MISC_SYSLOG_GET,
+					    sizeof(struct scmi_imx_misc_syslog_in),
+					    &ipriv);
+	if (IS_ERR(iter))
+		return PTR_ERR(iter);
+
+	/* If firmware return NOT SUPPORTED, propagate value to caller */
+	return ph->hops->iter_response_run(iter);
+}
+
 static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = {
 	.misc_ctrl_set = scmi_imx_misc_ctrl_set,
 	.misc_ctrl_get = scmi_imx_misc_ctrl_get,
 	.misc_ctrl_req_notify = scmi_imx_misc_ctrl_notify,
+	.misc_syslog = scmi_imx_misc_syslog_get,
 };
 
 static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph)
include/linux/scmi_imx_protocol.h +2 -0
index 27bd372cbfb142b6acb0b1cf4b82f061529d0d45..2407d7693b6ba1303e07629e45e2a7eaaa906fd3 100644
@@ -59,6 +59,8 @@ struct scmi_imx_misc_proto_ops {
 			     u32 *num, u32 *val);
 	int (*misc_ctrl_req_notify)(const struct scmi_protocol_handle *ph,
 				    u32 ctrl_id, u32 evt_id, u32 flags);
+	int (*misc_syslog)(const struct scmi_protocol_handle *ph, u16 *size,
+			   void *array);
 };
 
 /* See LMM_ATTRIBUTES in imx95.rst */
Signature · 1 line
2.37.1
Acked-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] firmware: arm_scmi: imx: Support getting syslog of MISC protocol

Quoted 4 lines · Peng Fan

MISC protocol supports getting system log regarding system sleep latency, wakeup interrupt and etc. Add the API for user to retrieve the information from SM.

This LGTM, so

Let me know if i.MX maintainers prefer to pick up both the patches or they want me to do that.

Also it would be good to get Cristian's review especially the iterator is being used and he may spot something that I may be missing.

Signature · 2 lines
Regards,
Sudeep
author maintainer
#3 lore raw

PATCH v3 2/2 firmware: imx: sm-misc: Dump syslog info

In reply to Peng Fan

Add debugfs interface to read System Manager syslog info

---
 drivers/firmware/imx/sm-misc.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/firmware/imx/sm-misc.c +36 -1
index fc3ee12c2be878e0285183e3381c9514a63d5142..0a8ada329c9de3c1627da241bf142fa91a8085d7 100644
@@ -3,12 +3,16 @@
  * Copyright 2024 NXP
  */
 
+#include <linux/debugfs.h>
+#include <linux/device/devres.h>
 #include <linux/firmware/imx/sm.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/scmi_protocol.h>
 #include <linux/scmi_imx_protocol.h>
+#include <linux/seq_file.h>
+#include <linux/sizes.h>
 
 static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops;
 static struct scmi_protocol_handle *ph;
@@ -44,10 +48,38 @@ static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb,
 	return 0;
 }
 
+static int syslog_show(struct seq_file *file, void *priv)
+{
+	/* 4KB is large enough for syslog */
+	void *syslog __free(kfree) = kmalloc(SZ_4K, GFP_KERNEL);
+	/* syslog API use num words, not num bytes */
+	u16 size = SZ_4K / 4;
+	int ret;
+
+	if (!ph)
+		return -ENODEV;
+
+	ret = imx_misc_ctrl_ops->misc_syslog(ph, &size, syslog);
+	if (ret)
+		return ret;
+
+	seq_hex_dump(file, " ", DUMP_PREFIX_NONE, 16, sizeof(u32), syslog, size * 4, false);
+	seq_putc(file, '\n');
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(syslog);
+
+static void scmi_imx_misc_put(void *p)
+{
+	debugfs_remove((struct dentry *)p);
+}
+
 static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
 {
 	const struct scmi_handle *handle = sdev->handle;
 	struct device_node *np = sdev->dev.of_node;
+	struct dentry *scmi_imx_dentry;
 	u32 src_id, flags;
 	int ret, i, num;
 
@@ -98,7 +130,10 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
 		}
 	}
 
-	return 0;
+	scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL);
+	debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops);
+
+	return devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry);
 }
 
 static const struct scmi_device_id scmi_id_table[] = {
Signature · 1 line
2.37.1
#4 lore raw
In reply to Peng Fan

Hi Sudeep, Cristian

Just checking in - did you get a chance to review this patchset? Please let me know if you need any additional details or context.

Thanks,
Peng

Quoted 49 lines · Peng Fan

This is the patch 5 and 6 from patchset [1] with switching to using raw dump, per check with Sudeep and NXP i.MX SM firmware owner

System Manager firmware provides API to dump system log information. So add the interface for Linux to retrieve the information.

In patch 1, I drop the two structures compared to patch 5 in [1]:
struct scmi_imx_misc_sys_sleep_rec
struct scmi_imx_misc_syslog
No other changes in this patch.

In patch 2, I switched to use debugfs to do raw dump the syslog, compared with patch 6 in [1].

[1] https://lore.kernel.org/arm-scmi/PAXPR04MB845937237E3C1AF5A2ABA8FA880CA@PAXPR04MB8459.eurprd04.prod.outlook.com/T/#m6ed303ac9c584c6e2ab39f89359f3131b
dfcc9e5

---
Changes in v3:
- Rebased to next-20251028
- Drop unused variable to avoid build warning reported by kernel test robot
- Link to v2: https://lore.kernel.org/arm-scmi/[email protected]/

Changes in v2:
- Rebased to next-20251010
- Patch 2: Remove the IS_ERR check for debugfs_create_dir per Dan Carpenter Change 'return 0' to 'return devm_add_action_or_reset'
Drop the size check
Include 'linux/sizes.h' to avoid build break
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Peng Fan (2):
firmware: arm_scmi: imx: Support getting syslog of MISC protocol
firmware: imx: sm-misc: Dump syslog info

.../firmware/arm_scmi/vendors/imx/imx-sm-misc.c    | 83 ++++++++++++++++++++++
drivers/firmware/imx/sm-misc.c                     | 37 +++++++++-
include/linux/scmi_imx_protocol.h                  |  2 +
3 files changed, 121 insertions(+), 1 deletion(-)

---
base-commit: f7d2388eeec24966fc4d5cf32d706f0514f29ac5
change-id: 20251029-sm-syslog-v3-0143f85b0ce6

Best regards,

Signature · 1 line
Peng Fan <[email protected]>
#5 lore raw

Hi Sudeep,

Hope you're doing well. Apologies for following up again, but this v3 patchset has been pending for quite some time. I wanted to check if everything looks good on your end.

Could you please confirm whether you plan to pick both patches? Or do you need an A-b from the i.MX maintainer for patch 2? Alternatively, I can ask Shawn to pick patch 2 if you only intend to take patch 1.

Please let me know your thoughts.

Thanks,
Peng

Quoted 58 lines · Peng Fan

Hi Sudeep, Cristian

Just checking in - did you get a chance to review this patchset? Please let me know if you need any additional details or context.

Thanks,
Peng

Quoted 49 lines · Peng Fan

This is the patch 5 and 6 from patchset [1] with switching to using raw dump, per check with Sudeep and NXP i.MX SM firmware owner

System Manager firmware provides API to dump system log information. So add the interface for Linux to retrieve the information.

In patch 1, I drop the two structures compared to patch 5 in [1]:
struct scmi_imx_misc_sys_sleep_rec
struct scmi_imx_misc_syslog
No other changes in this patch.

In patch 2, I switched to use debugfs to do raw dump the syslog, compared with patch 6 in [1].

[1] https://lore.kernel.org/arm-scmi/PAXPR04MB845937237E3C1AF5A2ABA8FA880CA@PAXPR04MB8459.eurprd04.prod.outlook.com/T/#m6ed303ac9c584c6e2ab39f89359f3131b
dfcc9e5

---
Changes in v3:
- Rebased to next-20251028
- Drop unused variable to avoid build warning reported by kernel test robot
- Link to v2: https://lore.kernel.org/arm-scmi/[email protected]/

Changes in v2:
- Rebased to next-20251010
- Patch 2: Remove the IS_ERR check for debugfs_create_dir per Dan Carpenter Change 'return 0' to 'return devm_add_action_or_reset'
Drop the size check
Include 'linux/sizes.h' to avoid build break
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Peng Fan (2):
firmware: arm_scmi: imx: Support getting syslog of MISC protocol
firmware: imx: sm-misc: Dump syslog info

.../firmware/arm_scmi/vendors/imx/imx-sm-misc.c    | 83 ++++++++++++++++++++++
drivers/firmware/imx/sm-misc.c                     | 37 +++++++++-
include/linux/scmi_imx_protocol.h                  |  2 +
3 files changed, 121 insertions(+), 1 deletion(-)

---
base-commit: f7d2388eeec24966fc4d5cf32d706f0514f29ac5
change-id: 20251029-sm-syslog-v3-0143f85b0ce6

Best regards,

Signature · 1 line
Peng Fan <[email protected]>
#6 lore raw
Quoted 6 lines · Peng Fan

Hi Sudeep,

Hope you're doing well. Apologies for following up again, but this v3 patchset has been pending for quite some time. I wanted to check if everything looks good on your end.

Yes overall it looks good to me.

Quoted 1 line

Could you please confirm whether you plan to pick both patches?

As I had asked once in previous version, I need i.MX maintainer ACK to pick it up myself.

Quoted 1 line

Or do you need an A-b from the i.MX maintainer for patch 2?

Yes as mentioned above.

Quoted 1 line

Alternatively, I can ask Shawn to pick patch 2 if you only intend to take patch 1.

I think that would break build or need to wait for another cycle. I can ack if it can be routed via i.MX tree or need ACK to pick it up myself.

Signature · 2 lines
Regards,
Sudeep
#7 lore raw
Quoted 9 lines · Sudeep Holla
Quoted 6 lines · Peng Fan

Hi Sudeep,

Hope you're doing well. Apologies for following up again, but this v3 patchset has been pending for quite some time. I wanted to check if everything looks good on your end.

Yes overall it looks good to me.

Thanks a lot.

Quoted 1 line

...

Quoted 4 lines
Quoted 1 line

Alternatively, I can ask Shawn to pick patch 2 if you only intend to take patch 1.

I think that would break build or need to wait for another cycle. I can ack if it can be routed via i.MX tree or need ACK to pick it up myself.

Shawn,

Do you plan to pick the two patches with Sudeep's Ack in patch 1? Or you prefer to route the patches via SCMI tree with your Ack?

Thanks,
Peng

Quoted 4 lines
Signature · 3 lines
-- 
Regards,
Sudeep
#8 lore raw
Quoted 17 lines · Peng Fan
Quoted 9 lines · Sudeep Holla
Quoted 6 lines · Peng Fan

Hi Sudeep,

Hope you're doing well. Apologies for following up again, but this v3 patchset has been pending for quite some time. I wanted to check if everything looks good on your end.

Yes overall it looks good to me.

Thanks a lot.

Quoted 1 line

...

Quoted 2 lines
Quoted 1 line

Alternatively, I can ask Shawn to pick patch 2 if you only intend to take patch 1.

Quoted 7 lines
Quoted 2 lines

I think that would break build or need to wait for another cycle. I can ack if it can be routed via i.MX tree or need ACK to pick it up myself.

Shawn,

Do you plan to pick the two patches with Sudeep's Ack in patch 1? Or you prefer to route the patches via SCMI tree with your Ack?

I noticed this morning we are already at -rc5, which is later than my usual PR timing (I generally aim to send to the SoC team between -rc4 and -rc5). I have already sent the SCMI PR.

For these changes, would it be acceptable to route them via the i.MX tree if they are still intended for v7.0/v6.20? If not, I am happy to defer and pick them up for the merge window after next.

Signature · 2 lines
Regards,
Sudeep
Applied
#9 lore raw
Quoted 26 lines · Sudeep Holla
Quoted 17 lines · Peng Fan
Quoted 9 lines · Sudeep Holla
Quoted 6 lines · Peng Fan

Hi Sudeep,

Hope you're doing well. Apologies for following up again, but this v3 patchset has been pending for quite some time. I wanted to check if everything looks good on your end.

Yes overall it looks good to me.

Thanks a lot.

Quoted 1 line

...

Quoted 2 lines
Quoted 1 line

Alternatively, I can ask Shawn to pick patch 2 if you only intend to take patch 1.

Quoted 7 lines
Quoted 2 lines

I think that would break build or need to wait for another cycle. I can ack if it can be routed via i.MX tree or need ACK to pick it up myself.

Shawn,

Do you plan to pick the two patches with Sudeep's Ack in patch 1? Or you prefer to route the patches via SCMI tree with your Ack?

Quoted 7 lines

I noticed this morning we are already at -rc5, which is later than my usual PR timing (I generally aim to send to the SoC team between -rc4 and -rc5). I have already sent the SCMI PR.

For these changes, would it be acceptable to route them via the i.MX tree if they are still intended for v7.0/v6.20? If not, I am happy to defer and pick them up for the merge window after next.

I picked them up for v7.0/v6.20, thanks!

Shawn