[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220520082940.2984914-11-arnaud.pouliquen@foss.st.com>
Date: Fri, 20 May 2022 10:29:40 +0200
From: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>
To: Bjorn Andersson <bjorn.andersson@...aro.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>
CC: <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-stm32@...md-mailman.stormreply.com>,
Deepak Kumar Singh <quic_deesin@...cinc.com>,
Chris Lew <quic_clew@...cinc.com>,
<arnaud.pouliquen@...s.st.com>
Subject: [RFC PATCH 10/10] rpmsg: virtio: Set default dst address on flow control
When a rpmsg channel has been created locally with a destination address
set to RPMSG_ADDR_ANY, a name service announcement message is sent to
the remote side. Then the destination address is never updated, making it
impossible to send messages to the remote.
An example of kernel trace observed:
rpmsg_tty virtio0.rpmsg-tty.29.-1: invalid addr (src 0x1d, dst 0xffffffff)
The flow control can be used to set the rpmsg device address.
If the destination address is RPMSG_ADDR_ANY, then set it to
address of the remote endpoint that send the message.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>
---
This patch is an alternative of the fix proposed in patch [1]
[1] https://lore.kernel.org/lkml/20220316153001.662422-1-arnaud.pouliquen@foss.st.com/
---
drivers/rpmsg/virtio_rpmsg_bus.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index a8e60ca4cd08..0337a07e278c 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -393,6 +393,16 @@ static int virtio_rpmsg_remote_flowctrl(struct rpmsg_device *rpdev,
if (!ept)
return -EINVAL;
+ /*
+ * If the endpoint is the rpmsg device default one, then it can not be yet associated
+ * to the remote endpoint. This can occur if a ns announcement message has been
+ * previously sent to the remote side.
+ * Update the rpmsg device destination address in such case to store the remote
+ * address as default remote endpoint.
+ */
+ if (rpdev->ept == ept && rpdev->dst == RPMSG_ADDR_ANY)
+ rpdev->dst = __rpmsg32_to_cpu(virtio_is_little_endian(vrp->vdev), chinfo->src);
+
/* Make sure ept->sig_cb doesn't go away while we use it */
mutex_lock(&ept->cb_lock);
--
2.25.1
Powered by blists - more mailing lists