* [PATCH 0/2] firmware: arm_scmi: imx: Support getting reset reason
@ 2026-03-05 1:56 Peng Fan (OSS)
2026-03-05 1:56 ` [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol Peng Fan (OSS)
2026-03-05 1:56 ` [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons Peng Fan (OSS)
0 siblings, 2 replies; 11+ messages in thread
From: Peng Fan (OSS) @ 2026-03-05 1:56 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam
Cc: arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan
i.MX SCMI MISC protocol supports getting reset reason per Logical Machine
or System. Add the API for user to retrieve the information from System
Manager.
Documentation: drivers/firmware/arm_scmi/vendors/imx/imx95.rst +1542
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (2):
firmware: arm_scmi: imx: Support getting reset reason of MISC protocol
firmware: imx: sm-misc: Print boot/shutdown reasons
.../firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 86 ++++++++++++++++++++++
drivers/firmware/imx/sm-misc.c | 73 ++++++++++++++++++
include/linux/scmi_imx_protocol.h | 14 ++++
3 files changed, 173 insertions(+)
---
base-commit: d517cb8cea012f43b069617fc8179b45404f8018
change-id: 20260303-scmi-imx-reset-43d4520d0253
Best regards,
--
Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol 2026-03-05 1:56 [PATCH 0/2] firmware: arm_scmi: imx: Support getting reset reason Peng Fan (OSS) @ 2026-03-05 1:56 ` Peng Fan (OSS) 2026-03-05 6:52 ` Daniel Baluta ` (2 more replies) 2026-03-05 1:56 ` [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons Peng Fan (OSS) 1 sibling, 3 replies; 11+ messages in thread From: Peng Fan (OSS) @ 2026-03-05 1:56 UTC (permalink / raw) To: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam Cc: arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan From: Peng Fan <peng.fan@nxp.com> MISC protocol supports getting reset reason per Logical Machine or System. Add the API for user to retrieve the information from System Manager. Signed-off-by: Peng Fan <peng.fan@nxp.com> --- .../firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 86 ++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 14 ++++ 2 files changed, 100 insertions(+) diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c index 0ada753367efe5cbcb8124ea46c05736c49f1ab8..637973fb45e6508c200211708358299cf7cbe3f1 100644 --- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c +++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c @@ -27,6 +27,7 @@ enum scmi_imx_misc_protocol_cmd { SCMI_IMX_MISC_CTRL_GET = 0x4, SCMI_IMX_MISC_DISCOVER_BUILD_INFO = 0x6, SCMI_IMX_MISC_CTRL_NOTIFY = 0x8, + SCMI_IMX_MISC_RESET_REASON_GET = 0xA, SCMI_IMX_MISC_CFG_INFO_GET = 0xC, SCMI_IMX_MISC_SYSLOG_GET = 0xD, SCMI_IMX_MISC_BOARD_INFO = 0xE, @@ -89,6 +90,37 @@ struct scmi_imx_misc_cfg_info_out { u8 cfgname[MISC_MAX_CFGNAME]; }; +struct scmi_imx_misc_reset_reason_in { +#define MISC_REASON_FLAG_SYSTEM BIT(0) + __le32 flags; +}; + +struct scmi_imx_misc_reset_reason_out { + /* Boot reason flags */ +#define MISC_BOOT_FLAG_VLD BIT(31) +#define MISC_BOOT_FLAG_ORG_VLD BIT(28) +#define MISC_BOOT_FLAG_ORIGIN GENMASK(27, 24) +#define MISC_BOOT_FLAG_O_SHIFT 24 +#define MISC_BOOT_FLAG_ERR_VLD BIT(23) +#define MISC_BOOT_FLAG_ERR_ID GENMASK(22, 8) +#define MISC_BOOT_FLAG_E_SHIFT 8 +#define MISC_BOOT_FLAG_REASON GENMASK(7, 0) + __le32 b_flags; + /* Shutdown reason flags */ +#define MISC_SHUTDOWN_FLAG_VLD BIT(31) +#define MISC_SHUTDOWN_FLAG_EXT_LEN GENMASK(30, 29) +#define MISC_SHUTDOWN_FLAG_ORG_VLD BIT(28) +#define MISC_SHUTDOWN_FLAG_ORIGIN GENMASK(27, 24) +#define MISC_SHUTDOWN_FLAG_O_SHIFT 24 +#define MISC_SHUTDOWN_FLAG_ERR_VLD BIT(23) +#define MISC_SHUTDOWN_FLAG_ERR_ID GENMASK(22, 8) +#define MISC_SHUTDOWN_FLAG_E_SHIFT 8 +#define MISC_SHUTDOWN_FLAG_REASON GENMASK(7, 0) + __le32 s_flags; + /* Array of extended info words */ + __le32 extinfo[MISC_EXT_INFO_LEN_MAX]; +}; + struct scmi_imx_misc_syslog_in { __le32 flags; __le32 index; @@ -452,11 +484,65 @@ static int scmi_imx_misc_syslog_get(const struct scmi_protocol_handle *ph, u16 * return ph->hops->iter_response_run(iter); } +static int scmi_imx_misc_reset_reason(const struct scmi_protocol_handle *ph, bool system, + struct scmi_imx_misc_reset_reason *boot_r, + struct scmi_imx_misc_reset_reason *shut_r, + u32 *extinfo) +{ + struct scmi_imx_misc_reset_reason_in *in; + struct scmi_imx_misc_reset_reason_out *out; + struct scmi_xfer *t; + int ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_RESET_REASON_GET, sizeof(*in), + sizeof(*out), &t); + if (ret) + return ret; + + in = t->tx.buf; + if (system) + in->flags = le32_encode_bits(1, MISC_REASON_FLAG_SYSTEM); + else + in->flags = cpu_to_le32(0); + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + out = t->rx.buf; + if (boot_r) { + boot_r->valid = le32_get_bits(out->b_flags, MISC_BOOT_FLAG_VLD); + boot_r->orig_valid = le32_get_bits(out->b_flags, MISC_BOOT_FLAG_ORG_VLD); + boot_r->err_valid = le32_get_bits(out->b_flags, MISC_BOOT_FLAG_ERR_VLD); + boot_r->reason = le32_get_bits(out->b_flags, MISC_BOOT_FLAG_REASON); + boot_r->origin = le32_get_bits(out->b_flags, MISC_BOOT_FLAG_ORIGIN); + boot_r->errid = le32_get_bits(out->b_flags, MISC_BOOT_FLAG_ERR_ID); + } + + if (shut_r) { + shut_r->valid = le32_get_bits(out->s_flags, MISC_SHUTDOWN_FLAG_VLD); + shut_r->orig_valid = le32_get_bits(out->s_flags, + MISC_SHUTDOWN_FLAG_ORG_VLD); + shut_r->err_valid = le32_get_bits(out->s_flags, + MISC_SHUTDOWN_FLAG_ERR_VLD); + shut_r->reason = le32_get_bits(out->s_flags, MISC_SHUTDOWN_FLAG_REASON); + shut_r->origin = le32_get_bits(out->s_flags, MISC_SHUTDOWN_FLAG_ORIGIN); + shut_r->errid = le32_get_bits(out->s_flags, MISC_SHUTDOWN_FLAG_ERR_ID); + } + + if (extinfo) + memcpy_from_le32(extinfo, out->extinfo, MISC_EXT_INFO_LEN_MAX); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + 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, + .misc_reset_reason = scmi_imx_misc_reset_reason, }; static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph) diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h index 2407d7693b6ba1303e07629e45e2a7eaaa906fd3..ab867463c08cc297e063aa1dc4189132a5ddb61a 100644 --- a/include/linux/scmi_imx_protocol.h +++ b/include/linux/scmi_imx_protocol.h @@ -52,6 +52,17 @@ struct scmi_imx_misc_ctrl_notify_report { unsigned int flags; }; + +#define MISC_EXT_INFO_LEN_MAX 4 +struct scmi_imx_misc_reset_reason { + bool valid:1; + bool orig_valid:1; + bool err_valid:1; + u32 reason; + u32 origin; + u32 errid; +}; + struct scmi_imx_misc_proto_ops { int (*misc_ctrl_set)(const struct scmi_protocol_handle *ph, u32 id, u32 num, u32 *val); @@ -61,6 +72,9 @@ struct scmi_imx_misc_proto_ops { u32 ctrl_id, u32 evt_id, u32 flags); int (*misc_syslog)(const struct scmi_protocol_handle *ph, u16 *size, void *array); + int (*misc_reset_reason)(const struct scmi_protocol_handle *ph, + bool system, struct scmi_imx_misc_reset_reason *boot_r, + struct scmi_imx_misc_reset_reason *shut_r, u32 *extinfo); }; /* See LMM_ATTRIBUTES in imx95.rst */ -- 2.37.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol 2026-03-05 1:56 ` [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol Peng Fan (OSS) @ 2026-03-05 6:52 ` Daniel Baluta 2026-03-05 10:18 ` Peng Fan 2026-03-18 15:25 ` Sudeep Holla 2026-03-18 16:09 ` Daniel Baluta 2 siblings, 1 reply; 11+ messages in thread From: Daniel Baluta @ 2026-03-05 6:52 UTC (permalink / raw) To: Peng Fan (OSS) Cc: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan On Thu, Mar 5, 2026 at 3:55 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote: > > From: Peng Fan <peng.fan@nxp.com> > > MISC protocol supports getting reset reason per Logical Machine or > System. Add the API for user to retrieve the information from System > Manager. [..] > +struct scmi_imx_misc_reset_reason_in { > +#define MISC_REASON_FLAG_SYSTEM BIT(0) > + __le32 flags; > +}; > + > +struct scmi_imx_misc_reset_reason_out { > + /* Boot reason flags */ > +#define MISC_BOOT_FLAG_VLD BIT(31) > +#define MISC_BOOT_FLAG_ORG_VLD BIT(28) > +#define MISC_BOOT_FLAG_ORIGIN GENMASK(27, 24) > +#define MISC_BOOT_FLAG_O_SHIFT 24 > +#define MISC_BOOT_FLAG_ERR_VLD BIT(23) > +#define MISC_BOOT_FLAG_ERR_ID GENMASK(22, 8) > +#define MISC_BOOT_FLAG_E_SHIFT 8 > +#define MISC_BOOT_FLAG_REASON GENMASK(7, 0) I would move this macros outside of the struct. Although the intention is good it makes everything hard to read. Just do: struct scmi_imx_misc_reset_reason_out { __le32 b_flags; /* MISC_BOOT_FLAG_* flags */ __le32 s_flags; /* MISC_SHUTDOWN_FLAG_* flags */ /* Array of extended info words */ __le32 extinfo[MISC_EXT_INFO_LEN_MAX]; } [...] > +static int scmi_imx_misc_reset_reason(const struct scmi_protocol_handle *ph, bool system, > + struct scmi_imx_misc_reset_reason *boot_r, > + struct scmi_imx_misc_reset_reason *shut_r, > + u32 *extinfo) > +{ > + struct scmi_imx_misc_reset_reason_in *in; > + struct scmi_imx_misc_reset_reason_out *out; > + struct scmi_xfer *t; > + int ret; > + > + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_RESET_REASON_GET, sizeof(*in), > + sizeof(*out), &t); > + if (ret) > + return ret; > + > + in = t->tx.buf; > + if (system) > + in->flags = le32_encode_bits(1, MISC_REASON_FLAG_SYSTEM); > + else > + in->flags = cpu_to_le32(0); What does system = 0 mean? can you directly do in->flags = 0? > + > + ret = ph->xops->do_xfer(ph, t); Is it mandatory to call ph->xops->xfer_put(ph, t); even if ret ! = 0? Because we can get rid of one level of indentation with: ret = ph->xops->do_xfer(ph, t); if (ret) return ret; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol 2026-03-05 6:52 ` Daniel Baluta @ 2026-03-05 10:18 ` Peng Fan 0 siblings, 0 replies; 11+ messages in thread From: Peng Fan @ 2026-03-05 10:18 UTC (permalink / raw) To: Daniel Baluta Cc: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan Hi Daniel, Thanks for giving a look. On Thu, Mar 05, 2026 at 08:52:41AM +0200, Daniel Baluta wrote: >On Thu, Mar 5, 2026 at 3:55 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote: >> >> From: Peng Fan <peng.fan@nxp.com> >> >> MISC protocol supports getting reset reason per Logical Machine or >> System. Add the API for user to retrieve the information from System >> Manager. > >[..] > >> +struct scmi_imx_misc_reset_reason_in { >> +#define MISC_REASON_FLAG_SYSTEM BIT(0) >> + __le32 flags; >> +}; >> + >> +struct scmi_imx_misc_reset_reason_out { >> + /* Boot reason flags */ >> +#define MISC_BOOT_FLAG_VLD BIT(31) >> +#define MISC_BOOT_FLAG_ORG_VLD BIT(28) >> +#define MISC_BOOT_FLAG_ORIGIN GENMASK(27, 24) >> +#define MISC_BOOT_FLAG_O_SHIFT 24 >> +#define MISC_BOOT_FLAG_ERR_VLD BIT(23) >> +#define MISC_BOOT_FLAG_ERR_ID GENMASK(22, 8) >> +#define MISC_BOOT_FLAG_E_SHIFT 8 >> +#define MISC_BOOT_FLAG_REASON GENMASK(7, 0) > >I would move this macros outside of the struct. Although the intention >is good it makes everything hard to read. I followed arm_scmi coding style, such as drivers/firmware/arm_scmi/clock.c drivers/firmware/arm_scmi/perf.c and etc. I would not break the rule here. > >Just do: > >struct scmi_imx_misc_reset_reason_out { >__le32 b_flags; /* MISC_BOOT_FLAG_* flags */ >__le32 s_flags; /* MISC_SHUTDOWN_FLAG_* flags */ > /* Array of extended info words */ > __le32 extinfo[MISC_EXT_INFO_LEN_MAX]; >} > >[...] > >> +static int scmi_imx_misc_reset_reason(const struct scmi_protocol_handle *ph, bool system, >> + struct scmi_imx_misc_reset_reason *boot_r, >> + struct scmi_imx_misc_reset_reason *shut_r, >> + u32 *extinfo) >> +{ >> + struct scmi_imx_misc_reset_reason_in *in; >> + struct scmi_imx_misc_reset_reason_out *out; >> + struct scmi_xfer *t; >> + int ret; >> + >> + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_RESET_REASON_GET, sizeof(*in), >> + sizeof(*out), &t); >> + if (ret) >> + return ret; >> + >> + in = t->tx.buf; >> + if (system) >> + in->flags = le32_encode_bits(1, MISC_REASON_FLAG_SYSTEM); >> + else >> + in->flags = cpu_to_le32(0); > >What does system = 0 mean? can you directly do in->flags = 0? If system is false, that means to get LM(logial machine) reset reason. If system is true, that means to get system reset reason. grep "cpu_to_le32(0)" ./drivers/firmware/arm_scmi/ -rn You will see other usage, I just follow same style here. > > >> + >> + ret = ph->xops->do_xfer(ph, t); > >Is it mandatory to call ph->xops->xfer_put(ph, t); even if ret ! = 0? >Because we can get rid of one level of indentation with: yes, xfer_put is mandatory. Thanks, Peng. > > ret = ph->xops->do_xfer(ph, t); > if (ret) > return ret; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol 2026-03-05 1:56 ` [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol Peng Fan (OSS) 2026-03-05 6:52 ` Daniel Baluta @ 2026-03-18 15:25 ` Sudeep Holla 2026-03-18 16:09 ` Daniel Baluta 2 siblings, 0 replies; 11+ messages in thread From: Sudeep Holla @ 2026-03-18 15:25 UTC (permalink / raw) To: Peng Fan (OSS) Cc: Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Sudeep Holla, Fabio Estevam, arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan On Thu, Mar 05, 2026 at 09:56:44AM +0800, Peng Fan (OSS) wrote: > From: Peng Fan <peng.fan@nxp.com> > > MISC protocol supports getting reset reason per Logical Machine or > System. Add the API for user to retrieve the information from System > Manager. > Sorry for missing this earlier. It looks good though my usual rant is that this MISC protocol is becoming never ending dumping ground for all sorts of info you want kernel to dump in dmesg. Anyways, I am not too bothered as it is not any user ABI. If, you plan to ask i.MX maintainers to pick this up, Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org> If not, I need their ack for 2/2/ -- Regards, Sudeep ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol 2026-03-05 1:56 ` [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol Peng Fan (OSS) 2026-03-05 6:52 ` Daniel Baluta 2026-03-18 15:25 ` Sudeep Holla @ 2026-03-18 16:09 ` Daniel Baluta 2 siblings, 0 replies; 11+ messages in thread From: Daniel Baluta @ 2026-03-18 16:09 UTC (permalink / raw) To: Peng Fan (OSS) Cc: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan On Thu, Mar 5, 2026 at 3:55 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote: > > From: Peng Fan <peng.fan@nxp.com> > > MISC protocol supports getting reset reason per Logical Machine or > System. Add the API for user to retrieve the information from System > Manager. > > Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com> Thanks Peng for your explanations! ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons 2026-03-05 1:56 [PATCH 0/2] firmware: arm_scmi: imx: Support getting reset reason Peng Fan (OSS) 2026-03-05 1:56 ` [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol Peng Fan (OSS) @ 2026-03-05 1:56 ` Peng Fan (OSS) 2026-03-05 7:44 ` Alexander Stein 1 sibling, 1 reply; 11+ messages in thread From: Peng Fan (OSS) @ 2026-03-05 1:56 UTC (permalink / raw) To: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam Cc: arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan From: Peng Fan <peng.fan@nxp.com> Add reset reason string table for i.MX95 and introduce a helper (scmi_imx_misc_get_reason) to query and print both system and LM (Logical Machine) reset reasons via the SCMI MISC protocol. Signed-off-by: Peng Fan <peng.fan@nxp.com> --- drivers/firmware/imx/sm-misc.c | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c index 0a8ada329c9de3c1627da241bf142fa91a8085d7..16b5ff833d21274403a4c55abe2fa1f49fce3e73 100644 --- a/drivers/firmware/imx/sm-misc.c +++ b/drivers/firmware/imx/sm-misc.c @@ -18,6 +18,29 @@ static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops; static struct scmi_protocol_handle *ph; struct notifier_block scmi_imx_misc_ctrl_nb; +static const char * const rst_imx95[] = { + "cm33_lockup", "cm33_swreq", "cm7_lockup", "cm7_swreq", "fccu", + "jtag_sw", "ele", "tempsense", "wdog1", "wdog2", "wdog3", "wdog4", + "wdog5", "jtag", "cm33_exc", "bbm", "sw", "sm_err", "fusa_sreco", + "pmic", "unused", "unused", "unused", "unused", "unused", "unused", + "unused", "unused", "unused", "unused", "unused", "por", +}; + +static const char * const rst_imx94[] = { + "cm33_lockup", "cm33_swreq", "cm70_lockup", "cm70_swreq", "fccu", + "jtag_sw", "ele", "tempsense", "wdog1", "wdog2", "wdog3", "wdog4", + "wdog5", "jtag", "wdog6", "wdog7", "wdog8", "wo_netc", "cm33s_lockup", + "cm33s_swreq", "cm71_lockup", "cm71_swreq", "cm33_exc", "bbm", "sw", + "sm_err", "fusa_sreco", "pmic", "unused", "unused", "unused", "por", +}; + +static const struct of_device_id allowlist[] = { + { .compatible = "fsl,imx952", .data = rst_imx95 }, + { .compatible = "fsl,imx95", .data = rst_imx95 }, + { .compatible = "fsl,imx94", .data = rst_imx94 }, + { /* Sentinel */ } +}; + int scmi_imx_misc_ctrl_set(u32 id, u32 val) { if (!ph) @@ -75,6 +98,54 @@ static void scmi_imx_misc_put(void *p) debugfs_remove((struct dentry *)p); } +static int scmi_imx_misc_get_reason(struct scmi_device *sdev) +{ + struct scmi_imx_misc_reset_reason boot, shutdown; + const char **rst; + bool system = true; + int ret; + + if (!of_machine_device_match(allowlist)) + return 0; + + rst = (const char **)of_machine_get_match_data(allowlist); + + ret = imx_misc_ctrl_ops->misc_reset_reason(ph, system, &boot, &shutdown, NULL); + if (!ret) { + if (boot.valid) + dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n", + system ? "SYS" : "LM", rst[boot.reason], + boot.orig_valid ? boot.origin : -1, + boot.err_valid ? boot.errid : -1); + if (shutdown.valid) + dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n", + system ? "SYS" : "LM", rst[shutdown.reason], + shutdown.orig_valid ? shutdown.origin : -1, + shutdown.err_valid ? shutdown.errid : -1); + } else { + dev_err(&sdev->dev, "Failed to get system reset reason: %d\n", ret); + } + + system = false; + ret = imx_misc_ctrl_ops->misc_reset_reason(ph, system, &boot, &shutdown, NULL); + if (!ret) { + if (boot.valid) + dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n", + system ? "SYS" : "LM", rst[boot.reason], + boot.orig_valid ? boot.origin : -1, + boot.err_valid ? boot.errid : -1); + if (shutdown.valid) + dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n", + system ? "SYS" : "LM", rst[shutdown.reason], + shutdown.orig_valid ? shutdown.origin : -1, + shutdown.err_valid ? shutdown.errid : -1); + } else { + dev_err(&sdev->dev, "Failed to get lm reset reason: %d\n", ret); + } + + return 0; +} + static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) { const struct scmi_handle *handle = sdev->handle; @@ -133,6 +204,8 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL); debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops); + scmi_imx_misc_get_reason(sdev); + return devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry); } -- 2.37.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons 2026-03-05 1:56 ` [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons Peng Fan (OSS) @ 2026-03-05 7:44 ` Alexander Stein 2026-03-05 10:22 ` Peng Fan 0 siblings, 1 reply; 11+ messages in thread From: Alexander Stein @ 2026-03-05 7:44 UTC (permalink / raw) To: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel Cc: arm-scmi, imx, linux-arm-kernel, linux-kernel, Peng Fan, Peng Fan (OSS) Hi, Am Donnerstag, 5. März 2026, 02:56:45 CET schrieb Peng Fan (OSS): > From: Peng Fan <peng.fan@nxp.com> > > Add reset reason string table for i.MX95 and introduce a helper > (scmi_imx_misc_get_reason) to query and print both system and LM > (Logical Machine) reset reasons via the SCMI MISC protocol. > > Signed-off-by: Peng Fan <peng.fan@nxp.com> > --- > drivers/firmware/imx/sm-misc.c | 73 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 73 insertions(+) > > diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c > index 0a8ada329c9de3c1627da241bf142fa91a8085d7..16b5ff833d21274403a4c55abe2fa1f49fce3e73 100644 > --- a/drivers/firmware/imx/sm-misc.c > +++ b/drivers/firmware/imx/sm-misc.c > @@ -18,6 +18,29 @@ static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops; > static struct scmi_protocol_handle *ph; > struct notifier_block scmi_imx_misc_ctrl_nb; > > +static const char * const rst_imx95[] = { > + "cm33_lockup", "cm33_swreq", "cm7_lockup", "cm7_swreq", "fccu", > + "jtag_sw", "ele", "tempsense", "wdog1", "wdog2", "wdog3", "wdog4", > + "wdog5", "jtag", "cm33_exc", "bbm", "sw", "sm_err", "fusa_sreco", > + "pmic", "unused", "unused", "unused", "unused", "unused", "unused", > + "unused", "unused", "unused", "unused", "unused", "por", > +}; > + > +static const char * const rst_imx94[] = { > + "cm33_lockup", "cm33_swreq", "cm70_lockup", "cm70_swreq", "fccu", > + "jtag_sw", "ele", "tempsense", "wdog1", "wdog2", "wdog3", "wdog4", > + "wdog5", "jtag", "wdog6", "wdog7", "wdog8", "wo_netc", "cm33s_lockup", > + "cm33s_swreq", "cm71_lockup", "cm71_swreq", "cm33_exc", "bbm", "sw", > + "sm_err", "fusa_sreco", "pmic", "unused", "unused", "unused", "por", > +}; > + > +static const struct of_device_id allowlist[] = { > + { .compatible = "fsl,imx952", .data = rst_imx95 }, > + { .compatible = "fsl,imx95", .data = rst_imx95 }, > + { .compatible = "fsl,imx94", .data = rst_imx94 }, > + { /* Sentinel */ } > +}; > + > int scmi_imx_misc_ctrl_set(u32 id, u32 val) > { > if (!ph) > @@ -75,6 +98,54 @@ static void scmi_imx_misc_put(void *p) > debugfs_remove((struct dentry *)p); > } > > +static int scmi_imx_misc_get_reason(struct scmi_device *sdev) > +{ > + struct scmi_imx_misc_reset_reason boot, shutdown; > + const char **rst; > + bool system = true; > + int ret; > + > + if (!of_machine_device_match(allowlist)) > + return 0; > + > + rst = (const char **)of_machine_get_match_data(allowlist); > + > + ret = imx_misc_ctrl_ops->misc_reset_reason(ph, system, &boot, &shutdown, NULL); > + if (!ret) { > + if (boot.valid) > + dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n", > + system ? "SYS" : "LM", rst[boot.reason], > + boot.orig_valid ? boot.origin : -1, > + boot.err_valid ? boot.errid : -1); > + if (shutdown.valid) > + dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n", > + system ? "SYS" : "LM", rst[shutdown.reason], > + shutdown.orig_valid ? shutdown.origin : -1, > + shutdown.err_valid ? shutdown.errid : -1); > + } else { > + dev_err(&sdev->dev, "Failed to get system reset reason: %d\n", ret); > + } > + > + system = false; > + ret = imx_misc_ctrl_ops->misc_reset_reason(ph, system, &boot, &shutdown, NULL); > + if (!ret) { > + if (boot.valid) > + dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n", > + system ? "SYS" : "LM", rst[boot.reason], > + boot.orig_valid ? boot.origin : -1, > + boot.err_valid ? boot.errid : -1); > + if (shutdown.valid) > + dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n", > + system ? "SYS" : "LM", rst[shutdown.reason], > + shutdown.orig_valid ? shutdown.origin : -1, > + shutdown.err_valid ? shutdown.errid : -1); Is there a way to query this from userspace programs instead of printing into kernel log? Best regards, Alexander > + } else { > + dev_err(&sdev->dev, "Failed to get lm reset reason: %d\n", ret); > + } > + > + return 0; > +} > + > static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) > { > const struct scmi_handle *handle = sdev->handle; > @@ -133,6 +204,8 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) > scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL); > debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops); > > + scmi_imx_misc_get_reason(sdev); > + > return devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry); > } > > > -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons 2026-03-05 7:44 ` Alexander Stein @ 2026-03-05 10:22 ` Peng Fan 2026-03-05 10:48 ` Oleksij Rempel 0 siblings, 1 reply; 11+ messages in thread From: Peng Fan @ 2026-03-05 10:22 UTC (permalink / raw) To: Alexander Stein Cc: Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel, arm-scmi, imx, linux-kernel, Peng Fan Hi Alexander, Thanks for giving a look. On Thu, Mar 05, 2026 at 08:44:26AM +0100, Alexander Stein wrote: >Hi, > >Am Donnerstag, 5. März 2026, 02:56:45 CET schrieb Peng Fan (OSS): >> From: Peng Fan <peng.fan@nxp.com> >> >> Add reset reason string table for i.MX95 and introduce a helper >> (scmi_imx_misc_get_reason) to query and print both system and LM >> (Logical Machine) reset reasons via the SCMI MISC protocol. >> >> Signed-off-by: Peng Fan <peng.fan@nxp.com> >> --- [...] >> + if (boot.valid) >> + dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n", >> + system ? "SYS" : "LM", rst[boot.reason], >> + boot.orig_valid ? boot.origin : -1, >> + boot.err_valid ? boot.errid : -1); >> + if (shutdown.valid) >> + dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n", >> + system ? "SYS" : "LM", rst[shutdown.reason], >> + shutdown.orig_valid ? shutdown.origin : -1, >> + shutdown.err_valid ? shutdown.errid : -1); > >Is there a way to query this from userspace programs instead of printing into kernel log? I not add sysfs or debugfs to get the information in this patchset, since our customer only want the information could be shown in kernel boot log. But I could add also sysfs interface to allow userspace get the information if you need this feature. Regards, Peng > >Best regards, >Alexander > >> + } else { >> + dev_err(&sdev->dev, "Failed to get lm reset reason: %d\n", ret); >> + } >> + >> + return 0; >> +} >> + >> static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) >> { >> const struct scmi_handle *handle = sdev->handle; >> @@ -133,6 +204,8 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) >> scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL); >> debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops); >> >> + scmi_imx_misc_get_reason(sdev); >> + >> return devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry); >> } >> >> >> > > >-- >TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany >Amtsgericht München, HRB 105018 >Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider >http://www.tq-group.com/ > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons 2026-03-05 10:22 ` Peng Fan @ 2026-03-05 10:48 ` Oleksij Rempel 2026-03-10 5:10 ` Peng Fan 0 siblings, 1 reply; 11+ messages in thread From: Oleksij Rempel @ 2026-03-05 10:48 UTC (permalink / raw) To: Peng Fan Cc: Alexander Stein, Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel, arm-scmi, imx, linux-kernel, Peng Fan Hi all, On Thu, Mar 05, 2026 at 06:22:15PM +0800, Peng Fan wrote: > Hi Alexander, > > Thanks for giving a look. > > On Thu, Mar 05, 2026 at 08:44:26AM +0100, Alexander Stein wrote: > >Hi, > > > >Am Donnerstag, 5. März 2026, 02:56:45 CET schrieb Peng Fan (OSS): > >> From: Peng Fan <peng.fan@nxp.com> > >> > >> Add reset reason string table for i.MX95 and introduce a helper > >> (scmi_imx_misc_get_reason) to query and print both system and LM > >> (Logical Machine) reset reasons via the SCMI MISC protocol. > >> > >> Signed-off-by: Peng Fan <peng.fan@nxp.com> > >> --- > [...] > >> + if (boot.valid) > >> + dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n", > >> + system ? "SYS" : "LM", rst[boot.reason], > >> + boot.orig_valid ? boot.origin : -1, > >> + boot.err_valid ? boot.errid : -1); > >> + if (shutdown.valid) > >> + dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n", > >> + system ? "SYS" : "LM", rst[shutdown.reason], > >> + shutdown.orig_valid ? shutdown.origin : -1, > >> + shutdown.err_valid ? shutdown.errid : -1); > > > >Is there a way to query this from userspace programs instead of printing into kernel log? > > I not add sysfs or debugfs to get the information in this patchset, since our > customer only want the information could be shown in kernel boot log. > > But I could add also sysfs interface to allow userspace get the information if > you need this feature. I started to working on corresponding framework: https://lore.kernel.org/all/20250618120255.3141862-1-o.rempel@pengutronix.de/ but it is stalled due to devicetree decisions. I wont to respin the discussion tomorrow Best Regards, Oleksij ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons 2026-03-05 10:48 ` Oleksij Rempel @ 2026-03-10 5:10 ` Peng Fan 0 siblings, 0 replies; 11+ messages in thread From: Peng Fan @ 2026-03-10 5:10 UTC (permalink / raw) To: Oleksij Rempel Cc: Alexander Stein, Sudeep Holla, Cristian Marussi, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel, arm-scmi, imx, linux-kernel, Peng Fan On Thu, Mar 05, 2026 at 11:48:31AM +0100, Oleksij Rempel wrote: >Hi all, > >On Thu, Mar 05, 2026 at 06:22:15PM +0800, Peng Fan wrote: >> Hi Alexander, >> >> Thanks for giving a look. >> >> On Thu, Mar 05, 2026 at 08:44:26AM +0100, Alexander Stein wrote: >> >Hi, >> > >> >Am Donnerstag, 5. März 2026, 02:56:45 CET schrieb Peng Fan (OSS): >> >> From: Peng Fan <peng.fan@nxp.com> >> >> >> >> Add reset reason string table for i.MX95 and introduce a helper >> >> (scmi_imx_misc_get_reason) to query and print both system and LM >> >> (Logical Machine) reset reasons via the SCMI MISC protocol. >> >> >> >> Signed-off-by: Peng Fan <peng.fan@nxp.com> >> >> --- >> [...] >> >> + if (boot.valid) >> >> + dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n", >> >> + system ? "SYS" : "LM", rst[boot.reason], >> >> + boot.orig_valid ? boot.origin : -1, >> >> + boot.err_valid ? boot.errid : -1); >> >> + if (shutdown.valid) >> >> + dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n", >> >> + system ? "SYS" : "LM", rst[shutdown.reason], >> >> + shutdown.orig_valid ? shutdown.origin : -1, >> >> + shutdown.err_valid ? shutdown.errid : -1); >> > >> >Is there a way to query this from userspace programs instead of printing into kernel log? >> >> I not add sysfs or debugfs to get the information in this patchset, since our >> customer only want the information could be shown in kernel boot log. >> >> But I could add also sysfs interface to allow userspace get the information if >> you need this feature. > >I started to working on corresponding framework: >https://lore.kernel.org/all/20250618120255.3141862-1-o.rempel@pengutronix.de/ Thanks for sharing the thread. > >but it is stalled due to devicetree decisions. I wont to respin the >discussion tomorrow TBH, I have not look into the details. If the generic framework could land into linux kernel, we could use this in i.MX SCMI reset reason. But I would not add dependency for now, so I will still just keep printing the log into kernel log. Thanks, Peng > >Best Regards, >Oleksij ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-03-18 16:06 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-05 1:56 [PATCH 0/2] firmware: arm_scmi: imx: Support getting reset reason Peng Fan (OSS) 2026-03-05 1:56 ` [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol Peng Fan (OSS) 2026-03-05 6:52 ` Daniel Baluta 2026-03-05 10:18 ` Peng Fan 2026-03-18 15:25 ` Sudeep Holla 2026-03-18 16:09 ` Daniel Baluta 2026-03-05 1:56 ` [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons Peng Fan (OSS) 2026-03-05 7:44 ` Alexander Stein 2026-03-05 10:22 ` Peng Fan 2026-03-05 10:48 ` Oleksij Rempel 2026-03-10 5:10 ` Peng Fan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox