From patchwork Thu Aug 24 07:21:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9919357 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 2D50F60327 for ; Thu, 24 Aug 2017 07:49:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E67128B83 for ; Thu, 24 Aug 2017 07:49:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 134D228B99; Thu, 24 Aug 2017 07:49:46 +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 AB04D28B83 for ; Thu, 24 Aug 2017 07:49:45 +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=Np3TZiePa5iJD3vbyqzVb5UhA4P61JdIiwxeoCl6ZEg=; b=PvEvwRDcW+1z/ksHZ/JWfywotS Zv1iPT1LyIwNBQppBJMLnK80G2d5JinzF7jioVwHKPmu+kFyhGVa/eOrgdjogJDUeBeoi8rxh15Yd aOE2XdI2WWtvepD7SKZTNJlA7ytfCN85KaZLUbFxa/JSLxHKfp4V+KXcdmuG8SLwvEOeM/bwng9Vp LT1LSsUTIZTi40E4SwDtZVwv4QK0cVb/qST5OiMKNE1bRoZQT9U6YhWDONcpKa1TJCXvOYLkmAS/F C4AyA1jK/UD/DdODJvMkTouac1FwtDGLuziN/T+59/X78fb/mDJ73BsCTAQRVfCmk0RN128+2iHGf b5OxF1rw==; 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 1dkmtZ-0002L8-Dm; Thu, 24 Aug 2017 07:49:41 +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 1dkmt8-00022b-6s for linux-arm-kernel@bombadil.infradead.org; Thu, 24 Aug 2017 07:49:14 +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=gV8QBfTrfE7XdM2tAOHauXvUF4skLE1KYGnxoDAuXmc=; b=ogcpWfw0x4GbKqOpOTLTwK+Ht vK7I5xl39GgNOnUJzX2uE45Bs1McB1de4H9GdFsp098xgqIP7aybL/C8XMfhNP1evj4u5gtVfjG5W KUK2PLWrS0MqSrzYmMrWtHeaW8F95LdXdrMqm3iom8q+OxaXrTDGW6OMOxDLJ15aut+yv4MyJuWBG JIixaHH1FEfbgk4NXo13RvHXxdMQTS8KeyrwJXd2HzUsGwiFbXeVE5ikptx/RZLKjngwUhHMnB7YL yC/nhinZaLzVCQWhS8iMO9FV0qj021Vng/KF4SxQFYolj/9eKo1RPEGgbwuwcX9lU1Rqo9XsyKwYd 77S8hDwIA==; Received: from smtp.codeaurora.org ([198.145.29.96]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkmU2-0004iu-6x for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2017 07:23:18 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B38F560712; Thu, 24 Aug 2017 07:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559377; bh=4t8M8LbT4HYjuJUwIhxeejj8jfj0OgnphslPSH4/ZPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EnTCfAm8YnBDP/cYkyrK9zczRaQqF01DEKehO06NInJd1PpI0kEoEH88yT1PNYdkG J8CdljIohpv7WcZ9aEsACTZLImi7YLO3cLVBvFtuHlZjhgtpMuyKmPyqPuh2K3WOz2 yzSxXJMth5T4LbGdck6y1s+eq5DrSyvdyhla60X0= 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 42C95607EA; Thu, 24 Aug 2017 07:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559370; bh=4t8M8LbT4HYjuJUwIhxeejj8jfj0OgnphslPSH4/ZPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tpfk4PMhov35DtAjiXyxS7RNEQ2RoSlG8zrV7QeLOdo88ybJueyJpM35PFRm7H3xP L21r+3XeP5d0Kg5hgAx7a3IykS/y1bgc4ZrH1gH2zUtfDtc/N6XIedkLu1p4jCbCH9 5ZaSxu3oleihyqMXnz0oNxOwuaeogPiDSiKFqd9Q= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 42C95607EA 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 v2 18/20] rpmsg: glink: Use the intents passed by remote Date: Thu, 24 Aug 2017 12:51:40 +0530 Message-Id: <1503559302-3744-19-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> 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 d93d651..163c082 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1110,19 +1110,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)