From patchwork Wed Aug 16 17:19:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9904465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A8FD600CA for ; Wed, 16 Aug 2017 17:52:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69D58287C3 for ; Wed, 16 Aug 2017 17:52:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E7C928A3D; Wed, 16 Aug 2017 17:52:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D21A6287C3 for ; Wed, 16 Aug 2017 17:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+G6+IP5G791/Hl514APXH8+beETN4Pse1HeGxBzr6nM=; b=ebu2ojGArdEjeJvGrIYXb+jiLu 88ZkuKUZzTc+oU6kJHBIdpSMz98yvVdZ2LQpnnon9cLqZnea+0OlSGs0AdjiHONqegvEH36S6pKIJ Ko5qYAYS3QAbEUrN8tzz+kXf+eII4Snu8R5d5K9LCKx/EMlgDdHu5AnrX3pEud2ZuoHxyEmYqxlMY 24CS+nHjBiU6qxm7/KWJDT0wgYUN4AFDaaBWUQ+CHDJeM68xBTaRAzQ7D+/fD/UWWK4N8CiMc9Nh6 GEEUvb0jEeIOcIrB9g8UKQ+b356TG1X5fyjoXdbt2Rb0AsQd2pFhUE/lVNMm899jewt2cJp6F9U2j DVsYdV2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1di2UO-0006PK-8f; Wed, 16 Aug 2017 17:52:20 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1di2SJ-0003ys-EX for linux-arm-kernel@bombadil.infradead.org; Wed, 16 Aug 2017 17:50:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zkFq/Tlo9ox5ErdiV/LWK8bJuF4wDYQzT/QQYxbSd48=; b=RirTHxB4EYEc9pb6sbFBIE4jO PTdfxRgJPVfJcXdyL+IMRw5YdT1xmRr0pDjudbXs/qjrDMWfXoPKVw6WxtHN8u3+CEw7mecrSM51D HVHMfRds8gDr+ui0KM0Qthtzq6S8EB5dQFhZFRsiC48BCfFXY+L27AIiS38Kx+xM0GOXG3+N/s5x9 4EZ+Z5RtG2g4DENL8v47XzWv4/qIAvzZEwsep/KFPzoaWRupsCm80cyiQ2Ix+DFZqyv7mGL1cwAM9 dJlxJaDDGNMWnA63n1fj9K3pj8pidifTbupBcFpi66QG/RhM0VuLFUZIlchbV9yiLrx/Ojjfbwbc0 MFnso9PCw==; Received: from smtp.codeaurora.org ([198.145.29.96]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1di207-0005bw-B5 for linux-arm-kernel@lists.infradead.org; Wed, 16 Aug 2017 17:21:04 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9728A6073F; Wed, 16 Aug 2017 17:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502904035; bh=VigCOJTrMvODmLr64HFIH8MMm+aZ84vsi8mhP9jASMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fDzbhofDrgEwKwhwyJPpN3AiAXMfWQ9bsrvvqm5WJL9zzmdFRRxWK59ew8zc6vVti S2M0zRZYbBHkd3oA2Pz2gXJQ5aZE08kmeUOKibYLRv7FdJyB2cGHkkAbljl6i9A0fM AA5m6VgoLldBa+UAudFxjq4KMIS0/lomk2T8jXxI= Received: from srichara-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0460C60376; Wed, 16 Aug 2017 17:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502904016; bh=VigCOJTrMvODmLr64HFIH8MMm+aZ84vsi8mhP9jASMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ODKg3Cg6bPGxXlmb86zz2gnSO0bxDgV65zcWwbm7Q97iEzWXz2mzZcNwNW4cV5uGq gSEhMX4vSzgE84hdCmYKQSiQoTrsRkt5xgOmtbTIhJuLy2tjLHVzLXY6M8lO7D5B3N 4t4aj6Vfw5rMpgln2mDoCwRiq5qoJdXGOAXCsb4g= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0460C60376 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sricharan@codeaurora.org From: Sricharan R To: ohad@wizery.com, bjorn.andersson@linaro.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 16/18] rpmsg: glink: Use the intents passed by remote Date: Wed, 16 Aug 2017 22:49:09 +0530 Message-Id: <1502903951-5403-17-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502903951-5403-1-git-send-email-sricharan@codeaurora.org> References: <1502903951-5403-1-git-send-email-sricharan@codeaurora.org> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sricharan@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP While sending data, use the remote intent id buffer of suitable size that was passed by remote previously. Signed-off-by: Sricharan R Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 738303e..7b43adc 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1103,19 +1103,50 @@ static int __qcom_glink_send(struct glink_channel *channel, void *data, int len, bool wait) { struct qcom_glink *glink = channel->glink; + struct glink_core_rx_intent *intent = NULL; + struct glink_core_rx_intent *tmp; + int iid = 0; struct { struct glink_msg msg; __le32 chunk_size; __le32 left_size; } __packed req; + int ret; + unsigned long flags; + + if (!glink->intentless) { + if (!intent) { + spin_lock_irqsave(&channel->intent_lock, flags); + idr_for_each_entry(&channel->riids, tmp, iid) { + if (tmp->size >= len && !tmp->in_use) { + tmp->in_use = true; + intent = tmp; + break; + } + } + spin_unlock_irqrestore(&channel->intent_lock, flags); + + /* We found an available intent */ + if (!intent) + return -EBUSY; + } + + iid = intent->id; + } req.msg.cmd = cpu_to_le16(RPM_CMD_TX_DATA); req.msg.param1 = cpu_to_le16(channel->lcid); - req.msg.param2 = cpu_to_le32(channel->rcid); + req.msg.param2 = cpu_to_le32(iid); req.chunk_size = cpu_to_le32(len); req.left_size = cpu_to_le32(0); - return qcom_glink_tx(glink, &req, sizeof(req), data, len, wait); + ret = qcom_glink_tx(glink, &req, sizeof(req), data, len, wait); + + /* Mark intent available if we failed */ + if (ret) + intent->in_use = false; + + return ret; } static int qcom_glink_send(struct rpmsg_endpoint *ept, void *data, int len)