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] [thread-next>] [day] [month] [year] [list]
Message-Id: <1595235977-106241-3-git-send-email-franck.lenormand@oss.nxp.com>
Date:   Mon, 20 Jul 2020 11:06:12 +0200
From:   franck.lenormand@....nxp.com
To:     shawnguo@...nel.org, s.hauer@...gutronix.de, festevam@...il.com
Cc:     franck.lenormand@....nxp.com, kernel@...gutronix.de,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-imx@....com, aisheng.dong@....com, abel.vesa@....com,
        Anson.Huang@....com, linux@...pel-privat.de,
        leonard.crestez@....com, daniel.baluta@....com,
        qiangqing.zhang@....com, peng.fan@....com
Subject: [PATCH 2/7] firmware: imx: scu: Support reception of messages of any size

From: Franck LENORMAND <franck.lenormand@....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@....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@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ