Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4017824rdh; Fri, 29 Sep 2023 08:52:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn9mR/kcK/nAZImImRTXksKq+70ErUNPJUbfRuT8Eo1Ak7RmsxFq7wheYhs35ZCp2Z8Wye X-Received: by 2002:a05:6a21:270f:b0:15e:9e62:7082 with SMTP id rm15-20020a056a21270f00b0015e9e627082mr3894245pzb.29.1696002731654; Fri, 29 Sep 2023 08:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696002731; cv=none; d=google.com; s=arc-20160816; b=LNHwxPay/vUKYcaYQQBUcIH/JimzFM7DaY0f5HL/fzRdj6h7OO1RHKuou8X/HVr7Oi n2t9N7kvqm1aBPWN4aLVwHauTaaEF3PvvHYIx5BofzBDZlDiV73Mojg3kbDvnYSaiklN Hpts5l9rk9wNLOLQB4keS8ioSYkkG1e5FSe3aIk9aLc11rkPZR5HkKrBC7m7/qJo2AZk fxbU5RNUO/8bejpmIjr/9A5N/A1OrmR4HTwXXDHPhXOM+tmRZ0D01AK6umRLX431kd4U N2PsYQssqYmSgOup5qyVuSKpLk3ZujHCoYZ2JGzcDRYSNQlQICbsbfmiI0AtubDIZiLZ TZdA== 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=T/yrEm74su1ROMa3HaVtVGOXUqzdZ9XodrQGVof3j9I=; fh=iZJRvoZuVJp3Jcg3UWu0imuTLbH0nKChof8pDyzNHj4=; b=Hgr1kfzGSrl/cN3aJrIMXYiRjtRm2S/YSU5FT+q/siRbQW8JMlpUUzfZ+HapVfsahd 7I600iZWtsUCXNip3amBcuVm3VChcn7hhJvfofKubpvDqya5349OBbB6U5GaR6WT+mfl am3IfCvK6oMEs413Tl8tmC7pZB45SacjIL+CKDrDbPPlc3pZSWi0yZU7VXkbBf3nks45 lelQegq1qNBnR2fZYCrXfFCvIJi9Yt3tGG2A/JqlWtPIeBLZxZh0rfvao/3PLvJn/7so /aYdG4gU7qX5gPEBwpLRcgD2//klSvWU1ZJI3fSADwCzJFEyFj2dngO/jYAFCYIoSpGN DAZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id j21-20020a056a00235500b0068fac3509a9si22328386pfj.350.2023.09.29.08.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id CD3F7853F29E; Fri, 29 Sep 2023 08:03:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233354AbjI2PD2 (ORCPT + 99 others); Fri, 29 Sep 2023 11:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233315AbjI2PDU (ORCPT ); Fri, 29 Sep 2023 11:03:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BAE55F7 for ; Fri, 29 Sep 2023 08:03:17 -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 794261007; Fri, 29 Sep 2023 08:03:55 -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 226643F5A1; Fri, 29 Sep 2023 08:03:16 -0700 (PDT) From: Sudeep Holla Date: Fri, 29 Sep 2023 16:02:51 +0100 Subject: [PATCH v3 02/17] 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: <20230929-ffa_v1-1_notif-v3-2-c8e4f15190c8@arm.com> References: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@arm.com> In-Reply-To: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@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=3398; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=E8dkL+QG2QXGEwg80l0faZM6cA032hi2OPI14UW5ukU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlFucuvBBiLwRwI+A6SBHoF7BhodlY60hl2wjwZ SYQKjnfHqqJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRbnLgAKCRAAQbq8MX7i mFOQEAC1qH09c9WVdsH6CsUdBdw3pCM0Gbn2kvv/5BJyJEKhaSlahsvCohQGLVkTiinsRzlQN/G AcbwPbb9tZ6+AvWDnxeUa+YLz+hjT8PgQuLziXUmrqyngPU8IivU3ENKLnHIjjyI68E+q1hEddD Svfmo57KwmzLDn6fbf4BlyL2rF2KDR+VamNUuLOUp2dCgn9nMoQ/1bchDcxwLK2OiYyAiTqI+Fs tSCdY/pzUJXye/nnv5FK+H++Y9Xv2Ji4lmCTPDKTunmMpVRu2xlG5JClEVE5XfLjLwCsvkGiEF5 me4K9Kg3IIoENEpbOV18LLSJN7BcY/LU6DKfhqvH5jhRHx0rbm7lkhikTDwFCR1Gwdy8IJ6VgHn o40WyqaKv6EorKh4e+DFuAGDp6d/XpyS5OTVGE7HDWlucYNIAl61NZrm3KEmrjFekJhyhgRIeo8 q9cX4JCiLvfKxuMCzChS7AuDsBBqxqKxl01wFXBzKAV+xFIySKgSlLRmnLbelzFtlE6b//SigsB jaXxpvQwwDP9iNWBomOpWr6CDOJfb3VfumDdG7+ZWp25wXMhkgNy/gTVs4KlvT6o/EWJIexGdNy 5CeJ3/a3wfsW/0u+goWAFd7k+lebdnG7HsvrJLbCXR3eyzJLSTHfT3QwXPqQRyKuLB4pns2+euD 4XFwj2kKBd17Y+w== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:03:35 -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 2b24cda2a185..efa4e7fb15e3 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) || @@ -712,6 +744,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; @@ -767,7 +824,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); @@ -782,6 +839,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