From patchwork Tue Sep 19 17:40:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13391631 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 C867FCE79AA for ; Tue, 19 Sep 2023 17:42: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: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=bHBFzH9VqaafdKw18yVY7HYyv7peSAHJ1JDunS6Ve2c=; b=gSy/lt0aEYiyE8 7r8ESdYtHNi66I3OwruKcLueQR+CUf/zwZRSBr7RtkPYn3LZQkHy/nKFUHyZbraVRkXVBw7SbBPBY 3DPKpeRXr+aMKoFG5OhbDtISoOA5+z9aASw3kMzLI7vVwqv07e14SyJcqcdkkqkxQLUFfUM2kGJDL eIkI0PgwWBROAdB5b+617fIEoeHfUfOMzaxuCa7WlHxHxTCYxXQ9nzF4fjN+6pzvSrb3goc2HwRj4 ZzoF8A2ulgiW7KbYiydqm8OMkqj3HLMzZwcWo83+gSvQs/6jBrmCwR+RGdPcFokKE/gsC3M2WcmbN VXuek3YmYHnHcaopPC2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qiej9-000xHq-38; Tue, 19 Sep 2023 17:41:35 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qieiy-000xAw-1E for linux-arm-kernel@lists.infradead.org; Tue, 19 Sep 2023 17:41:26 +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 61AB0FEC; Tue, 19 Sep 2023 10:41:58 -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 164A93F5A1; Tue, 19 Sep 2023 10:41:19 -0700 (PDT) From: Sudeep Holla Date: Tue, 19 Sep 2023 18:40:50 +0100 Subject: [PATCH RFT v2 02/18] firmware: arm_ffa: Implement notification bitmap create and destroy interfaces MIME-Version: 1.0 Message-Id: <20230919-ffa_v1-1_notif-v2-2-6f3a3ca3923c@arm.com> References: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> In-Reply-To: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Jens Wiklander , Marc Bonnici , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3398; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=j7d2i8CVINs5jyS14TuFWaqZrPCGJMCk2srmUKJvdW8=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlCd06QZn5C9izY1A/eynVtrklx/AVvq3+Tj6Gm lvxvS/Euo6JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZQndOgAKCRAAQbq8MX7i mB8yD/9DKYH5p7gWrZcQ7Hfxovms8Cl+ggEC3d7QDvN9WXOOuMXb8RNZfw7KMOY1TuCuAoLBgUJ d0q7RmUwdXzN+/Ht6Xu8gxmqbzlLf9AzBvKVAXkdZBiJYQiXWqEmoiwpjrAEjYjgTsegD6hG5D6 a95TqZeuNg/E9tdDn0FujAq9vwj5p1gEfUwzqJXt1k1FJMisB/0pUP+FO7u3lm4LlraRlC7eHtp KpqfnemY3giLyouee15bgPT/6YRetTdy8TGNxc3jMqxvGs0B63/BZQjZ5jh9spnTR6/HSZGVe8V z3mJN70EKBW5xQ+oGhVCDV9hGfUQLm5cq5/gq/STBCw25kswPqCa2pRqaCsn0K0rMaJ1byoyCew 6bctIu0lIaPVCHhZqG0E0vF6wSopHiZeEvUEP8QOHb+gzk5VYgpIKogPxOubW0DfHhsREaS7Q9L w5tN9xknIwHf3FFSczYhIaprybxqYfpjsE3dcL2V3Ri2OFTEYLE0A6UyD7yXl4dpTZo4K/wIWap /9cRI9k6/Jq7XWqtAa0LuJeTTJOrXmZJG5eaboC5HVqlavS+46/2rVTiFgVtQtCKxRzz6KA9nNe KOjCY4Akufdh7B0hA1BBYJ5U5VEcjQzFoNrOLx9I5jjNfm7UuA2oFt4LBYuVUnRxSDv/uimbtU9 ZK/FHygpJePngQA== 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-20230919_104124_529545_A18A37F9 X-CRM114-Status: GOOD ( 15.42 ) 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 | 60 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 6fc83fa6b81c..5522523afefe 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,31 @@ 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(); + drv_info->bitmap_created = false; + } +} + static int __init ffa_init(void) { int ret; @@ -755,7 +812,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 +827,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);