From: Peng Fan <peng.fan@nxp.com>
To: "Franck Lenormand (OSS)" <franck.lenormand@oss.nxp.com>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"festevam@gmail.com" <festevam@gmail.com>
Cc: "kernel@pengutronix.de" <kernel@pengutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
dl-linux-imx <linux-imx@nxp.com>,
Aisheng Dong <aisheng.dong@nxp.com>,
Abel Vesa <abel.vesa@nxp.com>, Anson Huang <anson.huang@nxp.com>,
"linux@rempel-privat.de" <linux@rempel-privat.de>,
Leonard Crestez <leonard.crestez@nxp.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Joakim Zhang <qiangqing.zhang@nxp.com>
Subject: RE: [PATCH 2/7] firmware: imx: scu: Support reception of messages of any size
Date: Tue, 21 Jul 2020 01:25:17 +0000 [thread overview]
Message-ID: <DB6PR0402MB27609873F3C0183D022674A088780@DB6PR0402MB2760.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <1595235977-106241-3-git-send-email-franck.lenormand@oss.nxp.com>
> Subject: [PATCH 2/7] firmware: imx: scu: Support reception of messages of
> any size
Could fast_ipc be used for your case? I am not fans to use the legacy method
which is error prone.
Thanks,
Peng.
>
> From: Franck LENORMAND <franck.lenormand@nxp.com>
>
> The word of a message can arrive in any order and the current driver cannot
> receive more than 4-word message.
>
> To fix this, a new variable rx_pos is added to imx_sc_chan structure to save
> the position at which the word receive must be stored.
>
> The position is initialized by the index of the channel.
>
> The position is incremented by SCU_MU_RX_CHAN_NUM each time a word
> is received on the channel.
>
> This allow the words to be received in any order and be stored in the
> expected order.
>
> Signed-off-by: Franck LENORMAND <franck.lenormand@oss.nxp.com>
> ---
> drivers/firmware/imx/imx-scu.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c
> index 2ab0482..7c13595 100644
> --- a/drivers/firmware/imx/imx-scu.c
> +++ b/drivers/firmware/imx/imx-scu.c
> @@ -1,6 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0+
> /*
> - * Copyright 2018 NXP
> + * Copyright 2018,2020 NXP
> * Author: Dong Aisheng <aisheng.dong@nxp.com>
> *
> * Implementation of the SCU IPC functions using MUs (client side).
> @@ -19,6 +19,8 @@
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
>
> +#define SCU_MU_TX_CHAN_NUM 4
> +#define SCU_MU_RX_CHAN_NUM 4
> #define SCU_MU_CHAN_NUM 8
> #define MAX_RX_TIMEOUT (msecs_to_jiffies(30))
>
> @@ -29,6 +31,7 @@ struct imx_sc_chan {
> struct mbox_chan *ch;
> int idx;
> struct completion tx_done;
> + u8 rx_pos;
> };
>
> struct imx_sc_ipc {
> @@ -136,16 +139,14 @@ static void imx_scu_rx_callback(struct mbox_client
> *c, void *msg)
> return;
> }
>
> - if (sc_chan->idx == 0) {
> + if (sc_chan->rx_pos == 0) {
> hdr = msg;
> sc_ipc->rx_size = hdr->size;
> dev_dbg(sc_ipc->dev, "msg rx size %u\n", sc_ipc->rx_size);
> - if (sc_ipc->rx_size > 4)
> - dev_warn(sc_ipc->dev, "RPC does not support receiving over 4
> words: %u\n",
> - sc_ipc->rx_size);
> }
>
> - sc_ipc->msg[sc_chan->idx] = *data;
> + sc_ipc->msg[sc_chan->rx_pos] = *data;
> + sc_chan->rx_pos += SCU_MU_RX_CHAN_NUM;
> sc_ipc->count++;
>
> dev_dbg(sc_ipc->dev, "mu %u msg %u 0x%x\n", sc_chan->idx, @@
> -205,6 +206,7 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg,
> bool have_resp)
> uint8_t saved_svc, saved_func;
> struct imx_sc_rpc_msg *hdr;
> int ret;
> + int i;
>
> if (WARN_ON(!sc_ipc || !msg))
> return -EINVAL;
> @@ -212,6 +214,13 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void
> *msg, bool have_resp)
> mutex_lock(&sc_ipc->lock);
> reinit_completion(&sc_ipc->done);
>
> + /* Set the indexes for the reception chans */
> + for (i = SCU_MU_TX_CHAN_NUM; i < SCU_MU_CHAN_NUM; i++) {
> + struct imx_sc_chan *sc_chan = &sc_ipc->chans[i];
> +
> + sc_chan->rx_pos = sc_chan->idx;
> + }
> +
> if (have_resp) {
> sc_ipc->msg = msg;
> saved_svc = ((struct imx_sc_rpc_msg *)msg)->svc;
> --
> 2.7.4
next prev parent reply other threads:[~2020-07-21 1:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 9:06 [PATCH 0/7] Add support of SECVIO from SNVS on iMX8q/x franck.lenormand
2020-07-20 9:06 ` [PATCH 1/7] firmware: imx: scu-rm: Add Resource Management APIs franck.lenormand
2020-07-21 1:24 ` Peng Fan
2020-07-20 9:06 ` [PATCH 2/7] firmware: imx: scu: Support reception of messages of any size franck.lenormand
2020-07-21 1:25 ` Peng Fan [this message]
2020-07-20 9:06 ` [PATCH 3/7] firmware: imx: scu-seco: Add SEcure Controller APIS franck.lenormand
2020-07-20 9:06 ` [PATCH 4/7] firmware: imx: scu-irq: Add API to retrieve status of IRQ franck.lenormand
2020-07-20 9:06 ` [PATCH 5/7] dt-bindings: firmware: imx-scu: Add SECVIO resource franck.lenormand
2020-07-20 9:06 ` [PATCH 6/7] dt-bindings: arm: imx: Documentation of the SC secvio driver franck.lenormand
2020-07-20 9:06 ` [PATCH 7/7] soc: imx8: Add the SC SECVIO driver franck.lenormand
2020-07-20 14:06 ` kernel test robot
2020-07-20 21:21 ` kernel test robot
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=DB6PR0402MB27609873F3C0183D022674A088780@DB6PR0402MB2760.eurprd04.prod.outlook.com \
--to=peng.fan@nxp.com \
--cc=abel.vesa@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=anson.huang@nxp.com \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.com \
--cc=franck.lenormand@oss.nxp.com \
--cc=kernel@pengutronix.de \
--cc=leonard.crestez@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rempel-privat.de \
--cc=qiangqing.zhang@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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;
as well as URLs for NNTP newsgroup(s).