From: franck.lenormand@oss.nxp.com
To: shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com
Cc: franck.lenormand@oss.nxp.com, kernel@pengutronix.de,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com,
aisheng.dong@nxp.com, abel.vesa@nxp.com, Anson.Huang@nxp.com,
linux@rempel-privat.de, leonard.crestez@nxp.com,
daniel.baluta@nxp.com, qiangqing.zhang@nxp.com, peng.fan@nxp.com
Subject: [PATCH 2/7] firmware: imx: scu: Support reception of messages of any size
Date: Mon, 20 Jul 2020 11:06:12 +0200 [thread overview]
Message-ID: <1595235977-106241-3-git-send-email-franck.lenormand@oss.nxp.com> (raw)
In-Reply-To: <1595235977-106241-1-git-send-email-franck.lenormand@oss.nxp.com>
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-20 9:06 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 ` franck.lenormand [this message]
2020-07-21 1:25 ` [PATCH 2/7] firmware: imx: scu: Support reception of messages of any size Peng Fan
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=1595235977-106241-3-git-send-email-franck.lenormand@oss.nxp.com \
--to=franck.lenormand@oss.nxp.com \
--cc=Anson.Huang@nxp.com \
--cc=abel.vesa@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.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=peng.fan@nxp.com \
--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).