From patchwork Thu Oct 5 14:44:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13410155 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 A0694E92707 for ; Thu, 5 Oct 2023 14:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: 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=98M25LN/Mvo9UGlB3g3GhdlmtlaaIRcVLT0Bat/4Pl4=; b=nGprvPkkEjXBG4 qU6TdSWnJ5fGUUvkGFEm4Zc2CRaor5KN/yU8kWaMmzBXRBupQrjyHM2/CgxB02gYwKmqYL2W2o1+5 vYu79vK1lMoWOcQOkyclebKNr939M1H03WSt+qybEmiGFuRdNIake5+glhnffc6b4lao1MbS4xWF5 GmGd8WrBG43mvuqykIHIkpcNJ6QZolV+13GeVW+ACfbrzOPxvNPlIjfUP+k1UjNQ6wN+xZSa2hltv 5ZUWl8Y9ap8cSw9Rqa0vE9OKtNKdvS9yaBAfZagQKoybH59cNny6lMTVI9t+Lu5LhgFP/Ffnwo+S2 fu/5yZ+fv54JBam9DytA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbP-003lf4-1g; Thu, 05 Oct 2023 14:45:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbI-003lb4-07 for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 14:45:20 +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 54E351515; Thu, 5 Oct 2023 07:45:52 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9EF643F641; Thu, 5 Oct 2023 07:45:12 -0700 (PDT) From: Sudeep Holla Date: Thu, 05 Oct 2023 15:44:57 +0100 Subject: [PATCH v4 04/17] firmware: arm_ffa: Implement the FFA_RUN interface MIME-Version: 1.0 Message-Id: <20231005-ffa_v1-1_notif-v4-4-cddd3237809c@arm.com> References: <20231005-ffa_v1-1_notif-v4-0-cddd3237809c@arm.com> In-Reply-To: <20231005-ffa_v1-1_notif-v4-0-cddd3237809c@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Marc Bonnici , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2472; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=PdtsxMbWHMsPxE3UREG0cqF5vyZGskCvDY/GrQFa0NE=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlHsvw8PoKVnG2NHbjO9VKHIkzUeI3tmEoRMZG4 CcZ3zhBb9iJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZR7L8AAKCRAAQbq8MX7i mJGAD/9T3ada0rAJvvmdm4qPS7qlrINgtkmqLi3Kf2JYBUErUpdZ9bQfUD1yvZquHAA5O5ATiRu GDBcpn+mkMSOAOjQ5bmbwwSKb37jWU8zyryDMzbqUAF4bt72WWsr2nJqBeYO+gBvgNX6/A21j0V txxuE1Eai5zxYoAntxc3ND/8iEZDkHyL4lrz6KzJP6+Uny/NJngaFfCt+dFVAIot5azBIDqOSsm S5+Ae70YY1Fsh9XmTsSdlBCkgNuZZ2luTyhtDyhnZQpMlAbDh1TksFq3MshGvnWl5g6diNEx3EF BaYASOCTcWO/I2Pck5cMDkd2F+kYCUrc1c5gVa5GkMlRmFW1y9sUMXz08M98VAxyso4ADG23epZ s+5WMm+x4p2KfMXSba5EDeucauhkjWSwOZTtmz8h68H/YiveyVJv3b13GyDAUWOuaOvqyFrOeWy ca5z0JUUTmHEP5v8Jw7E6OFhsie/0uSByFsm99bjEdMAKiTBef41nweztaesSB9xvHpF2eLYjdv rUYKP0EVnUFhT7Tcj+R5PaZ1Gyj6HD+SIGGrDjVsw26gnZDLolIqu0b5lFtc2OjrC8LRd3ndkcc Z/lFQk6x8A+rsiOk0Jgp8mYUu+GE6+bAp/cJgi9H5jMtmmkDVc0UKICHlTxtH5azRoGSmRwyzrd AvR/xApIzrT8qFw== 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-20231005_074516_172084_D85BB59E X-CRM114-Status: GOOD ( 13.43 ) 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 FFA_RUN is used by a scheduler to allocate CPU cycles to a target endpoint execution context specified in the target information parameter. If the endpoint execution context is in the waiting/blocked state, it transitions to the running state. Expose the ability to call FFA_RUN in order to give any partition in the system cpu cycles to perform IMPDEF functionality. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 22 ++++++++++++++++++++++ include/linux/arm_ffa.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 20f8f4ca8e89..82e54d231074 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -616,6 +616,23 @@ static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, return 0; } +static int ffa_run(struct ffa_device *dev, u16 vcpu) +{ + ffa_value_t ret; + u32 target = dev->vm_id << 16 | vcpu; + + invoke_ffa_fn((ffa_value_t){ .a0 = FFA_RUN, .a1 = target, }, &ret); + + while (ret.a0 == FFA_INTERRUPT) + invoke_ffa_fn((ffa_value_t){ .a0 = FFA_RUN, .a1 = ret.a1, }, + &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + + return 0; +} + static void ffa_set_up_mem_ops_native_flag(void) { if (!ffa_features(FFA_FN_NATIVE(MEM_LEND), 0, NULL, NULL) || @@ -700,10 +717,15 @@ static const struct ffa_mem_ops ffa_drv_mem_ops = { .memory_lend = ffa_memory_lend, }; +static const struct ffa_cpu_ops ffa_drv_cpu_ops = { + .run = ffa_run, +}; + static const struct ffa_ops ffa_drv_ops = { .info_ops = &ffa_drv_info_ops, .msg_ops = &ffa_drv_msg_ops, .mem_ops = &ffa_drv_mem_ops, + .cpu_ops = &ffa_drv_cpu_ops, }; void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 2ea1717a0825..12fd134bf670 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -387,10 +387,15 @@ struct ffa_mem_ops { int (*memory_lend)(struct ffa_mem_ops_args *args); }; +struct ffa_cpu_ops { + int (*run)(struct ffa_device *dev, u16 vcpu); +}; + struct ffa_ops { const struct ffa_info_ops *info_ops; const struct ffa_msg_ops *msg_ops; const struct ffa_mem_ops *mem_ops; + const struct ffa_cpu_ops *cpu_ops; }; #endif /* _LINUX_ARM_FFA_H */