public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Sudeep Holla <sudeep.holla@kernel.org>,
	Cristian Marussi <cristian.marussi@arm.com>,
	Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	arm-scmi@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol
Date: Thu, 5 Mar 2026 18:18:56 +0800	[thread overview]
Message-ID: <aalYkDpKS/W3p3m2@shlinux89> (raw)
In-Reply-To: <CAEnQRZC4w3qNOJgth=8N-Ri3wFeKc-=VnQXWzr4WR0j6yt7WMQ@mail.gmail.com>

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;

  reply	other threads:[~2026-03-05 10:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aalYkDpKS/W3p3m2@shlinux89 \
    --to=peng.fan@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=daniel.baluta@gmail.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sudeep.holla@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox