All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rpmsg: virtio: set dst address on first message received
@ 2022-03-15 15:38 Arnaud Pouliquen
  2022-03-15 22:47 ` kernel test robot
  2022-05-06 17:12 ` Mathieu Poirier
  0 siblings, 2 replies; 5+ messages in thread
From: Arnaud Pouliquen @ 2022-03-15 15:38 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: linux-remoteproc, linux-kernel, linux-stm32, arnaud.pouliquen

when a rpmsg channel has been locally created 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)

Implement same strategy than the open-amp library:
On the reception of the first message, 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@foss.st.com>

---
Remark:
An alternative (or a complement?) could be to add a NS bind/unbind in
the NS announcement channel (in rpmsg_ns.c).
This would allow the local and/or the remote processor to inform the
remote side the the service announced in bound.
---
 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 3ede25b1f2e4..99d2119cc164 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -708,6 +708,7 @@ static ssize_t virtio_rpmsg_get_mtu(struct rpmsg_endpoint *ept)
 static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
 			     struct rpmsg_hdr *msg, unsigned int len)
 {
+	struct rpmsg_device *rpdev;
 	struct rpmsg_endpoint *ept;
 	struct scatterlist sg;
 	bool little_endian = virtio_is_little_endian(vrp->vdev);
@@ -746,6 +747,15 @@ static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
 	mutex_unlock(&vrp->endpoints_lock);
 
 	if (ept) {
+		rpdev = ept->rpdev;
+		if (rpdev->ept == ept && rpdev->dst == RPMSG_ADDR_ANY) {
+			/*
+			 * First message received from the remote side on the default endpoint,
+			 * update channel destination address.
+			 */
+			rpdev->dst = msg->src;
+		}
+
 		/* make sure ept->cb doesn't go away while we use it */
 		mutex_lock(&ept->cb_lock);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-10 15:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 15:38 [PATCH] rpmsg: virtio: set dst address on first message received Arnaud Pouliquen
2022-03-15 22:47 ` kernel test robot
2022-05-06 17:12 ` Mathieu Poirier
2022-05-09  9:18   ` Arnaud POULIQUEN
2022-05-10 14:45     ` Mathieu Poirier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.