lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMZ6RqLcUoaD9ErNXyN5gxGSU7qPtW4HPRft=EnH0V1yVSYGCQ@mail.gmail.com>
Date: Fri, 12 Jul 2024 11:36:43 +0900
From: Vincent MAILHOL <mailhol.vincent@...adoo.fr>
To: Frank Li <Frank.Li@....com>
Cc: Marc Kleine-Budde <mkl@...gutronix.de>, "David S. Miller" <davem@...emloft.net>, 
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, 
	Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, 
	linux-can@...r.kernel.org, netdev@...r.kernel.org, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org, haibo.chen@....com, imx@...ts.linux.dev, 
	han.xu@....com
Subject: Re: [PATCH 4/4] can: flexcan: add wakeup support for imx95

Hi,

Thank you for the patch. I am not familiar with the iMX95 quirks, but
to the extent of my knowledge, the patch looks good.

Here are a few nits. Next time, maybe you should run a syntax checker
to catch the easy mistakes in the English grammar.

You can directly add my review tag to the v2:

Reviewed-by: Vincent Mailhol <mailhol.vincent@...adoo.fr>

Le ven. 12 juil. 2024 à 03:24, Frank Li <Frank.Li@....com> a écrit :
>
> From: Haibo Chen <haibo.chen@....com>
>
> iMX95 define a bit in GPR that assert/desert IPG_STOP signal to Flex CAN
        ^^^^^^
define -> defines
assert/desert -> desert means to "run away" or "leave behind". Not
sure this is the correct word here. Maybe something like set/unset is
better here? This sentence is worth rephrasing.

> module. It control flexcan enter STOP mode. Wakeup should work even FlexCAN
             ^^^^^^^                                             ^^^^
control -> controls
even -> even if

> is in STOP mode.
>
> Due to iMX95 architecture design, A-Core can't access GPR. Only the system
> manager (SM) can config GPR. To support the wakeup feature, follow below
                   ^^^^^^
config -> configure
>
> For suspend:
>
> 1) linux suspend, when CAN suspend, do nothing for GPR, and keep CAN
> related clock on.
> 2) In ATF, check whether the CAN need to support wakeup, if yes, send a
                                   ^^^^
need -> needs

> request to SM through SCMI protocol.
> 3) In SM, config the GPR and assert IPG_STOP.
> 4) A-Core suspend.
>
> For wakeup and resume:
>
> 1) A-core wakeup event arrive.
> 2) In SM, deassert IPG_STOP.
> 3) Linux resume.

Indent your lists:

  - For suspend:

    1) linux suspend, when CAN suspend, do nothing for GPR, and keep CAN
       related clock on.
    2) In ATF, check whether the CAN need to support wakeup, if yes, send a
       request to SM through SCMI protocol.
    3) In SM, config the GPR and assert IPG_STOP.
    4) A-Core suspend.

  - For wakeup and resume:

    1) A-core wakeup event arrive.
    2) In SM, deassert IPG_STOP.
    3) Linux resume.

> Add a new fsl_imx95_devtype_data and FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI to
> reflect this.
>
> Reviewed-by: Han Xu <han.xu@....com>
> Signed-off-by: Haibo Chen <haibo.chen@....com>
> Signed-off-by: Frank Li <Frank.Li@....com>
> ---
>  drivers/net/can/flexcan/flexcan-core.c | 49 ++++++++++++++++++++++++++++++----
>  drivers/net/can/flexcan/flexcan.h      |  2 ++
>  2 files changed, 46 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
> index f6e609c388d55..ad3240e7e6ab4 100644
> --- a/drivers/net/can/flexcan/flexcan-core.c
> +++ b/drivers/net/can/flexcan/flexcan-core.c
> @@ -354,6 +354,14 @@ static struct flexcan_devtype_data fsl_imx93_devtype_data = {
>                 FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
>  };
>
> +static struct flexcan_devtype_data fsl_imx95_devtype_data = {
> +       .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
> +               FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
> +               FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI |
> +               FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC |
> +               FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
> +               FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
> +};

Can you declare this as constant?

  static const struct flexcan_devtype_data fsl_imx95_devtype_data = {

>  static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
>         .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
>                 FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
> @@ -548,6 +556,13 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
>         } else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) {
>                 regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
>                                    1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
> +       } else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI) {
> +               /* For the SCMI mode, driver do nothing, ATF will send request to
> +                * SM(system manager, M33 core) through SCMI protocol after linux
> +                * suspend. Once SM get this request, it will send IPG_STOP signal
> +                * to Flex_CAN, let CAN in STOP mode.
> +                */
> +               return 0;
>         }
>
>         return flexcan_low_power_enter_ack(priv);
> @@ -559,7 +574,11 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
>         u32 reg_mcr;
>         int ret;
>
> -       /* remove stop request */
> +       /* Remove stop request, for FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI,
> +        * do nothing here, because ATF already send request to SM before
> +        * linux resume. Once SM get this request, it will deassert the
> +        * IPG_STOP signal to Flex_CAN.
> +        */
>         if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW) {
>                 ret = flexcan_stop_mode_enable_scfw(priv, false);
>                 if (ret < 0)
> @@ -1987,6 +2006,9 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
>                 ret = flexcan_setup_stop_mode_scfw(pdev);
>         else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR)
>                 ret = flexcan_setup_stop_mode_gpr(pdev);
> +       else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI)
> +               /* ATF will handle all STOP_IPG related work */
> +               ret = 0;
>         else
>                 /* return 0 directly if doesn't support stop mode feature */
>                 return 0;
> @@ -2013,6 +2035,7 @@ static const struct of_device_id flexcan_of_match[] = {
>         { .compatible = "fsl,imx8qm-flexcan", .data = &fsl_imx8qm_devtype_data, },
>         { .compatible = "fsl,imx8mp-flexcan", .data = &fsl_imx8mp_devtype_data, },
>         { .compatible = "fsl,imx93-flexcan", .data = &fsl_imx93_devtype_data, },
> +       { .compatible = "fsl,imx95-flexcan", .data = &fsl_imx95_devtype_data, },
>         { .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
>         { .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
>         { .compatible = "fsl,imx53-flexcan", .data = &fsl_imx25_devtype_data, },
> @@ -2311,9 +2334,22 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device)
>         if (netif_running(dev)) {
>                 int err;
>
> -               if (device_may_wakeup(device))
> +               if (device_may_wakeup(device)) {
>                         flexcan_enable_wakeup_irq(priv, true);
>
> +                       /* For FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI, it need
> +                        * ATF to send request to SM through SCMI protocol,
> +                        * SM will assert the IPG_STOP signal. But all this
> +                        * works need the CAN clocks keep on.
> +                        * After the CAN module get the IPG_STOP mode, and
> +                        * switch to STOP mode, whether still keep the CAN
> +                        * clocks on or gate them off depend on the Hardware
> +                        * design.
> +                        */
> +                       if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI)
> +                               return 0;
> +               }
> +
>                 err = pm_runtime_force_suspend(device);
>                 if (err)
>                         return err;
> @@ -2330,9 +2366,12 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device)
>         if (netif_running(dev)) {
>                 int err;
>
> -               err = pm_runtime_force_resume(device);
> -               if (err)
> -                       return err;
> +               if (!(device_may_wakeup(device) &&
> +                     priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI)) {
> +                       err = pm_runtime_force_resume(device);
> +                       if (err)
> +                               return err;
> +               }
>
>                 if (device_may_wakeup(device))
>                         flexcan_enable_wakeup_irq(priv, false);
> diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/flexcan.h
> index 025c3417031f4..4933d8c7439e6 100644
> --- a/drivers/net/can/flexcan/flexcan.h
> +++ b/drivers/net/can/flexcan/flexcan.h
> @@ -68,6 +68,8 @@
>  #define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15)
>  /* Device supports RX via FIFO */
>  #define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16)
> +/* Setup stop mode with ATF SCMI protocol to support wakeup */
> +#define FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI BIT(17)
>
>  struct flexcan_devtype_data {
>         u32 quirks;             /* quirks needed for different IP cores */
>
> --
> 2.34.1
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ