Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp810393rdb; Tue, 19 Sep 2023 10:45:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4/rKXG2c62nKfqSHTwpkbaFT5FApCpBp1ilc3V94V7hfOKUZ11JxxVzPhyEf5ASlT+wys X-Received: by 2002:a05:6358:71c2:b0:143:1063:d1eb with SMTP id u2-20020a05635871c200b001431063d1ebmr381172rwu.17.1695145505103; Tue, 19 Sep 2023 10:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695145505; cv=none; d=google.com; s=arc-20160816; b=e6MLvudox7B38R9fmpNjtHnUVufasjNulhRHiapp0aC0Qvg1En0ylqW+RiU8td1rAy x2/ll6lKJZqpJtYUvndil/JWotH2L4Rwnyq1j3wy49RABJwTf5XgipLBaVOKSsqU0anJ 0iI2UpzcwiFXLLUss3ZhYolDx4Hyb+T955Kz+/vS7OpH0OZdxwnaAARWvHRF5OgSZDdg zSc2OxR7wgtvAOc9o1StDQ+y7dwzRvoApzegQbVWV4yMnHugY6Uk3t0dLgJgS6aW5McD IlusTnM4mSn2PDhEXK4FEcW+7qSia6RsCiSnX9YeZRP/E1mJY5FQus9+ePdWrCt3vDQM ruwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=C3SSsv/qKbrrs3mK2fwfkswTDBk7uD1QcGKJxh7BtMs=; fh=vcyxKNiHD7TmKqmM0/rwqxGOTauIz60tMzPVV7I2N7Q=; b=pvTZozXOYrP5fBhLetcMNQQd7Kt3TVI3vbQNFgySU4l1BQkH8wMqBlyR3oX6QaXFLd qV3FDOByLrlATH8EC0k5f46GGuDSYMxEacketJbTa15AAFxpVC1t/KRobVTP4r2QL1O/ xL6OheKPj1EtjvMzh/PhyS0ak2X7fHC7AMBeQSTjNQUrT4avzKTK8EmEncWAqX8eLPn/ GBZf65mMSgxovjwl8rypPSXVb3k2Mpy8EuullfzcZPQj9vH41Cz0b2YQigpt3gO/9qhY 9jV8bWXxPF/02UX7Hko1OF7lNkuTV44TKJwDO0WwcDZ92l1r9E2MBfdQH3cUnoLEUfuo OR0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o25-20020a635a19000000b0056da0ae25d0si9850096pgb.499.2023.09.19.10.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 10:45:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 725DD809843F; Tue, 19 Sep 2023 10:41:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232276AbjISRle (ORCPT + 99 others); Tue, 19 Sep 2023 13:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232154AbjISRl1 (ORCPT ); Tue, 19 Sep 2023 13:41:27 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4578E9F for ; Tue, 19 Sep 2023 10:41:21 -0700 (PDT) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 10:41:42 -0700 (PDT) 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); -- 2.42.0