From patchwork Thu Jul 2 08:21:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 192198 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1230978ilg; Thu, 2 Jul 2020 01:23:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQPRHpUuJj3AY/Dkh7eZxSXTZy9/KE6eAt5GG7hpNY1BF6BFFk7E0hU4RLtIu2QcEsdZsJ X-Received: by 2002:a17:907:1059:: with SMTP id oy25mr28324921ejb.90.1593678238810; Thu, 02 Jul 2020 01:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593678238; cv=none; d=google.com; s=arc-20160816; b=Tutapb5J8sEcP+HmsOGBCZgPx4GDEllfkn01CRpp/qR+7ivwnAKQRQLwwM61irRCJm 42WwbL8sl1Fdghw9UWJ92Q9LY+WGBEneVneZxXk5Al1EjgSSRZxCYv8TOZoxlN+Ubwgt 7/uAZepe1BCaOU9cImnSP5JNK0DnkGOgKeTxHdFuakid0jJB2xbcTpqHtAizkvMae2po TrXOC/PvybZdu9wNmE+/7pKwhRkiCCLDhpPPeFGMOfcy+wR+ai2dAOHGmcemNzPvOGWn UNzJ3V/drMTV9to3TIVTOCC2IcD16Y6De5/qyUq74yLBfTTqeXwSyXufDIqNv+QtLvZJ VDCQ== 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=CS+thz+JLeQ+1cARnXdSS/vj2S+D98DeKs94ynS4udE+dm4m9R6ex082mB+GKUu+RY GFYf5txcUmlHgxsHwEHJbPCTANZE4Boyk0cn2CWsUE95TdodO2vEdFr10xYSFMTUOhL+ +F58OEzErLtk76DxhRmnuR+DLqBcKtocqMeZZcX8qj4SUn3nHBqiLN2MQwFvstbZ1yK9 uqSJyeucpEMqaytSHR7v4NdKXO6VkiV7yC1zF4gVZEbrSuFbsODOH81kfI01esFV6pcY WZQXJnZuRldSDRjqqVFjaNBWRidDHnU4u5ssKE37WGy8ZtQiTA29qhrvpJRslAg2cIc8 uFrw== 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 netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 n1si5296677edy.409.2020.07.02.01.23.58; Thu, 02 Jul 2020 01:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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 netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S1728669AbgGBIXf (ORCPT + 9 others); Thu, 2 Jul 2020 04:23:35 -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 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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(-) -- 2.17.1 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)