Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1288295ybt; Thu, 2 Jul 2020 01:28:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEv0+ZOWSUmYDBAylsafgZsw2svvdvKruone6ueTCu18JhT22TvnpzcyV/0w1JR1Nb7jud X-Received: by 2002:a50:931e:: with SMTP id m30mr34794193eda.341.1593678495767; Thu, 02 Jul 2020 01:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593678495; cv=none; d=google.com; s=arc-20160816; b=aGhhi3Rs9skUDdN/F5508vlv1TNrSp8wllmDZcPYUkG+rj39Uxe8mmYV8pqaNnxEyT Wu2nlI5WQSbbrxzN0Pndtid/lleCgfJHtipJnrDAqPm8BTYcxu3q/GATns/d+fNjkF37 M22+o7SnP9ciLF7pQsXpuvTUYErPhhpS1wNLost31qV+1xeBGgU/SLiNB5xzKWLTODa0 zH1A3wULJLccN2/FG/x6vYUwNUD2b587RazRHqraMbKNtu9CW0gCQtSvllB5KJSNVgPj OxdSmuuUgL7Hn71nMmuoD91WhO9wHosFeZ3c7QnczEghrqK+O3dSl2YmUMkRQkAtCuJm ZmDw== 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=eGNA5rrG1NuvNIA1EI0NeBso4lYApfm4ghwzOOSXghqCoxTbkMQIJgAPSnzGKLqt9q wePpbUaYFORqQca40EOUi8jMLxC3B+BCzLMXdn1E5nkBlOUk1GkJpqWTD1QsfdQPRYLW EMtnx5IM8t5SDKNROXmSSm3SaWDCjnucejzsLuPgN5aXyDL2x8Ws/lVBB5lhAkHs5lP5 4BIYxP/bowOvA4J8JsI4ChR6/1D3VJREqk3DRW0UTw82Ias1MsjoH+l7OtaBcTUvcOoY CXJqXPKU/+bxNWSTrobBcMnqxLj4aopQg9lodTsUJ4SDjcJvAvqMFr6VFurF21cmqwvw Cd1A== 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 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 g9si5639008eds.291.2020.07.02.01.27.52; Thu, 02 Jul 2020 01:28:15 -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=hKh4Ycc0; 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 S1728755AbgGBIZC (ORCPT + 99 others); Thu, 2 Jul 2020 04:25:02 -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 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 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(-) 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"); } -- 2.17.1