From patchwork Thu Aug 24 07:21:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9919171 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 3067E60353 for ; Thu, 24 Aug 2017 07:23:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2220928434 for ; Thu, 24 Aug 2017 07:23:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 169D228880; Thu, 24 Aug 2017 07:23: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=-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 9E45228434 for ; Thu, 24 Aug 2017 07:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751708AbdHXHXD (ORCPT ); Thu, 24 Aug 2017 03:23:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36054 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751792AbdHXHXA (ORCPT ); Thu, 24 Aug 2017 03:23:00 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7A9466076E; Thu, 24 Aug 2017 07:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559379; bh=PuvMumRdtm3XRUoznshilb+6Os7CnvMnx6Nofo03loo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VG8uDsoWisJRqnX8220ZwojcB6qgIqaj9zLGQcva0HxVKE86lJypmtT2Ye3fAWGpj z9TDG0UubK44TnTo4HwkOGlq3NoHn4YbNijVwW4VzGaPuZWrBhnGXC+buzoDUy6MZX R/rIA3hn5SNE34EeVSONYicjWqauwuLgmP+qiB5w= 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 52A24607DC; Thu, 24 Aug 2017 07:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559376; bh=PuvMumRdtm3XRUoznshilb+6Os7CnvMnx6Nofo03loo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TwxIt6T3G5AMQHwko4HUOVZykNL98KpbwRFgztfXMKdDTq8+YdTXlhkqeUo5P3bOq aWQ739T4Wh9iLSMtSgRRNw3zdPR3vAKKKQnpQoO0lhtDVZyinYUx4sgbe3usHsdGOX E78oaxNKZ9pCi9lef26ShfnWyT/KOZWV2w8zPogM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 52A24607DC 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 v2 20/20] rpmsg: glink: Handle remote rx done command Date: Thu, 24 Aug 2017 12:51:42 +0530 Message-Id: <1503559302-3744-21-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503559302-3744-1-git-send-email-sricharan@codeaurora.org> References: <1503559302-3744-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 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 54ddb66..08953ca 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -657,6 +657,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); +} + /** * qcom_glink_handle_intent_req() - Receive a request for rx_intent * from remote side @@ -965,6 +999,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));