From patchwork Thu Aug 3 19:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13340781 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 BFB30C00528 for ; Thu, 3 Aug 2023 19:03:01 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aGGddWWkmLPi9SCDWqc2LyoSqzR+BxAnNmph1PyL2I4=; b=rRMCTgmO1d2LS9 c86xGiFr/DJXWkUCthU9h0xcZX8gn8N4MIL7qkRqYBtBLde+XYbTY0mDSUplIYmGlrhxNidT+646a nLUb2WtiZmGXH5BKuVYOK/DGH7mvVQht8ekDYduLdlxylDrvA2IYHi+B42sYzDMk+fY/7oto5T7yc 06+v79TDL28hr/5AoJVj46nDbh2TOsDtCzuZ0P57Jgzjt5REM8IDUEpd3/F527ZmnJipAR4rburf2 gvH7Tc/MA0LqHexutIXJljs3zIVxykNC7FHiXzYPDGSxVUVuWhyqYcnmUPC0jBm1I/padzfW/IOn8 9lrBzZqeX9dyCU0woIpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRdaj-00Agxb-1v; Thu, 03 Aug 2023 19:02:33 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRdad-00Agtk-1J for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2023 19:02:29 +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 74D131474; Thu, 3 Aug 2023 12:03:07 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 595B03F6C4; Thu, 3 Aug 2023 12:02:23 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Lucian Paul-Trifu , Marc Bonnici , Coboy Chen Subject: [PATCH RFT 02/12] firmware: arm_ffa: Implement notification bitmap create and destroy interfaces Date: Thu, 3 Aug 2023 20:02:06 +0100 Message-ID: <20230803-ffa_v1-1_notif-v1-2-6613ff2b1f81@arm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803-ffa_v1-1_notif-v1-0-6613ff2b1f81@arm.com> References: <20230803-ffa_v1-1_notif-v1-0-6613ff2b1f81@arm.com> MIME-Version: 1.0 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3353; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=LjH8zfz+NSMR+jD4bGN8jL66879DFQjmAd8Zz162PAI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBky/iMaxntS0KpaU2/1R5tA+iKx9/x8ods9t7Ok eCvBJYhoVKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZMv4jAAKCRAAQbq8MX7i mMsID/9s4LbC/Bg40/xIJACO2aE3Q05WOdrjwdzAzm/gwkN1ioRVW98hKvwa4GdaaG2yPOBr9Gr 6pcRod3atLXK01PwKJE4k/14c1/RmLCCEMuFdjGMK199FvJdMIH9PrgWDjTvNpmn2j50PPjDONE 37t8Mo68WPo56ylte/svzGUiPrmULdojgMG3xdWZgFGCSBo15w+5qEWEPBnN30oH71OpFOJfWT6 +EXhTmAMmgMstzdwOP5nvU8+iTBInCwuuJM91mJGDvE01wJLw2YeKTxsBQkcp61jtLDqxGH8sB7 vGZH+GLbWHXbk3eHiP3hDxyFfwPspTWv+DrRdsp2RfIx6YjQvhH84T9zgiMyHWlfqg7wUWhO0D9 Wi6h68giUNTPgwjuxK4DqLa7vmD2b5PN671/dP8Zy4/xSD8l7t4tTRbUdNYpEWhuW/FBmrgKcYZ WxK9Z7FAOtrHxP5TYqJS8Zzce4Cw7V8hlhwPYnWenOTfdpWDmdTZlQYJEjaSJncxt5z4+Sn6uAe lGzduJ5jdNDzdyJvolC1+2opkY/u4GgMnlQ3/Itr5BQrW0xTgoKajF671RO7zfKtEmbhuCo4NYV JF2quBrCe45ti8nghRLfvrjl4iaEUqHZWAr0VumoGlFY+JOdJ2pP+kVNNab2WHOjAe89h6CBoFi LBm/CFH+ tIK73Rw== 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-20230803_120227_544307_989B8B1A X-CRM114-Status: GOOD ( 15.93 ) 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 On systems without a hypervisor the responsibility of requesting the creation of the notification bitmaps in the SPM falls to the FF-A driver. We use FFA features to determine if the ABI is supported, if it is not we can assume there is a hypervisor present and will take care of ensure the relevant notifications bitmaps are created on this partitions behalf. An endpoint’s notification bitmaps needs to be setup before it configures its notifications and before other endpoints and partition managers can start signaling these notifications. Add interface to create and destroy the notification bitmaps and use the same to do the necessary setup during the initialisation and cleanup during the module exit. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 58 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 6fc83fa6b81c..022c893c9e06 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -84,6 +84,7 @@ struct ffa_drv_info { void *rx_buffer; void *tx_buffer; bool mem_ops_native; + bool bitmap_created; }; static struct ffa_drv_info *drv_info; @@ -543,6 +544,37 @@ static int ffa_features(u32 func_feat_id, u32 input_props, return 0; } +static int ffa_notification_bitmap_create(void) +{ + ffa_value_t ret; + u16 vcpu_count = nr_cpu_ids; + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_NOTIFICATION_BITMAP_CREATE, + .a1 = drv_info->vm_id, .a2 = vcpu_count, + }, &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + + return 0; +} + +static int ffa_notification_bitmap_destroy(void) +{ + ffa_value_t ret; + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_NOTIFICATION_BITMAP_DESTROY, + .a1 = drv_info->vm_id, + }, &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,6 +732,29 @@ static void ffa_setup_partitions(void) kfree(pbuf); } +static int ffa_notifications_setup(void) +{ + int ret; + + ret = ffa_features(FFA_NOTIFICATION_BITMAP_CREATE, 0, NULL, NULL); + if (!ret) { + ret = ffa_notification_bitmap_create(); + if (ret) { + pr_err("notification_bitmap_create error %d\n", ret); + return ret; + } + } + drv_info->bitmap_created = true; + + return 0; +} + +static void ffa_notifications_cleanup(void) +{ + if (drv_info->bitmap_created) + ffa_notification_bitmap_destroy(); +} + static int __init ffa_init(void) { int ret; @@ -755,7 +810,7 @@ static int __init ffa_init(void) ffa_set_up_mem_ops_native_flag(); - return 0; + return ffa_notifications_setup(); free_pages: if (drv_info->tx_buffer) free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE); @@ -770,6 +825,7 @@ subsys_initcall(ffa_init); static void __exit ffa_exit(void) { + ffa_notifications_cleanup(); ffa_rxtx_unmap(drv_info->vm_id); free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE); free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE);