Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp912123pxp; Wed, 16 Mar 2022 21:04:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4l6jQ2ls3lOloVMs27hHYCAN5Rs+YXsXzXFMwUEIJJQgA54zQj0dOm0l4NZUzmVVVC5XS X-Received: by 2002:a17:90a:de90:b0:1c6:625f:d976 with SMTP id n16-20020a17090ade9000b001c6625fd976mr3063135pjv.218.1647489848648; Wed, 16 Mar 2022 21:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647489848; cv=none; d=google.com; s=arc-20160816; b=eRomDlY4tEEJEKomkBfhIwzR90N40GFTI8tg85dI4/q3SBcZVfE6lq+PD3GiGV9B+W Of02PG0iQYl8a67NNLsH+xV+817P2VX+k7WfVnNiyO/QGdebE+KrqeBrE/30cGmsgIAz i2x+nIXGwgyicmikeg75E/60HGDRcMcgX3NtFESj56o6nGLr7p1yDQNFCo8eGXR3Yj4N tVoFz5Uwk98k7quxB77N3/6PevsQJ6kIZUV1W3OyQxr3SYIu+KaxQKv7gOVCF+tyy26k 04A2EaC7x3ggf6C9LxJ5FgiJCU/ytglCnK8dVie0svpvHzoVgOvw0TlIFwY2m3NkvXj6 Q30g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=E0dTihjAMXoQuyyzHoX/vtLpZBobxaDs7n81eZr8XJQ=; b=kCvAKIOwceprxWgSX9xpuzFWyW/S6wLS0ivLgUKqB79L9iyjskqI9xMacWor9t6tgX K8eDQ9YMTc9c+f+03gmHJuaFQrynPQaPWY7IH2eacuwIrP1H82t4LDJuBnyZI1ZsfJzJ Dm17TyWV6r/F1YbvyEuCK0qWmi0H9AMD3T2Dv00dvJgz59xlsv/SNfSJuqyPBZn1kVoD +A6T89+FbEPJrPNcOdj838YkXKZo/zX7SetDWg7PHJZVC96VoLBd06DJJZFhSTwl9GuJ fe2Q7hgR9pHEEAs9qDa5MBVh+3Sfy1PyngyvDxcay8TQsSfDkMqVtKSAQ0dPPNl2sH4W 6FUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=cHpAoqzz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e11-20020a63ee0b000000b003816043f0casi894170pgi.703.2022.03.16.21.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 21:04:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=cHpAoqzz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7581291AEB; Wed, 16 Mar 2022 20:46:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349676AbiCOPkk (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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