From patchwork Tue Mar 15 15:38:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12781590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A64C7C433F5 for ; Tue, 15 Mar 2022 15:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344745AbiCOPkk (ORCPT ); Tue, 15 Mar 2022 11:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244187AbiCOPkj (ORCPT ); Tue, 15 Mar 2022 11:40:39 -0400 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58FC50E3A; Tue, 15 Mar 2022 08:39:25 -0700 (PDT) Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22FAEtP7004832; Tue, 15 Mar 2022 16:39:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=selector1; bh=E0dTihjAMXoQuyyzHoX/vtLpZBobxaDs7n81eZr8XJQ=; b=cHpAoqzzms1aUAHsRsl3k0YY2FCQ1IklsLnPqkrqOb3M2JgRDEU3ciEpmwIqCd469pII i8/wqCl0CHHjO+yeANyQpELk6N2HOp5kZqhYVRBKG1EBUPkln2Zev464iBfQcJGtC3pm 0gutxpXjc5ZU1XtWDe0gwLuyd62WGqzRMX0BBId1ikFKhxBzQQwpT77kqniFFgf+rxmg Uj+wt+lgJyLteBihfa1M0WQ7JBlgWv5MW9Rv/69Ohdyjytj6UAbZiZXWjo9s2TLXHxTj MJwBDVYu5zZ/42BWmFnNqdih194epNvNSjzDi6ua5OZPRhYH3pot22+vaIElJLWYjwv1 PQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3et63hyfqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Mar 2022 16:39:23 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8CDB110002A; Tue, 15 Mar 2022 16:39:22 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7F91622F7B2; Tue, 15 Mar 2022 16:39:22 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 15 Mar 2022 16:39:22 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , Subject: [PATCH] rpmsg: virtio: set dst address on first message received Date: Tue, 15 Mar 2022 16:38:56 +0100 Message-ID: <20220315153856.3117676-1-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-15_03,2022-03-15_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org 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 Reported-by: kernel test robot --- 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);