From patchwork Thu Oct 5 14:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13410152 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 450EDE92705 for ; Thu, 5 Oct 2023 14:45:41 +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=02LsSWQeDaS1FMxuYyEryNlwHcPoPd2XJ924xRMFTsM=; b=IO0Qwd4chQP/2P a1UsAswjsMLMKIGkTU/YW2Zc/J1A7QCo6QFmwqHfQYqOUCY0Pczl8CwDRQ0n9olOsVVFNAQSVoorb i1a2i7+rwJQEjIwsKShZUarrEekcFhtTzorRWzhjHlQdgFE+dTMH/UA0dA0x/mL3S7DCUHGIoH5Tk pvBUqhuKv8QhlSOW2XKxPsSVuTmM2oRMe+gmLsSkcCTfDke1K4ehzPPDxIzwKTK+8v7IhAEG60L1u oXbfD4GpUh075lpRf1hOlzjBphO7RuwMQXwun/M677Qqwfzk1FGjd53DdFKZ4R83YIw/QH0lE7xBe nBTmcdsJihbXhuALTJrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbI-003lbW-16; Thu, 05 Oct 2023 14:45:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbE-003lZi-0a for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 14:45:13 +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 E58FD139F; Thu, 5 Oct 2023 07:45:49 -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 3B6EE3F641; Thu, 5 Oct 2023 07:45:10 -0700 (PDT) From: Sudeep Holla Date: Thu, 05 Oct 2023 15:44:55 +0100 Subject: [PATCH v4 02/17] firmware: arm_ffa: Implement notification bitmap create and destroy interfaces MIME-Version: 1.0 Message-Id: <20231005-ffa_v1-1_notif-v4-2-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=3477; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=uUL2ZAphmbDP68h5pYnBIMj7pjeetUE+/DHcD8KcBDo=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlHsvwJYa5tKnQfZaTKhzLY4WPPK31PNv/mf0ul VCCjuqGifWJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZR7L8AAKCRAAQbq8MX7i mIqlD/9ZEzkQ5vVuCRL2ahSlui8c006jtP9sHnonqbqj/uQI25nWgyFlpfjkONGVjuCMTyUxRWu xPfCEn94+9Nx50JUjhdjNc9lCj3k8PvmC0kPUGwP96/dA4nNBdeYQmENzZNAnTMdDmj42UsCr7D /uBP0aJtAoA1lT2tLSqmsRx0ACpfaysMnTu/D+G4ZHuqNhzPXHiW+bE3EJm2lWc+yLY7UttbGGI vEUFMRS6Iz3/H5CJeDNSmvB94k6cnvNXEWdQeuL+cVAiiQLnls8iQ2ZLgqVVxjJlwHZ9C1Ol83D /voSUdLmKmDyfFcqxQR/VsZGakRzJKhgHgsqNYETj3VcVLBGvbKimPHA/QXXGejKWaRKtdb1M2d 64QcsZkswWyn0Vfz/Ku/ImS0Bt6teVWNbP6Yt7Edi+whd9/b3AmfUSY6WD3N55nrfD4W6FJwP0b EunSKSrbY9qbWhzejMYfZS+vRZnVxLu7/Su1ZJEtVEjPLH+Fcpg2G7ffClOyyRswQtBvL14hXzJ R2ca4WEMv1PAzoWFn6gik8c77a9suhCesDI9ubXm4+Y4/uU6mGDTMxalUn0DcDeN/qmha7Dmt5j uXreRXJ/pFpNCmG5vwW6+Fn2aGF5i6McW5N6lLQjbzFqbHvq/nKgVAZy+rJdR+cBAMEiZnfN7YO m82V4mWUYhJq3mQ== 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_074512_330620_879BFD97 X-CRM114-Status: GOOD ( 14.99 ) 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 | 63 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index a64512388ea5..c2ab6f4cf296 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; @@ -555,6 +556,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) || @@ -704,6 +736,34 @@ 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) { + pr_err("Notifications not supported, continuing with it ..\n"); + return 0; + } + + 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; @@ -759,7 +819,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); @@ -774,6 +834,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);