From patchwork Wed Aug 16 17:19:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9904353 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 E7F776038C for ; Wed, 16 Aug 2017 17:24:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF4DE28A26 for ; Wed, 16 Aug 2017 17:24:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3ED428A2A; Wed, 16 Aug 2017 17:24:36 +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 58FED28A26 for ; Wed, 16 Aug 2017 17:24:36 +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=H2FLP+XGWTvaJxfeqkLBdAyBtLFjGR//OsLYFCIIyyo=; b=lAMdu7Uun/hzf8fcqJ6cY68BZ6 rcgxmoUI5uTr8Ks6jfZA+eocgDNVWh+akg5i45fAM3bRwenXj3dqScxtyUNXRFB2pIbeDsFIdQIsy ZwQddAk0DXPj3htgdVGuoHrCx/PBGVQTzkNW71CN/Y6jy1+neN6v8pSrDgOsL8aYjZ+F6vsEAF8fI IqSwe5Cr4sSDjgm2/eGierb9qFuOz7QsdM1UkQW6B3YKB74y8z9XdtqcMnLiqqxEPIcKuWzgp6TtS BAkHQkWjPNN6ofUsPbQ4G058YGtUa4/FHDKrE9OoFSAnjHNptSL1sCup4nAeelUwnzxUxehaAtQru ylFhK/1w==; 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 1di23Q-0006X0-T5; Wed, 16 Aug 2017 17:24:28 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1di20G-0004bI-0l for linux-arm-kernel@lists.infradead.org; Wed, 16 Aug 2017 17:21:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5F60060850; Wed, 16 Aug 2017 17:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502904051; bh=ZqeVbzwLaqxzCDI1DeNIPTZQ7zf8pFyLDu6swaiJUb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f95PdAf+ReRjawTROj+0T28w03fnw+kO3/S62GGGpvHD8/8XR3SHwfYlJy5Y7dHnH fjWc4ndiTFJ37DQQp9+SG5KKAbDg8DLl66tn010PDMRPQp37jJxaMMbBvq3sMFDm4p MaxZpYuvw6uUEgbBnWIoZ7Y8kbh/YKR3nXsiDJx8= 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 1C9A260452; Wed, 16 Aug 2017 17:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502904022; bh=ZqeVbzwLaqxzCDI1DeNIPTZQ7zf8pFyLDu6swaiJUb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYBhZVxNvOaL1i6d6TO8yPbkGlDD3DnbPG/gZM1xsPM4rlUr2VikCO99tonSA7k1S fthHj3UVrCeO8jBi1SMYNjOc9K5b/cx2STtzezOSC+n71x4EOvQp9Lq2Q42ozMdDAX BvO8zH6QgksMtdxV4WenmC+XtBujFTppsbqYDQYA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1C9A260452 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 18/18] rpmsg: glink: Handle remote rx done command Date: Wed, 16 Aug 2017 22:49:11 +0530 Message-Id: <1502903951-5403-19-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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170816_102112_349093_3169EE7A X-CRM114-Status: GOOD ( 10.92 ) 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 Once the remote side sends a rx done ack, check for the intent reuse information from it and suitably discard or reuse the remote passed intent buffers. Signed-off-by: Sricharan R Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index cfacf4d..870bff6 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -647,6 +647,40 @@ static int qcom_glink_advertise_intent(struct qcom_glink *glink, return intent; } +static void qcom_glink_handle_rx_done(struct qcom_glink *glink, + u32 cid, uint32_t iid, + bool reuse) +{ + struct glink_core_rx_intent *intent; + struct glink_channel *channel; + unsigned long flags; + + spin_lock_irqsave(&glink->idr_lock, flags); + channel = idr_find(&glink->rcids, cid); + spin_unlock_irqrestore(&glink->idr_lock, flags); + if (!channel) { + dev_err(glink->dev, "invalid channel id received\n"); + return; + } + + spin_lock_irqsave(&channel->intent_lock, flags); + intent = idr_find(&channel->riids, iid); + + if (!intent) { + spin_unlock_irqrestore(&channel->intent_lock, flags); + dev_err(glink->dev, "invalid intent id received\n"); + return; + } + + intent->in_use = false; + + if (!reuse) { + idr_remove(&channel->riids, intent->id); + kfree(intent); + } + spin_unlock_irqrestore(&channel->intent_lock, flags); +} + /** * glink_core_rx_cmd_remote_rx_intent_req() - Receive a request for rx_intent * from remote side @@ -955,6 +989,14 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data) case RPM_CMD_INTENT: qcom_glink_handle_intent(glink, param1, param2, avail); break; + case RPM_CMD_RX_DONE: + qcom_glink_handle_rx_done(glink, param1, param2, false); + qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8)); + break; + case RPM_CMD_RX_DONE_W_REUSE: + qcom_glink_handle_rx_done(glink, param1, param2, true); + qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8)); + break; case RPM_CMD_RX_INTENT_REQ_ACK: qcom_glink_handle_intent_req_ack(glink, param1, param2); qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));