From patchwork Wed Aug 14 13:48:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40FEAC52D7B for ; Wed, 14 Aug 2024 13:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bYz7JCAlrOb2CKWmxYTEOhBPC9PfM5X0hlluBaSf1vw=; b=R3DQp27+jBFrYjWFvqlzYGyXbo YtkTOhNH5x2dI09lQFXOYA7XlPYaIboqsU4Ddsy1XXNpQol7OQiSILqoFuri/+ZcJrYUP/oOBvwTl yQdSAg90Gy1AtTLYK78Skxm2VFvDnG7ONeubkNtuov9HXqg9ISCJp6OmiSOx1DdDR2ZAOQbfHT4V9 E31GmjBIiNLpM+HtDhSdEOqiXwuq+tSkiyIPnYW/qeUfq1c9PBogem8Yc4G8wPImlFFPlJI3860/U coStlfhgHJE5bqowYIQXJVpZ/JrL8nLp3IsufX0wBEZCvm0gDADzjlmyhDf7eeY+dXy9daIFyi27h yCivQXEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seERQ-00000007ACG-14qQ; Wed, 14 Aug 2024 13:53:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seENG-0000000796O-1Z9n for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B89F5FEC; Wed, 14 Aug 2024 06:49:39 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 522433F6A8; Wed, 14 Aug 2024 06:49:13 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:55 +0100 Subject: [PATCH 6/7] firmware: arm_ffa: Add support for FFA_YIELD in direct messaging MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-6-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2597; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=cHY26v9U/Lk2MBCwxFC2dfJwwz2Tg4YJHFlafzsj2dY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXT68la8JDEBbW+9sa3a4Ym5s80JxwNzgkBu b45L2dp8bOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10wAKCRAAQbq8MX7i mDbGD/44X4sLdIsFoTVsYi8ZuiaVhccEvFksYYADQ35J5hf1YPKimN265u9sN4p+EK4z9gb2EtE jptZ7R69C+ufd3xGrKtzu5xJ+XyTt1223JeWa3BJ/72VAl2ynvCZWjelcyOZjoEQKL6M3CGsvIl gReEnMAGgsJg4k9qVUG2LPVrV2ApPv+uLfL9Rz92fYv8nLGTBFSzFnzIUxqEJ+rrCLrUoaiAVcZ smIoIYDdxUEjZCMN7Ofp2Xvfz9GwToz7SFBOnH7G0Wfe0I9wLcMJz4eH/jn0Ij1OE8NxsBujjPJ Py/cYBiIul+hZsxT671Nij1nyF8W/DhzCXDOyHob5VRHO+FxWJdpf8z1jIAVYXnvpsZqI0zOc6C rnrFwtnnBrKvEY+ZWDDyXOsqTpd0y15Lwt7aQntHd4RGlyZ4bKsCOWfww5Y6BsP+K/7xp6XoLP4 0ZSUq31Y3BZfE5kBUcxeUe65FLU1Yp85iANVTpePVI2M0nDQc38hCxAhR0U5OBocycggpeDa48m n1Qt7G/+rg2aGtF+3lGHEyHzqClkj84SrhsU0TwERv7eyThnz9maaHK+PtuKf9nEfX2O50gYD/B gCXNASIcpoimnjd+sfm9Af4KGIVFKsyLLBnWvZYTrIQpRfhEVMUTfpMsyn/G3tjj9Z7wIGkfGi5 KFJyMVqrTe/d0QA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064914_616342_DCEFF7E2 X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Successful completion of both direct messaging function can be indicated through an invocation of FFA_YIELD or GGA_INTERRUPT by the callee. FFA_INTERRUPT indicates that the direct request was interrupted and must be resumed through the FFA_RUN interface which is already done in the driver. FFA_YIELD indicates that the receiver endpoint has transitioned to the blocked runtime state and must be resumed through the FFA_RUN interface. However, the way receiver endpoint gets unblocked is implementation defined. So, the driver just sleeps for 1 - 2ms and issues FFA_RUN. It can return to the caller with FFA_YIELD is the receiver endpoint is still blocked. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 8af41be4b1c1..90102ed7bd18 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -397,6 +398,18 @@ static int ffa_id_get(u16 *vm_id) return 0; } +static inline void ffa_msg_send_wait_for_completion(ffa_value_t *ret) +{ + while (ret->a0 == FFA_INTERRUPT || ret->a0 == FFA_YIELD) { + if (ret->a0 == FFA_YIELD) + fsleep(1000); + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_RUN, .a1 = ret->a1, + }, ret); + } +} + static int ffa_msg_send_direct_req(u16 src_id, u16 dst_id, bool mode_32bit, struct ffa_send_direct_data *data) { @@ -417,10 +430,7 @@ static int ffa_msg_send_direct_req(u16 src_id, u16 dst_id, bool mode_32bit, .a6 = data->data3, .a7 = data->data4, }, &ret); - while (ret.a0 == FFA_INTERRUPT) - invoke_ffa_fn((ffa_value_t){ - .a0 = FFA_RUN, .a1 = ret.a1, - }, &ret); + ffa_msg_send_wait_for_completion(&ret); if (ret.a0 == FFA_ERROR) return ffa_to_linux_errno((int)ret.a2); @@ -482,10 +492,7 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid, invoke_ffa_fn(args, &ret); - while (ret.a0 == FFA_INTERRUPT) - invoke_ffa_fn((ffa_value_t){ - .a0 = FFA_RUN, .a1 = ret.a1, - }, &ret); + ffa_msg_send_wait_for_completion(&ret); if (ret.a0 == FFA_ERROR) return ffa_to_linux_errno((int)ret.a2);