From patchwork Tue Oct 24 10:56:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13434229 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 59B8EC07545 for ; Tue, 24 Oct 2023 10:57:16 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OijyMpBXzJw+UUJnWcQT3OIV29nQHkW6R9Cue5fi/Ak=; b=K8oA+1xomwm+O9 OIoC0bjzZ6ltf17X20ljvmi67fys/1lNResoWZd3qfCoej0HxKCsaywD4zR7bMomDAUxxn8wCXzh2 xvmO5wiamLu7Spor8eQMilwkFNBqUgcOPvmzCosiYu6sFnpXbn11P+S4x4+h9YLaBycrgpg2/dLj+ D8/enQzyWcE1mIgrl2phQFyPhEEVtS8YANLoXUIwHZvBXQ81HF2Su0w9Jp4cyLWmFJgYbIsysOko1 UW4byHZWQWs9/7Ma1AIpFaXUF00rZptE/pDoG+roIBrelyTL8X68eqpnO+BenbbYFLPCtcipl7oja EhQRtnx4nPfwJoWNLpbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5U-009bLT-25; Tue, 24 Oct 2023 10:56:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5M-009bGa-0F for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 10:56:33 +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 DAD05C15; Tue, 24 Oct 2023 03:57:08 -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 197BB3F64C; Tue, 24 Oct 2023 03:56:26 -0700 (PDT) From: Sudeep Holla Date: Tue, 24 Oct 2023 11:56:17 +0100 Subject: [PATCH 1/4] firmware: arm_ffa: Allow FF-A initialisation even when notification fails MIME-Version: 1.0 Message-Id: <20231024-ffa-notification-fixes-v1-1-d552c0ec260d@arm.com> References: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> In-Reply-To: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2317; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=UW+oG+gsm0FKrpPXyKAnSuAo0QMzo5a2SfkP+2CJjXs=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlN6LZt+oDW+pFRLk3OWWPZo4Q2axp2luX1Qowh FMTLIcpzCyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZTei2QAKCRAAQbq8MX7i mAFTEACpCDJLAhCp4Eu76ebowZKy1lZohQoC7AnD3RVB0A+S741ljXq/zk5k7p+3GHuk9GBoy+2 0GnK1CqbJ53cbrDL33KF4VzNSVRaGWdAMfMJUd5GUdbozL0Ew++JB5XVg9v2gZC/Q56DE4UhZ+C kj8mocLnf7kvJoRNpQN88qEXKATw+bdEHFh1JWhnfZi+6zUi9h1F4CtP72il69AVlCxis87YikG dLJFdjTxyZz8cRB+OaB90zXYP5xm9ff7QGcZnoD/8ZF2wP5InyTno3XuNOjLFwP7QSaLDr0iZgA LvA5Vz+yTvfXeIFwYks+CmBxwG4qp0KKzpgcGVduf8V9UBhjITXfJ014T0eXBqSoNyU/H1GbWIS Q8vYbiKNSpnmrPmSPwAYfHkVJUujkKRUo8qdbVtRuo9w+7qfbBeQci+quKHWLajxuCBJhqboFea qq+Y3ZAHrscn6Y++NI0YlxxAIuojDnU8LYhuHZku5B7Bn+NxLwM6ZcHgpQlTw97UmsC+h/mIyD+ gIGXSASEVM0zvZNqcPrjR05cH4tQ6w5MRFXtrLXrYnVF/jK5p4ynR17uveToNy5HQFZOrHW1q8n iyYdayr4SNF6tVQWsK1asEjJFpDJixAfDEUCD3Bg4PZLIAidnd9QoImOoZCI+WJI0EnogV1OEDE Aeznv2xfy7NdTzA== 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-20231024_035632_209181_95CBCC20 X-CRM114-Status: GOOD ( 12.61 ) 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 FF-A notifications are optional feature in the specification. Currently we allow to continue if the firmware reports no support for the notifications. However, we fail to continue and complete the FF-A driver initialisation if the notification setup fails for any reason. Let us allow the FF-A driver to complete the initialisation even if the notification fails to setup. We will just flag the error and continue to provide other features in the driver. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 07b72c679247..b4ba52d674e5 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1390,20 +1390,20 @@ static void ffa_notifications_cleanup(void) } } -static int ffa_notifications_setup(void) +static void ffa_notifications_setup(void) { int ret, irq; ret = ffa_features(FFA_NOTIFICATION_BITMAP_CREATE, 0, NULL, NULL); if (ret) { - pr_err("Notifications not supported, continuing with it ..\n"); - return 0; + pr_info("Notifications not supported, continuing with it ..\n"); + return; } ret = ffa_notification_bitmap_create(); if (ret) { - pr_err("notification_bitmap_create error %d\n", ret); - return ret; + pr_info("Notification bitmap create error %d\n", ret); + return; } drv_info->bitmap_created = true; @@ -1426,10 +1426,11 @@ static int ffa_notifications_setup(void) ret = ffa_sched_recv_cb_update(drv_info->vm_id, ffa_self_notif_handle, drv_info, true); if (!ret) - return ret; + return; cleanup: + pr_info("Notification setup failed %d, not enabled\n", ret); ffa_notifications_cleanup(); - return ret; + return; } static int __init ffa_init(void) @@ -1487,13 +1488,9 @@ static int __init ffa_init(void) ffa_set_up_mem_ops_native_flag(); - ret = ffa_notifications_setup(); - if (ret) - goto partitions_cleanup; + ffa_notifications_setup(); return 0; -partitions_cleanup: - ffa_partitions_cleanup(); free_pages: if (drv_info->tx_buffer) free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE); From patchwork Tue Oct 24 10:56:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13434223 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 E6B0DC00A8F for ; Tue, 24 Oct 2023 10:57:09 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C5zEBIJGDfq5EtQc9TsT5W7dXoZWBVClx8+Ww6w2Px8=; b=omsq4sQZU5uf52 pdS/jdgw+vT3/o32KZKOrBkHqBYfIHYRmzhHpQ1t7yuWzhE53Z0a17DM0IqxWdKmNUI6uK+i7r9+S s2c3qB8L8e9SDyefXzdu3YIgBXeHnHmGanpW3kTmglkdAFbSM6oorqM8RuES5Pa+G88okmVu7nrl5 szI7RuWZ3yOvxbLsman7BPeiaj2+DAz3fsZB6U9FaJSqn//vw564JvrL7vd5fBVMlxfOrjnZxyBXo 1MdzfOjF1uSRaUVCZ9jHsKRZxe5uw06XFSfWzY4vWRBh+cL/CoLBqKDmWm4n7b21BqDfd/l8hHUlq HTJf/qTrkDKYQl8C9myg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5T-009bKx-3D; Tue, 24 Oct 2023 10:56:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5L-009bFl-1n for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 10:56:33 +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 D7D3C1424; Tue, 24 Oct 2023 03:57:09 -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 165EC3F64C; Tue, 24 Oct 2023 03:56:27 -0700 (PDT) From: Sudeep Holla Date: Tue, 24 Oct 2023 11:56:18 +0100 Subject: [PATCH 2/4] firmware: arm_ffa: Setup the partitions after the notification initialisation MIME-Version: 1.0 Message-Id: <20231024-ffa-notification-fixes-v1-2-d552c0ec260d@arm.com> References: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> In-Reply-To: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1808; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=3aXcRjKfbSWHb8DoeLoTEHJIg2fFmreeDpN2RSMCi4I=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlN6LZLEQG8QC6qdL+oXai0m2YRoseXesNT1eBd mkxD38jUYeJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZTei2QAKCRAAQbq8MX7i mPcQEACPjeCJeGI2k7cfqoZsiAJxlaLTuatUGBnRApRiAi8yn8g//buZpcNTlVmo+p7ME9hnHJj 4cnb4hTyW9eG/jmYBI1KIo9kTVwS74GLNZ2JeSMQAunc9O0SVfnfOsMB9mcxh8e8Yenr3/FRD3M eiftmxTmBZJy7YXr+PCChncMZOUHIRqJtjWJT3PngbvTgfnXGPZ3USHiqofP3vI7aKhaCP2rQMC 6pVkhVEb60R8B7BE9BWhdWOCO47NUR26WzY193Tufwnhh7PDmG/PTw3tCWaBw2QfgZnCFUo1glj FHsSLsAvkZr338EA7YZ+opkqd4F4m17cQ9LaTrN8zZwkZS0Gv++jLCwzutL6udNvM1bMysQZ5/1 UaxKdgohtul2Esp+0fqxAZCUjPhR29opNBbVlPpB6VMgJhGH5RxjV9e/GMLp3nmTCHTLHLWRyOI 523KXa+W8pTCghTikElmQycWj41QyU0JaqwD3r69wrTztdTmHlMPtBZNrmkBq1yLT63n7/TTlIG MmyKnmWxd4somSJUWbX7rq9k7mJdJbUrFjENZt1XOgXhRHMWfHF6AunmO2hw2R8K/CIGbZ9E3zG d8JSftbzO+j+j1sh4OnB90VTCsM/zsr2nXm/nofJb+CN4gDqgLLOF1nnBJcz3ULWFU62RpGqGaS yUaiT867UnQLfmg== 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-20231024_035631_687808_BC733500 X-CRM114-Status: GOOD ( 10.16 ) 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 Currently the notifications are setup of the partitions are probed and FF-A devices are added on the FF-A bus. The FF-A driver probe can be called even before the FF-A notification setup happens which is wrong and may result in failure or misbehaviour in the FF-A partition device probe. In order to ensure the FF-A notifications are setup before the FF-A devices are probed, let us move the FF-A partition setup after the completion of FF-A notification setup. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index b4ba52d674e5..0ab30b571a69 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1422,11 +1422,7 @@ static void ffa_notifications_setup(void) hash_init(drv_info->notifier_hash); mutex_init(&drv_info->notify_lock); - /* Register internal scheduling callback */ - ret = ffa_sched_recv_cb_update(drv_info->vm_id, ffa_self_notif_handle, - drv_info, true); - if (!ret) - return; + return; cleanup: pr_info("Notification setup failed %d, not enabled\n", ret); ffa_notifications_cleanup(); @@ -1484,12 +1480,17 @@ static int __init ffa_init(void) mutex_init(&drv_info->rx_lock); mutex_init(&drv_info->tx_lock); - ffa_setup_partitions(); - ffa_set_up_mem_ops_native_flag(); ffa_notifications_setup(); + ffa_setup_partitions(); + + ret = ffa_sched_recv_cb_update(drv_info->vm_id, ffa_self_notif_handle, + drv_info, true); + if (ret) + pr_info("Failed to register driver sched callback %d\n", ret); + return 0; free_pages: if (drv_info->tx_buffer) From patchwork Tue Oct 24 10:56:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13434230 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 D28FEC25B48 for ; Tue, 24 Oct 2023 10:57:17 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1oXel4mlMjMOEpgbbHms8krIxQ/fEHT67UpIOW4ha8Q=; b=yJVUR5fdIrc8yq DHYewKPnEHxAEaeoxpjPfxeNDlYvWVEx1JTGKZsK1No6tAjSRFnpyX4NyuRRFkXQMU+6FwisU8qTF qYyklPe4dLwNBrncufVCAtlklbN0u0HHdgxh/daieDCgaUBgO9Haf/fTw5fpMX/0PRGrnodgAlWxs daENpi/rbWTtLzabNT+uFNL/6wkDeqYBN9LbM8qlvD6Xb3+JJWi9Uapm415jWriu3lP/fsxQJLTMz dbDBT6jE+K/odQZ4H1Yo++t6h8WAGbFzbtvICDpMwSbIJ01fPETFuyHthZIWKKEYN0owfsjWp7gM5 dyLphnOgl9AYPYH/Cy/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5W-009bMy-0H; Tue, 24 Oct 2023 10:56:42 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5N-009bHb-11 for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 10:56:35 +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 D4BD715A1; Tue, 24 Oct 2023 03:57:10 -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 1357F3F64C; Tue, 24 Oct 2023 03:56:28 -0700 (PDT) From: Sudeep Holla Date: Tue, 24 Oct 2023 11:56:19 +0100 Subject: [PATCH 3/4] firmware: arm_ffa: Add checks for the notification enabled state MIME-Version: 1.0 Message-Id: <20231024-ffa-notification-fixes-v1-3-d552c0ec260d@arm.com> References: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> In-Reply-To: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2821; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=E6NSv6v1x1k9jYmSXi9wqAwct9jHzDEtdSLjqJZKdeA=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlN6LZlekawWTp6pU0+zIL+ooCxPn686rd+ILSC Hhq+w8T2puJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZTei2QAKCRAAQbq8MX7i mCbFD/9dxq64fStRXBbNV9s6lwBsfxZTteMfOZvLHCLYjvzHUn33Gf2sGL5fml/7Ren7MF8mPvA ZGnOLK9do+ElMIsJ569kWwjpP5edeBS5R+Qs2ckeDQrsMYHEny5Kmn54yEkJLygzho4l8CzdpeA 6jI3WO+oNy8U13h7T3IJfmshizFhogR/+Tcl2OTEKMfVeQJKi4gBmA6BJRYGDHCcB3dTfs4Fkup Dnkuk74tbWojm5lL+l6wcxBIWZwc2R3BfAii9yUC+RSUHl1dNG643KBsKpMAOiHk9Nws1OWZboI u6X7lOacF8sfC0kDOjlpO/MuK57WHfYm7je5/8l0aI1BNQ/gOaN0u834vq3u4t8BzjwUjKzst1u 1KznUD0V96WwUOA1uBn8e669hV+hMLDr2YbmEDxNKC1HfhplKzaG6M7K7RfX7/I5paZU40z7eaf LIoNAejPcbfDGJptk+bt2mf7eLm2n2gcZ/T3nrlCJsfodT9KuiceYAaj99Pd0ta9vIQYxfXsnjc EypyLPkGa7r3Qd3yico3Y5sz6fdKOU8Hze1GYzWWzSJTIvKa81z1kCvD+VDuNBvwRQysRTVGfI0 8UKIHK9s/sASvLpEvKDrGHnCUcf7CyFSaV/aC1aHPdOVwQulkcXCsfciV3WN0KAe9eIVut9fQlh 1p49MAylzEvosjg== 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-20231024_035633_451539_713BCBF9 X-CRM114-Status: GOOD ( 11.59 ) 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 We need to check if the FF-A notifications are enabled or not in all the notification operations that are accessible for the FF-A device from the FF-A driver. This helps to avoid making calls to the FF-A firmware even if the notification setup has failed. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 0ab30b571a69..b097452597a2 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -99,6 +99,7 @@ struct ffa_drv_info { void *tx_buffer; bool mem_ops_native; bool bitmap_created; + bool notif_enabled; unsigned int sched_recv_irq; unsigned int cpuhp_state; struct ffa_pcpu_irq __percpu *irq_pcpu; @@ -889,6 +890,8 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) #define FFA_SECURE_PARTITION_ID_FLAG BIT(15) +#define ffa_notifications_disabled() (!drv_info->notif_enabled) + enum notify_type { NON_SECURE_VM, SECURE_PARTITION, @@ -908,6 +911,9 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, struct ffa_dev_part_info *partition; bool cb_valid; + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + partition = xa_load(&drv_info->partition_info, part_id); write_lock(&partition->rw_lock); @@ -1001,6 +1007,9 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) int rc; enum notify_type type = ffa_notify_type_get(dev->vm_id); + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + if (notify_id >= FFA_MAX_NOTIFICATIONS) return -EINVAL; @@ -1027,6 +1036,9 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, u32 flags = 0; enum notify_type type = ffa_notify_type_get(dev->vm_id); + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + if (notify_id >= FFA_MAX_NOTIFICATIONS) return -EINVAL; @@ -1057,6 +1069,9 @@ static int ffa_notify_send(struct ffa_device *dev, int notify_id, { u32 flags = 0; + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + if (is_per_vcpu) flags |= (PER_VCPU_NOTIFICATION_FLAG | vcpu << 16); @@ -1388,6 +1403,7 @@ static void ffa_notifications_cleanup(void) ffa_notification_bitmap_destroy(); drv_info->bitmap_created = false; } + drv_info->notif_enabled = false; } static void ffa_notifications_setup(void) @@ -1422,6 +1438,7 @@ static void ffa_notifications_setup(void) hash_init(drv_info->notifier_hash); mutex_init(&drv_info->notify_lock); + drv_info->notif_enabled = true; return; cleanup: pr_info("Notification setup failed %d, not enabled\n", ret); From patchwork Tue Oct 24 10:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13434222 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 5A771C07545 for ; Tue, 24 Oct 2023 10:57:09 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jyX3MMGBeNQJ1KqV3afVf1VvGRX4bdh4ZimxfiFUeqc=; b=HJYue+cWmt/Inc lypaJiGbtAFVupa82XsmzwGWw0JbECbhl+ZVnft59CM9KWPSl4WLRl4BW+Or3l/luRMMltoF5hcst gKBQPmq1QnwPMv6+BZp8qSUDbqvI9A6kFPcA50acXXxIrE1BK8eYOYkuEfOBJYNBYnZ7w+xhMC53L GB2slNDBbp+y4+LDGlz5LiuJhWeW2odwT4LEhQ1ELvZPCMudhbiSpwJBlVhXVuZl7RcCVTSXu/1LT ey3FEP2thpWIcBXQzoqSuN22djvJ9FBPRLuIzcFhZj83M1OqB967459743oxtgekEMoRvByMxK3C4 N1jLcLpxufT5Xr+AUh7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5V-009bM1-1Q; Tue, 24 Oct 2023 10:56:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5M-009bGF-0F for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 10:56:34 +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 D1C7215BF; Tue, 24 Oct 2023 03:57:11 -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 106D03F64C; Tue, 24 Oct 2023 03:56:29 -0700 (PDT) From: Sudeep Holla Date: Tue, 24 Oct 2023 11:56:20 +0100 Subject: [PATCH 4/4] firmware: arm_ffa: Fix FFA notifications cleanup path MIME-Version: 1.0 Message-Id: <20231024-ffa-notification-fixes-v1-4-d552c0ec260d@arm.com> References: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> In-Reply-To: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2084; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=//JpqRCTG6133GyveR4ek+FR3WO6FNVPAfl35AD8fYY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlN6LZAKdF6iJn1GsMxaobrUC4sNzZJsjmewCVP gjo4REtbPeJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZTei2QAKCRAAQbq8MX7i mObpD/4mSWyNNXZefkniqBQplfV6ySTNlgWi/ZjEF3LgcqkTPQ2IHYYUaJksssKwZCgiHaRWRt7 859lkifjOHGoqD+ndW9Ty+beHUyBZUEpr3NXikQEzSQQJBOjtXfK1pRiWoLHS6yppWa49XUx6CO o6HSA7AZZ88K/Gvui5yjjsHWnrveR+JjK1VTHQp4AN4YkrQJdNKLsxSaHX9RZAKbbtyYXK7c4XF Ya/jcFlV5ddHoRxy64ATyLq32XNYidYFQkwkdNljayIt/CsJTv83BHIxvysdCtmrGKL0w1skTVU acAeMcueb8M86oMhcPnWmSezEm+eQOuc/kN/k5vZEh/B5gkiJADmovLQ7wDkwbXYlaDu0EH/ody T+s/6Xm+AP6NrVU04y5EN9+Ua4zOek9haZ+4nHGePdMgeHAIpnguer9aet1YJHRvRKmGHbNH4vW Y8fwW+5pkeOiTbv3zVd/k+rk3o1FBnj2186MMLVuI4yEdTxD/xcIES1/N65Vp2g/97/Wo41o5Ab DL25Gd1mHGBkVGdvJYbIQtChqClYVMLDvxME6xAb6uCAbyF3XvJQR5RMGGaGeCqEji0vjx7eJG8 X527nLjYmcW4iKPmYkIIHjiY76YH+IctvETObLcDpqevYQwVq4eGxCSBa8sEBdA3jCG3imLK4tw VAoNnN0LsdysdiQ== 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-20231024_035632_209372_671E989C X-CRM114-Status: GOOD ( 11.34 ) 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 We allow the FF-A to be initialised successfully even when notification fails. When the notification fails, ffa_notifications_cleanup() gets called on the failure path. However, the driver information about the notifications like the irq, workqueues and cpu hotplug state for enabling and disabling percpu IRQ are not cleared. This may result in unexpected behaviour during CPU hotplug because of percpu IRQ being enabled and disabled or during the driver removal when ffa_notifications_cleanup() gets executed again. Fix the FFA notifications cleanup path by clearing all the notification related driver information. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index b097452597a2..e636181694aa 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1326,8 +1326,10 @@ static int ffa_sched_recv_irq_map(void) static void ffa_sched_recv_irq_unmap(void) { - if (drv_info->sched_recv_irq) + if (drv_info->sched_recv_irq) { irq_dispose_mapping(drv_info->sched_recv_irq); + drv_info->sched_recv_irq = 0; + } } static int ffa_cpuhp_pcpu_irq_enable(unsigned int cpu) @@ -1344,17 +1346,23 @@ static int ffa_cpuhp_pcpu_irq_disable(unsigned int cpu) static void ffa_uninit_pcpu_irq(void) { - if (drv_info->cpuhp_state) + if (drv_info->cpuhp_state) { cpuhp_remove_state(drv_info->cpuhp_state); + drv_info->cpuhp_state = 0; + } - if (drv_info->notif_pcpu_wq) + if (drv_info->notif_pcpu_wq) { destroy_workqueue(drv_info->notif_pcpu_wq); + drv_info->notif_pcpu_wq = NULL; + } if (drv_info->sched_recv_irq) free_percpu_irq(drv_info->sched_recv_irq, drv_info->irq_pcpu); - if (drv_info->irq_pcpu) + if (drv_info->irq_pcpu) { free_percpu(drv_info->irq_pcpu); + drv_info->irq_pcpu = NULL; + } } static int ffa_init_pcpu_irq(unsigned int irq)