From patchwork Thu Jul 2 08:21:36 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: 192204 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1231621ilg; Thu, 2 Jul 2020 01:25:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCts/9Jujy+MM3XRHI7MSuZC3Xo/WYnD+HPV6O580Dslfz9xot0YCVixFuHfzZ/53veUU0 X-Received: by 2002:a50:e3c9:: with SMTP id c9mr34531356edm.90.1593678306152; Thu, 02 Jul 2020 01:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593678306; cv=none; d=google.com; s=arc-20160816; b=jHDWaiBMKjdhVYmtth5Dvcof+VHgZ567fYhs7Gb1+j92lvoXekZz1UYgXoFNuF+2hm TaL1kvvVTRjOk80kZPyp6oh19W+9cQFmevpR62Qu6sdNn4dpEYIeNIbjyGGBgxfUF63e F6SBYqHFX4ewVvTOQtsBEQhg9qjutVO8HXNd1zZK+I8aHieFooFYLtNVsjcWg0s4xvcm rmKdDsbHtMwFkgtfzLQmEliJbBIf8Rodr7eC7bRWBIyKfU2ELraWtBkhFIRF6U2jXiWI U5y29qkCQIRDApWr+Yj6V7vcEmFSmmxgzFQf3pXJrKDD9I/ajJe+8gJgNtFWXsh1p2ho MpqQ== 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=z96ye//Mg15JHZ1ndtZxlE33lV8uirQIl1DtUAPpCNk=; b=HJNwEEtBK/PtlGv/BD2h3Hm/IwdFrpzuHyd4MXqovng0QDmRbCixqOHBkcZuw8Zui8 wZ+kmMU5JPMpIUL7m+tiXJ5SaZUPRcURZ/xt31TCftvUcEbQ4ET9ZYTQ0WRVDq/LpH1C bXcUZ4/FbEjUZz43Q0i+980snzUSwpGAaawCLQJn9LnaR+af6b6uewUvvubABH0Bkdcf g3IKdUGzz6cC6RHSJDhiEb2mfkhBBc2OCZsngfHI/xJ3Ocvc2lESnGCK2NklMiRZNq6Y omAJB8bhsttqc/klIRpZqBAzWuAsxZ4dkcRI21y3lMQSJ66jbEhXVCj61lmv8ckCrILE 5HXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hKh4Ycc0; 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 gy14si5338855ejb.313.2020.07.02.01.25.06; Thu, 02 Jul 2020 01:25:06 -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=hKh4Ycc0; 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 S1728556AbgGBIZD (ORCPT + 9 others); Thu, 2 Jul 2020 04:25:03 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:59580 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728529AbgGBIX1 (ORCPT ); Thu, 2 Jul 2020 04:23:27 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0628NGhc082008; Thu, 2 Jul 2020 03:23:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593678196; bh=z96ye//Mg15JHZ1ndtZxlE33lV8uirQIl1DtUAPpCNk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hKh4Ycc0nsKdDPMU7zvoAF1INSmeh72IPvQS5QOFMq4Kc9z2De6UHyUGJQsMmlqry DYgZNo1XEM+w2AaJimrzgI0NKEC9A5VRpDP9utmTyIV6VPFwKtQ/btpKPHG9wxz8/X /BiKQoNwEaAmwJLbq3/wJAlgDVSeBWOF5IKKiAxk= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0628NFj5066600 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 2 Jul 2020 03:23:15 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) 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; Thu, 2 Jul 2020 03:23:15 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE111.ent.ti.com (157.170.170.22) 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:15 -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 0628LiYR006145; Thu, 2 Jul 2020 03:23:10 -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 15/22] samples/rpmsg: Setup delayed work to send message Date: Thu, 2 Jul 2020 13:51:36 +0530 Message-ID: <20200702082143.25259-16-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 Let us not send any message to the remote processor before announce_create() callback has been invoked. Since announce_create() is only invoked after ->probe() is completed, setup delayed work to start sending message to the remote processor. Signed-off-by: Kishon Vijay Abraham I --- samples/rpmsg/rpmsg_client_sample.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index ae5081662283..514a51945d69 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c @@ -20,6 +20,8 @@ module_param(count, int, 0644); struct instance_data { int rx_count; + struct delayed_work send_msg_work; + struct rpmsg_device *rpdev; }; static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, @@ -48,9 +50,21 @@ static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, return 0; } -static int rpmsg_sample_probe(struct rpmsg_device *rpdev) +static void rpmsg_sample_send_msg_work(struct work_struct *work) { + struct instance_data *idata = container_of(work, struct instance_data, + send_msg_work.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); +} + +static int rpmsg_sample_probe(struct rpmsg_device *rpdev) +{ struct instance_data *idata; dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n", @@ -62,18 +76,18 @@ static int rpmsg_sample_probe(struct rpmsg_device *rpdev) dev_set_drvdata(&rpdev->dev, idata); - /* 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); - return ret; - } + idata->rpdev = rpdev; + INIT_DELAYED_WORK(&idata->send_msg_work, rpmsg_sample_send_msg_work); + schedule_delayed_work(&idata->send_msg_work, msecs_to_jiffies(500)); return 0; } static void rpmsg_sample_remove(struct rpmsg_device *rpdev) { + struct instance_data *idata = dev_get_drvdata(&rpdev->dev); + + cancel_delayed_work_sync(&idata->send_msg_work); dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n"); }