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: 9904329 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 CA59D6038C for ; Wed, 16 Aug 2017 17:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3506205FC for ; Wed, 16 Aug 2017 17:23:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A843C285F2; Wed, 16 Aug 2017 17:23:30 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6106F205FC for ; Wed, 16 Aug 2017 17:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752514AbdHPRU2 (ORCPT ); Wed, 16 Aug 2017 13:20:28 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53682 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751893AbdHPRUY (ORCPT ); Wed, 16 Aug 2017 13:20:24 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CD1296084E; 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=1502904023; bh=VigCOJTrMvODmLr64HFIH8MMm+aZ84vsi8mhP9jASMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bM3sGb9Vv59dfXpWh/twSoENMlrJmCOMyvKt7UWuGDD23bwfAYZCvYrubuds6qtzp tfKaGgIje+T6GX89CuuMsbXDth2sO+rXFaIYv7gMM800cTPrTgRwrvtXuVe0xcmVVe OhBya9dxgLD1YYzGDFf8V5Nv4Lc7iEwZZem53dIM= 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 Cc: sricharan@codeaurora.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> Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.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)