From patchwork Thu Aug 24 07:21:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9919213 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 AC5AA60353 for ; Thu, 24 Aug 2017 07:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C95628A43 for ; Thu, 24 Aug 2017 07:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 916BC28A59; Thu, 24 Aug 2017 07:24:56 +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 D848B28A43 for ; Thu, 24 Aug 2017 07:24:55 +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=g/XSQiigWCAzrlzRyry/hWIq8zBfd3G5HbA9BPy14i4=; b=hDg8itutc1tB0nSJO0PVCTn18J k/YLB1NMIjZ8/Kj6jFD1MRazcsBTivM/KW4B4IbpBWmhW0CnC2dfi9ZTH147xJJpWzjwVnAMaN8I2 InnARk6tBl+E3xiigkBFjbZOnia/fGgZwUnjSsiJvIkkklF1mFlSoGNSyeezSh7N3B1yJNjxHBkrr G3UO/dCk2th0963/mWHQSjq/pKpjdoBGxug9clnVtMoovapZv3uM0d3hhE943pcFyVBbCoqrMfVV5 bDsVhuDIJnup23ioY1J9F/Y5LuKcPo6CKTl1RuGnUwx4aKyQaGuzTmyYW9lvcGYoXm9F13YWMU21G /Ku3Jn7Q==; 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 1dkmVW-0001o7-4S; Thu, 24 Aug 2017 07:24:50 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkmTm-0008Sl-Nk for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2017 07:23:50 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5389A607C5; Thu, 24 Aug 2017 07:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559362; bh=jtmewkS7E9MkbsHtilP3sn8kZ044UDNL1oTrABMjmcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NqRV8bZI+5Q65m/6S62uRa9xtz9q1BQWbIEbjYg7vtVgMvUubt3X+7/iVASDKqIZ7 336vM5M2BIZAc7MWKMKKO1oF1eOq3xTCbYsT0JZl31xv7OzjahKVXNJF/ogm4zVl2X KHgXH/eKqkloSNVO5FyDbQg0MyMjqyiuJhN8g+7g= 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 928F96074A; Thu, 24 Aug 2017 07:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559346; bh=jtmewkS7E9MkbsHtilP3sn8kZ044UDNL1oTrABMjmcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z331l9lZzAmWcZLvh+KE5KAf2mQLDdPxbkfZ6x6H8ugOtLawsQSgkHY95D6hjEtcN +7IB7yQlvR6kdDUIF41BBR2gzOG4kcYJDOYe2fCWatwHl1KQmmYJo8tcMTV2D4jN0n RlopBTo6DUAji7rq4pFG/LjIhv95tD0NLrp5XUfg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 928F96074A 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 10/20] rpmsg: glink: Add support for transport version negotiation Date: Thu, 24 Aug 2017 12:51:32 +0530 Message-Id: <1503559302-3744-11-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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170824_002303_788010_32166940 X-CRM114-Status: GOOD ( 18.11 ) 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 G-link supports a version number and feature flags for each transport. A combination of the version number and feature flags enable/disable: (*) G-Link software updates for each edge (*) Individual features for each edge Endpoints negotiate both the version and the supported flags when the transport is opened and they cannot be changed after negotiation has been completed. Each full implementation of G-Link must support a minimum of the current version, the previous version, and the base negotiation version called v0. Signed-off-by: Sricharan R Signed-off-by: Bjorn Andersson Acked-by: Arun Kumar Neelakantam --- drivers/rpmsg/qcom_glink_native.c | 75 ++++++++++++++++++++++++++++++++++++--- drivers/rpmsg/qcom_glink_native.h | 5 +++ drivers/rpmsg/qcom_glink_rpm.c | 4 ++- drivers/rpmsg/qcom_glink_smem.c | 1 + 4 files changed, 79 insertions(+), 6 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 9a58925..777ac6b 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -31,6 +31,7 @@ #include "qcom_glink_native.h" #define GLINK_NAME_SIZE 32 +#define GLINK_VERSION_1 1 #define RPM_GLINK_CID_MIN 1 #define RPM_GLINK_CID_MAX 65536 @@ -94,6 +95,9 @@ struct qcom_glink { struct mutex idr_lock; struct idr lcids; struct idr rcids; + unsigned long features; + + bool intentless; }; enum { @@ -256,8 +260,8 @@ static int qcom_glink_send_version(struct qcom_glink *glink) struct glink_msg msg; msg.cmd = cpu_to_le16(RPM_CMD_VERSION); - msg.param1 = cpu_to_le16(1); - msg.param2 = cpu_to_le32(GLINK_FEATURE_INTENTLESS); + msg.param1 = cpu_to_le16(GLINK_VERSION_1); + msg.param2 = cpu_to_le32(glink->features); return qcom_glink_tx(glink, &msg, sizeof(msg), NULL, 0, true); } @@ -267,8 +271,8 @@ static void qcom_glink_send_version_ack(struct qcom_glink *glink) struct glink_msg msg; msg.cmd = cpu_to_le16(RPM_CMD_VERSION_ACK); - msg.param1 = cpu_to_le16(1); - msg.param2 = cpu_to_le32(0); + msg.param1 = cpu_to_le16(GLINK_VERSION_1); + msg.param2 = cpu_to_le32(glink->features); qcom_glink_tx(glink, &msg, sizeof(msg), NULL, 0, true); } @@ -362,6 +366,63 @@ static void qcom_glink_send_close_ack(struct qcom_glink *glink, qcom_glink_tx(glink, &req, sizeof(req), NULL, 0, true); } +/** + * qcom_glink_receive_version() - receive version/features from remote system + * + * @glink: pointer to transport interface + * @r_version: remote version + * @r_features: remote features + * + * This function is called in response to a remote-initiated version/feature + * negotiation sequence. + */ +static void qcom_glink_receive_version(struct qcom_glink *glink, + u32 version, + u32 features) +{ + switch (version) { + case 0: + break; + case GLINK_VERSION_1: + glink->features &= features; + /* FALLTHROUGH */ + default: + qcom_glink_send_version_ack(glink); + break; + } +} + +/** + * qcom_glink_receive_version_ack() - receive negotiation ack from remote system + * + * @glink: pointer to transport interface + * @r_version: remote version response + * @r_features: remote features response + * + * This function is called in response to a local-initiated version/feature + * negotiation sequence and is the counter-offer from the remote side based + * upon the initial version and feature set requested. + */ +static void qcom_glink_receive_version_ack(struct qcom_glink *glink, + u32 version, + u32 features) +{ + switch (version) { + case 0: + /* Version negotiation failed */ + break; + case GLINK_VERSION_1: + if (features == glink->features) + break; + + glink->features &= features; + /* FALLTHROUGH */ + default: + qcom_glink_send_version(glink); + break; + } +} + static int qcom_glink_rx_defer(struct qcom_glink *glink, size_t extra) { struct glink_defer_cmd *dcmd; @@ -909,9 +970,10 @@ static void qcom_glink_work(struct work_struct *work) switch (cmd) { case RPM_CMD_VERSION: - qcom_glink_send_version_ack(glink); + qcom_glink_receive_version(glink, param1, param2); break; case RPM_CMD_VERSION_ACK: + qcom_glink_receive_version_ack(glink, param1, param2); break; case RPM_CMD_OPEN: qcom_glink_rx_open(glink, param1, msg->data); @@ -932,6 +994,7 @@ static void qcom_glink_work(struct work_struct *work) } struct qcom_glink *qcom_glink_native_probe(struct device *dev, + unsigned long features, struct qcom_glink_pipe *rx, struct qcom_glink_pipe *tx) { @@ -947,6 +1010,8 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, glink->tx_pipe = tx; glink->rx_pipe = rx; + glink->features = features; + mutex_init(&glink->tx_lock); spin_lock_init(&glink->rx_lock); INIT_LIST_HEAD(&glink->rx_queue); diff --git a/drivers/rpmsg/qcom_glink_native.h b/drivers/rpmsg/qcom_glink_native.h index 197bb9d..456ec79 100644 --- a/drivers/rpmsg/qcom_glink_native.h +++ b/drivers/rpmsg/qcom_glink_native.h @@ -14,6 +14,10 @@ #ifndef __QCOM_GLINK_NATIVE_H__ #define __QCOM_GLINK_NATIVE_H__ +#define GLINK_FEATURE_INTENT_REUSE BIT(0) +#define GLINK_FEATURE_MIGRATION BIT(1) +#define GLINK_FEATURE_TRACER_PKT BIT(2) + struct qcom_glink_pipe { size_t length; @@ -31,6 +35,7 @@ struct qcom_glink_pipe { struct qcom_glink; struct qcom_glink *qcom_glink_native_probe(struct device *dev, + unsigned long features, struct qcom_glink_pipe *rx, struct qcom_glink_pipe *tx); void qcom_glink_native_remove(struct qcom_glink *glink); diff --git a/drivers/rpmsg/qcom_glink_rpm.c b/drivers/rpmsg/qcom_glink_rpm.c index cc73af0..7d039cd 100644 --- a/drivers/rpmsg/qcom_glink_rpm.c +++ b/drivers/rpmsg/qcom_glink_rpm.c @@ -302,7 +302,9 @@ static int glink_rpm_probe(struct platform_device *pdev) writel(0, tx_pipe->head); writel(0, rx_pipe->tail); - glink = qcom_glink_native_probe(&pdev->dev, &rx_pipe->native, + glink = qcom_glink_native_probe(&pdev->dev, + 0, + &rx_pipe->native, &tx_pipe->native); if (IS_ERR(glink)) return PTR_ERR(glink); diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c index 19179a1..b78874b 100644 --- a/drivers/rpmsg/qcom_glink_smem.c +++ b/drivers/rpmsg/qcom_glink_smem.c @@ -284,6 +284,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent, *tx_pipe->head = 0; glink = qcom_glink_native_probe(dev, + GLINK_FEATURE_TRACER_PKT, &rx_pipe->native, &tx_pipe->native); if (IS_ERR(glink)) { ret = PTR_ERR(glink);