Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1287152ybt; Thu, 2 Jul 2020 01:25:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6tRe1FgDg6PZVY+oRf2HXw7Lrt5dXEammuCRgpcdLr2StIciRcm2CbWa2OE50g12cBRfs X-Received: by 2002:a17:906:46cd:: with SMTP id k13mr25861877ejs.312.1593678359133; Thu, 02 Jul 2020 01:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593678359; cv=none; d=google.com; s=arc-20160816; b=MEqFTbeJKPqXc86sPUOv51yZg9jSY+TOexjj7VDXvU+h3saZCMpnhqVGUrBaTPAv1m 8BtMWt3wGBNipxgRvn/pdlzP3nvtjN4mnc1GfcmERhnNd6oKPMQ8MBeZHDYSarjU1soA ac3DPX8yTrQNOmPe52MOJtAS7kSKYK5UcXX4K0WFIvLL3CFa6YF5VGom9c6U2cUhHoye s7aoOKMJQzr69qsEEJWSO20yHJ7auyUN7QI1QO9hV8poFZVvnbM4vr08SemNfrxxQNAu h7taUGmApK7CICiEiA/KPXojcBNRiKLXBCuUKF/57N1zN3bvjtyIW9wsQd+e4tLkxm3O cduQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ogem8OEd0B1KK4dvO1xOb9/ggBhFiU5Os5ncLUubhLU=; b=OFPMeDH2nRLpjKcjuZRlCZ5njznsdzlkLjYtZSXdD4q3XzqPk1VOnn1TW9Goj0fEDU eHbVZSIRtL9nHW5p6jCc+bFOL2zAIoq4/Jf3/Dgswarlnshc2GORx/7nj90+guyEdjC6 wDAEIVu8jvBYTQXTAVRAeDsqLdsdyeBCyX0fxhZnznODEmW8nOcAIUbJPfbyq2ctr4Lc 6vNiIogylqle2UcWXr7Py7bU4HoOJJZNa1dXhieRCgfckI7GOmsbJ2kZLsVPtL0Ero6G fik+6orrzBc7TiORx9Vh5qvjx75kgvz5ov5f9oSNNf0BPxuo5WPRFwKAcne9eFpNnkR7 /IKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="HEU/4DXs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si5332200eji.459.2020.07.02.01.25.35; Thu, 02 Jul 2020 01:25:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="HEU/4DXs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbgGBIXe (ORCPT + 99 others); Thu, 2 Jul 2020 04:23:34 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:59596 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbgGBIXa (ORCPT ); Thu, 2 Jul 2020 04:23:30 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0628NL3E082026; Thu, 2 Jul 2020 03:23:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593678201; bh=ogem8OEd0B1KK4dvO1xOb9/ggBhFiU5Os5ncLUubhLU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HEU/4DXsWuzYfdUEEOO77ST1979/soZJPDuJUCzGAvxmewNGEmE4zfLzI7ww5YTzZ m7doXWRZWlJkxYO0tciaPf451IzSjvAlvkTO+hMhshLQfX4smwzZ29wHGD0WEInyd/ 7/CTp/uz2fcR0iBA4D5Z1RVCP0l6gvjPWMmC/1+4= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0628NLlT067307 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 2 Jul 2020 03:23:21 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 2 Jul 2020 03:23:20 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 2 Jul 2020 03:23:21 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0628LiYS006145; Thu, 2 Jul 2020 03:23:15 -0500 From: Kishon Vijay Abraham I To: Ohad Ben-Cohen , Bjorn Andersson , Jon Mason , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Paolo Bonzini , Stefan Hajnoczi , Stefano Garzarella CC: , , , , , , , Subject: [RFC PATCH 16/22] samples/rpmsg: Wait for address to be bound to rpdev for sending message Date: Thu, 2 Jul 2020 13:51:37 +0530 Message-ID: <20200702082143.25259-17-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702082143.25259-1-kishon@ti.com> References: <20200702082143.25259-1-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rpmsg_client_sample can use either virtio_rpmsg_bus or vhost_rpmsg_bus to send messages. In the case of vhost_rpmsg_bus, the destination address of rpdev will be assigned only after receiving address service notification from the remote virtio_rpmsg_bus. Wait for address to be bound to rpdev (rpmsg_client_sample running in vhost system) before sending messages to the remote virtio_rpmsg_bus. Signed-off-by: Kishon Vijay Abraham I --- samples/rpmsg/rpmsg_client_sample.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index 514a51945d69..07149d7fbd0c 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c @@ -57,10 +57,14 @@ static void rpmsg_sample_send_msg_work(struct work_struct *work) struct rpmsg_device *rpdev = idata->rpdev; int ret; - /* send a message to our remote processor */ - ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); - if (ret) - dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); + if (rpdev->dst != RPMSG_ADDR_ANY) { + /* send a message to our remote processor */ + ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); + if (ret) + dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); + } else { + schedule_delayed_work(&idata->send_msg_work, msecs_to_jiffies(50)); + } } static int rpmsg_sample_probe(struct rpmsg_device *rpdev) -- 2.17.1