From patchwork Mon Feb 17 15:38:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978142 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 7A84EC021AB for ; Mon, 17 Feb 2025 15:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=JSFDjESCF0e4nMJZ2/RT2u9Nm4d866jIp7I72zpFvYw=; b=Fe97cUmB9Vl455JyNBPzvVlA6w MmOkq8jmegbp5k0TGfVR2iYLchsEBjq1Cuyf6zIUQgkYE+ZvOmcPTEe+jOOM1GhkBP+QTft9g2YLY qA+lmCqwsvrg9UhKSpPKzHFksR45W0ELWZHIfUckZOcVq3DeV7iHOgQwCzKSBUdjY2oZIY6q3OniG 0aHkptuZjXUWlOnV0kxzHnjImd58qFfZ4VGNPn49pRTvRlp823jV1WkI56IUYjOvo+InzkjCVLEXS 55WMK54dngYSdfhmiZrTD/1R2LhAHeBcMqkFItPtrJL0EmZvUjHFQG9zbSFLXh4F1Jl9Kl1QLxWVy BER7FkyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Mu-000000057u9-0RMj; Mon, 17 Feb 2025 15:49:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3DW-000000055WF-3Jbr for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:31 +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 0A3EC1692; Mon, 17 Feb 2025 07:39:49 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 25D243F6A8; Mon, 17 Feb 2025 07:39:29 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:42 +0000 Subject: [PATCH v3 01/19] firmware: arm_ffa: Replace SCMI by FF-A in the macro MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-1-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1599; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=tJtJ+iZ/RH0kV6E8FVz8GWyFPWw0X5nxEmvPF+pyVpA=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gtXHWnKMr9WB5CJdIm1VEcTqqQjHoG8va+Y X+57qiPKpOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLQAKCRAAQbq8MX7i mC22EACTJ1oYJdI/jH3Mk8BIbelop4SG8s08yql/bZfcv1x+PDI8uqU+FBC/c//aJVpOaNmDPXf BKFVqR3r5o9svjC82IAsKRD6ZW4JjGrUsn6QGJxHKS4eW+LGaNEduPnr+mb8GHT1YzDju2ZLDDh 97OQ/j4mVz5CVJdtlmcgAXHjVY/W15F2iE/PkRfVgVlsVeLdKuNGH5TSIyLZGSempxZvHHukxIT fPSopQAPDGFWZchtSzzA4TW50gevDU46kEYa54iqa2uVw2H+ne9qvXuXzesc+ddUGLFfqeF6oCD pjPw8F544ZDRfw3zMiqprjyD+bIE4WWpOfpu/iUJZ+rUMkUiMJdCYZbed6QMswj9r5iNTL2pCcO /t0jRtiUWkGaAjONSI2j2KJDWaFuqNNTkBXCnkniam5UQe85P9xfVPMHlbSMQo9pCl8/igVHNS9 23sfDJt0Qjw79Cdw6Rgzqu1Ps5KyO9o++c5QlvrYrUz7+jGim5GuLX5LtduNWUtAG4Dc3wzruFE qFhD9LokcPbKVyMTErbDonSV07AwRli6OFuAvYhMoZ/bkgpSN8onj2HbjGWJTrDk+D7fXcBgraY RLACo93enHMMfIutecbjQ8q7c5jIGTeZGlDtGAGqY/K90z3qI6yt1OA6DXlYOc4b94ASxJ4u8bR OB0SxNn84EAe9BQ== 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-20250217_073930_892862_D4906173 X-CRM114-Status: GOOD ( 10.48 ) 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 Commit 22779149e93d ("firmware: arm_ffa: Emit modalias for FF-A devices") added modalias for FF-A devices. However the macro added used SCMI incorrectly. Replace the reference to SCMI by FF-A and update the macro. (i.e. s/SCMI/FFA/) No functional change. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index dfda5ffc14db7208e8b622cdd648194c9cb1ef34..52b1f09209a0e51e321cd23a69aa7e4c4daa8dd1 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -15,7 +15,7 @@ #include "common.h" -#define SCMI_UEVENT_MODALIAS_FMT "arm_ffa:%04x:%pUb" +#define FFA_UEVENT_MODALIAS_FMT "arm_ffa:%04x:%pUb" static DEFINE_IDA(ffa_bus_id); @@ -68,7 +68,7 @@ static int ffa_device_uevent(const struct device *dev, struct kobj_uevent_env *e { const struct ffa_device *ffa_dev = to_ffa_dev(dev); - return add_uevent_var(env, "MODALIAS=" SCMI_UEVENT_MODALIAS_FMT, + return add_uevent_var(env, "MODALIAS=" FFA_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, &ffa_dev->uuid); } @@ -77,7 +77,7 @@ static ssize_t modalias_show(struct device *dev, { struct ffa_device *ffa_dev = to_ffa_dev(dev); - return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, + return sysfs_emit(buf, FFA_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, &ffa_dev->uuid); } static DEVICE_ATTR_RO(modalias); From patchwork Mon Feb 17 15:38:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978143 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 8196DC021AA for ; Mon, 17 Feb 2025 15:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=feOWQiVTfcgj6k9SopBCC1ZQ3AfHJw5e9aA+GLfs3SQ=; b=Y3tEO8iejp+1CUEYH8BBz5KSvM oeatZpBZvChctDUCAa1avU8Evz50iScaOFxplH4yaPThaH56fDB3v/r/p8QV55oIt42JruAGQ/orG nNDVqRdFFjiOo+ww23OvYEbS2BdwA2jxmc/RTWeRFpruZ1gj5Tq1RuXUZ4FgJToVcM8myiQFSaW7z xy7XaYW/0ylISXEKPrSe/G1AD+yQxsUt8QuLiznwYOLujzVSQQE8EzSsvqrHt0o+6Akr2WCMrhwmk oIsDijWxCF/IdNCj2usJ1QdCMPeIsak3OlBhAqRw5H0iPr5zdh9cTYF2EtrrCeCtvt7ZvkLfi9Lsl cvgQ4kig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3OM-000000058rG-37FP; Mon, 17 Feb 2025 15:50:42 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3DX-000000055Wl-1FXV for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:32 +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 10D8B176C; Mon, 17 Feb 2025 07:39:50 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2C96B3F6A8; Mon, 17 Feb 2025 07:39:30 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:43 +0000 Subject: [PATCH v3 02/19] firmware: arm_ffa: Replace UUID buffer to standard UUID format MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-2-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1834; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=41/PckYdXDOTJF8iWlnuSJNwd8OQjt77Kk+5Anq6r5U=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gujyDHIKZMNG7950DZexKR3aYwMRvLGf/k2 G9mgUW16smJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mHZ/D/wNF9tM7wzyNXUygi+AGta04YEYaQ9RmT6Vh64PQoapjffroFoi2W0QDJXXUqepbb0ErNE JzO6MLjbqRP6H4Q+cWQNZ9Fl31BbbIUpwiqMTyeDir/1dkSrSQ840i9DdBaSzVmrcZPs+vJ2BFN YjTqjoUcjZgvySN61u6M2duPKrARh02IPJ9WJMadGipV6vGW/sTzX5zKBkW8noYZT7TayLrNrV4 8czN/yo359zKxTqAIcoUJTenDgEJ0ubrEBtpnvpdbwm2AOniqlqJ4nkNd9dVZn2ox/CwL8mu71V re2GamEvkh2pRLD4+/4wdzmO6uMwReOSxsfNUiR/hb069YcwVF45gpoQeyOGDWrDLfY/vb+Gzfx u5WbcDoMBQ+fkO88uM2OVn7bAw7QUNVFZZYqbRAb81GyqSgYa7yG/0Zoi5/WzzCvA6xFji0w0lA pRqsrZRRLNBe9bMp2BM+pWz658nenMeXjZ2vhciYYZgKmov7jkTO4kN/PYS8pryqZNCe0OdEN9E +FGeSUk7MVr+RpWXSefHEU1WDThFV5hHUgjXQ4db+nOFCm/dk1IUU2+P83NujIVDo4jMrragsFJ m6jNPesiCF5ho35L2AQhYY7/QyzFSSPymBMEkcrEcfzWpS8nw/woTXdnus6N6JlxkoCqEhvXTx4 +AR8N6sI/Z+ixXA== 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-20250217_073931_383206_14609182 X-CRM114-Status: GOOD ( 11.64 ) 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 ffa_partition_info structure holds the UUID in the format compatible with the firmware interface. However, most of the functions in the FF-A core driver deals directly with uuid_t type. Replace UUID buffer to standard UUID format in the ffa_partition_info structure. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/bus.c | 4 +--- include/linux/arm_ffa.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index 52b1f09209a0e51e321cd23a69aa7e4c4daa8dd1..a90e2faa990219574ff20b8f573dbb7ca76137d9 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -192,7 +192,6 @@ ffa_device_register(const struct ffa_partition_info *part_info, const struct ffa_ops *ops) { int id, ret; - uuid_t uuid; struct device *dev; struct ffa_device *ffa_dev; @@ -218,8 +217,7 @@ ffa_device_register(const struct ffa_partition_info *part_info, ffa_dev->vm_id = part_info->id; ffa_dev->properties = part_info->properties; ffa_dev->ops = ops; - import_uuid(&uuid, (u8 *)part_info->uuid); - uuid_copy(&ffa_dev->uuid, &uuid); + uuid_copy(&ffa_dev->uuid, &part_info->uuid); ret = device_register(&ffa_dev->dev); if (ret) { diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 74169dd0f65948b05991732358855cdc31b54adb..abd0208f0f74c15ef4ee4c81de81eb7800a0eb1d 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -238,7 +238,7 @@ struct ffa_partition_info { /* partition runs in the AArch64 execution state. */ #define FFA_PARTITION_AARCH64_EXEC BIT(8) u32 properties; - u32 uuid[4]; + uuid_t uuid; }; static inline From patchwork Mon Feb 17 15:38:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978157 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 A9E6EC021A9 for ; Mon, 17 Feb 2025 15:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=WQMAbQUj8iCcX00cmVzvirLL3hMuCmxUKzghu3Z1kbA=; b=kAHnIA5BHwEA8Mti+BDjgdpxaJ csGSl8kha11lREV2ppuH39RusDv2aoQuu2fIeY+L4KDQzNambcYtcgIEt+D6SJfw4lNU7KNXAPB9y VJRtdsK9DkLykFW6nySLCZqwvOFG3xf7eMHYVMEBxtxHdUEtm2YJqOQUh0YNznIBvnfvSGnTm4zXO MTPKlro0C1YOS4UVlW5gpPjebvRMks8iHEWbFMlvoa3RG3DxALJ3R86XSvWBezNYr9W+QAS0UmXMQ wo/VXK+z7V/lkveCbxlDXGj3W1cWsbmxIrQVHmmunZ1Z1niM7pFpT0A/HyJ2ao2t7ZNMmqc8eSYrP YvUxOOaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Pn-000000059GA-25p2; Mon, 17 Feb 2025 15:52:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3DY-000000055XP-0kOp for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39: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 17C5D1A2D; Mon, 17 Feb 2025 07:39:51 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3300B3F6A8; Mon, 17 Feb 2025 07:39:31 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:44 +0000 Subject: [PATCH v3 03/19] firmware: arm_ffa: Align sync_send_receive{,2} function prototypes MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-3-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1999; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=4qW9fLAIK65nMpnh87qvF4rVxzPnc+20rA4dvUSmnYQ=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gu7Puq8FsTi5lz416LENDreOz5v7OyPXVSe MAvVyPesJqJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mBQ8D/9FoTUxJ10mqJW1QCCvDw2zaRD1zNKIp8ptdL/m8gxImTzVuSy29Sx/P8Tzucs35KikIAL 04W/Szqr9qtUH6pOi/YogCoA0LNWWamvHMqYGRYhqUu76kXiCJAlTyqFUTQDsMjJvlf1m0OJs6h JpLTGnQmtZyJNtHnMJrf7W36A8BbOzAovF0GKnXh9i3dF0nUwJTCHkjuOZCSJMGbejP8YKOEnQt Mktk1heaOCihOMCMaFHcELOrIoDXxfjqzPKwY/OUp31JvqJLW5sMeNQl5fBQxdyjrcSiUotHXIi nRCqBO9s7MkABh3zvDm1mLizXFXxy2pL+oem86tURZB5S25a77M2uj8jhwib5T01v5GuM3NDJ6Q 6Bboj+FsqBM7/eCDMvi/ABAd3bQYMnkq0MgE0BBTPivns35h5VCj+BSmehsMGo0YtEh48SyqKu7 b9nCvpts/PdC8GBtN08vvRwx/fR5sqs2BwbeeM6HakuItUlpVUNAhdFjFQC+8Q3YQZf613OBEzj qlOCU6B4rg1Gva9fOIeGfrxzrklfAbof8dkxsjoL5LUcV5lszWUZenIGw5462iomCioEltvjhtK DZl3R8EhNzsstvnZ0M43TFmDVZbF9eVzzIMoniXg76j9m2mRkJqFCS/M5TiJwpH+0tWS7DmQFej 7mS7Dv9alPgfS1Q== 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-20250217_073932_347534_8362DA97 X-CRM114-Status: GOOD ( 10.09 ) 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 ffa_sync_send_receive2() takes UUID as a separate parameter instead of using the one available in ffa_device structure. Change the prototype of ffa_sync_send_receive2() to align with the ffa_sync_send_receive() and use ffa_device->uuid. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 4 ++-- include/linux/arm_ffa.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 2c2ec3c35f15612168cdf0ef94022e00c08677b5..037e0d684994fd30971f40bf139367d1e45c1bf0 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1018,14 +1018,14 @@ static int ffa_indirect_msg_send(struct ffa_device *dev, void *buf, size_t sz) return ffa_msg_send2(drv_info->vm_id, dev->vm_id, buf, sz); } -static int ffa_sync_send_receive2(struct ffa_device *dev, const uuid_t *uuid, +static int ffa_sync_send_receive2(struct ffa_device *dev, struct ffa_send_direct_data2 *data) { if (!drv_info->msg_direct_req2_supp) return -EOPNOTSUPP; return ffa_msg_send_direct_req2(drv_info->vm_id, dev->vm_id, - uuid, data); + &dev->uuid, data); } static int ffa_memory_share(struct ffa_mem_ops_args *args) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index abd0208f0f74c15ef4ee4c81de81eb7800a0eb1d..e8b8ae8b192ab11d5550c16fd33fa9d192b07f67 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -439,7 +439,7 @@ struct ffa_msg_ops { int (*sync_send_receive)(struct ffa_device *dev, struct ffa_send_direct_data *data); int (*indirect_send)(struct ffa_device *dev, void *buf, size_t sz); - int (*sync_send_receive2)(struct ffa_device *dev, const uuid_t *uuid, + int (*sync_send_receive2)(struct ffa_device *dev, struct ffa_send_direct_data2 *data); }; From patchwork Mon Feb 17 15:38:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978158 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 5763BC021A9 for ; Mon, 17 Feb 2025 15:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=BiBRqPKPwoTjvCLxWk9I8YtTWfokUqMiJIhsMR9Lf5Q=; b=zLZxFJJ2XX4LEMCyzIpJmaIKNl l0ZWi237yh1vODzH/aan26Zs4Nbz3XWNRUSIhIAoNO5Z+k8HTKc5kRaCBQUl/BipWuoW9Z3tcd5hk XytaJcI8BAaUOaxMcfcJldpQ3HQm5Y06hVmCYompTPibfpkJh55NIU9CTQfMnB93XVlQky6ug2NSL 3t/VetuYGNtu7cpvF9eMk8EJeWU/fmDwXEQCS/Go8+AqPEizn3Py8/zuk2GIHlH4xGY1vjLKguRG0 Bbwf1V+rW9CYuEDpwhGAIHydgi199r1zXg0SKHYrIjvnyZ6V8D8l1zXfQOlvPtifYUk0vPBnKEWId 9G+Za8lQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3RF-000000059gh-0XsV; Mon, 17 Feb 2025 15:53:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3DZ-000000055Y5-0vjK for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39: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 1E6FA152B; Mon, 17 Feb 2025 07:39:52 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 39E633F6A8; Mon, 17 Feb 2025 07:39:32 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:45 +0000 Subject: [PATCH v3 04/19] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get() MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-4-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1786; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=kZ4/y9DUzlAVsB+B8wZcgeoxtKetDWyU/DxHjgkskJo=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1guejv910xM8qLwgUybkj8V3zFB0dE+XXyEL ysdpk5aHfWJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mB9jD/9pahw2bI9ZGgs+Lk8rfGttLPSDcZKs/caLMhRMeHBrLa98jGOCsq7AAOmndqBvzmxi475 GqdtBeW1KuVIuwXdS4ICus1lAcDpyhZpYK/L2MEHSn+CR0fX7Eutks2uLS+exiaKBXVPb+lcKG6 zOM1YJAc1T3UZ9PqECQWbIZlVmV0BxsIEmyvyyEO9yPULIv4/0aUiHQynQls2fPFpYKeD0PMlTY IAuSl8lpSvwfp7rXnBJ5gNfbPGMFoIYlsZ3NAJpyeKQf6mN2BOSCBtZSe8uLkOB5M+gxUY7HvmG OtiTcksj1+tv99gLS4x12FRFX2k/9SF6UbH1Qlf8t/PAaEaqNsFuVPT347VJjOk3ewrGU6WFj59 dABMEXM6g1Rvv5eKFXsD1qSJUiLGwU9WikpXYSXfFydH0keAh+gje6kEg2mGrrlhmCJ4HPJ0eEc kb11fIAYwSFlaa0ARoDi+f53GK5kpmz+WXeh8/NYJTOM7GL03QocyIBeKEwWGb2eXRkuQeHp6VJ bN0VQ5yMyAHqO5MhMl5MFO1RAp9S1kVlA1yb9Ayjl3+57gdiTX676BT0vLbNuR7XfU0lKAtm/Xs Ao9zj7VMe/lZFd520GOWh7FTmDVnCsG0vlp9YtvIgMQmx+2qht/76Sf8a93x7D5pujag+NXj+C1 J4OC1ciJuH9wqJQ== 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-20250217_073933_313242_5A370287 X-CRM114-Status: GOOD ( 13.18 ) 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 FF-A driver doesn't support big-endian correctly. It is hard to regularly test the setup due to lack of test infrastructure and tools. In order to support full stack, we need to take small steps in getting the support for big-endian kernel added slowly. This change fixes the support in __ffa_partition_info_get() so that the response from the firmware are converted correctly as required. With this change, we can enumerate all the FF-A devices correctly in the big-endian kernel. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 037e0d684994fd30971f40bf139367d1e45c1bf0..bc6ffd25ad2e2fea0fe3610cf896718dbed8f0ad 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -276,9 +276,21 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, } if (buffer && count <= num_partitions) - for (idx = 0; idx < count; idx++) - memcpy(buffer + idx, drv_info->rx_buffer + idx * sz, - buf_sz); + for (idx = 0; idx < count; idx++) { + struct ffa_partition_info_le { + __le16 id; + __le16 exec_ctxt; + __le32 properties; + uuid_t uuid; + } *rx_buf = drv_info->rx_buffer + idx * sz; + struct ffa_partition_info *buf = buffer + idx; + + buf->id = le16_to_cpu(rx_buf->id); + buf->exec_ctxt = le16_to_cpu(rx_buf->exec_ctxt); + buf->properties = le32_to_cpu(rx_buf->properties); + if (buf_sz > 8) + import_uuid(&buf->uuid, (u8 *)&rx_buf->uuid); + } ffa_rx_release(); From patchwork Mon Feb 17 15:38:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978159 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 7A3AEC021A9 for ; Mon, 17 Feb 2025 15:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=1u8wXzo5hiqn9vO3x0T8iv1O+rtKz0TIe0ExrEGiJ9Y=; b=Ai/6gsxFgi5VzauG/+Su98XNi+ swr0SmXyF5XEm1gINnOkcgHdPKKOLkClzA0RcNV/InoyeenEspr55KWx6Cuel++C2CKaS7R2NpFb4 5fwIngjNSEjMBlhs9D9b3Smk2oPGVQyRSXh9K6mBkao5B9hCGoq0sMm1VrGNIGW1uhzlKlTeUV9gD QTd5YrWlb/RrZ7I59MEBBsZkEJ5xm/WH9MK4p9XxRQaGF1wpIdtnMixiH5mBWiSmLw60/rmxM6+zC PLlKRrYKt/9jCTk6fBzHUZ/IKa/a8ufskUBQtK4jGO5h6ureOEerNk7Xgv1GLEYVxEp+ndXmVgU7l xnfUO+rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Sf-00000005A4S-3lVT; Mon, 17 Feb 2025 15:55:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Da-000000055XP-0mLp for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39: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 282881692; Mon, 17 Feb 2025 07:39:53 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 417D83F6A8; Mon, 17 Feb 2025 07:39:33 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:46 +0000 Subject: [PATCH v3 05/19] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get() MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-5-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3021; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ZiI+o4/xD0+sVTO80TuOTg2mkZUoOiDa0Hm9f3l0JUE=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1guew0YRkg8z32s3kG6Fe1sx95jZL5K1KIVT gWi0evAxp+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mPDnEACqI8MINPPKKOLiDxwBMxxWvLh8vA/CCDimYHgIW4Y2Qv2QbO5GG88LWxeTrxFp+2PUni5 DeEGMHWmnLemPp8FxjTBf47KzdHk/4GHhNCWxO/oVYw3cKL/5w5MyR0GGI26Qh+dwiU8TaNDEvL pLxRudQcrRof9vNxkCfVaIbGbnja6Ee6HSDxZip4JVKLBRKtKlF9K6E15NFxDb00GiTw6c/CHA6 TnPuVGffcoVZINhWU7T+BnuEvIliZNmUQt6N26VmgvgSGn7QSLBOU8LlYiJM/Om25D3N2rYEF/g 4hXDxbUiCnbvy4nowvMg7JCQZSThhRqwUXFMeu2K+MMWnoBTG2jPyj8mXx/7HcBW6Jcs8Luj0d4 QVH3Jnio1389tb/SEdXKL1g7L/ZfiiMome3GACtDRTDloo4uaZYAwmUv94vZkeC/NUIe8ehdixq oqvq9iFCvPbElDMOhmrOo8RGgvWdQTTXvSaT4v0I2doPRKhoBmsUizTQupKOKkeaDytIql4U77U SHbxcbnR2relc68vKHSnH+PH+IOmJDDVfulOmPtLG5qURlsIybcvq/ShKiXXdL5ivSlIXiBX0qD GjPLiMmTGcWRkZLxTDaWHhTGBQ2BrnMtmsNQJFTpxoGdzCbbzNBQJeJGjOm5lepGsppBHecr8N6 csc1WG1viaKNb3Q== 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-20250217_073934_359111_25459DB4 X-CRM114-Status: GOOD ( 14.71 ) 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 FF-A driver doesn't support big-endian correctly. It is hard to regularly test the setup due to lack of test infrastructure and tools. In order to support full stack, we need to take small steps in getting the support for big-endian kernel added slowly. This change fixes the support in __ffa_partition_info_regs_get() so that the response from the firmware are converted correctly as required. With this change, we can enumerate all the FF-A devices correctly in the big-endian kernel if the FFA_PARTITION_INFO_REGS_GET is supported. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index bc6ffd25ad2e2fea0fe3610cf896718dbed8f0ad..87e106c728b89f3ce7c11219cf7cad9cc166dda2 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -307,14 +307,24 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, #define CURRENT_INDEX(x) ((u16)(FIELD_GET(CURRENT_INDEX_MASK, (x)))) #define UUID_INFO_TAG(x) ((u16)(FIELD_GET(UUID_INFO_TAG_MASK, (x)))) #define PARTITION_INFO_SZ(x) ((u16)(FIELD_GET(PARTITION_INFO_SZ_MASK, (x)))) +#define PART_INFO_ID_MASK GENMASK(15, 0) +#define PART_INFO_EXEC_CXT_MASK GENMASK(31, 16) +#define PART_INFO_PROPS_MASK GENMASK(63, 32) +#define PART_INFO_ID(x) ((u16)(FIELD_GET(PART_INFO_ID_MASK, (x)))) +#define PART_INFO_EXEC_CXT(x) ((u16)(FIELD_GET(PART_INFO_EXEC_CXT_MASK, (x)))) +#define PART_INFO_PROPERTIES(x) ((u32)(FIELD_GET(PART_INFO_PROPS_MASK, (x)))) static int __ffa_partition_info_get_regs(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, struct ffa_partition_info *buffer, int num_parts) { u16 buf_sz, start_idx, cur_idx, count = 0, prev_idx = 0, tag = 0; + struct ffa_partition_info *buf = buffer; ffa_value_t partition_info; do { + __le64 *regs; + int idx; + start_idx = prev_idx ? prev_idx + 1 : 0; invoke_ffa_fn((ffa_value_t){ @@ -338,8 +348,25 @@ __ffa_partition_info_get_regs(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, if (buf_sz > sizeof(*buffer)) buf_sz = sizeof(*buffer); - memcpy(buffer + prev_idx * buf_sz, &partition_info.a3, - (cur_idx - start_idx + 1) * buf_sz); + regs = (void *)&partition_info.a3; + for (idx = 0; idx < cur_idx - start_idx + 1; idx++, buf++) { + union { + uuid_t uuid; + u64 regs[2]; + } uuid_regs = { + .regs = { + le64_to_cpu(*(regs + 1)), + le64_to_cpu(*(regs + 2)), + } + }; + u64 val = *(u64 *)regs; + + buf->id = PART_INFO_ID(val); + buf->exec_ctxt = PART_INFO_EXEC_CXT(val); + buf->properties = PART_INFO_PROPERTIES(val); + uuid_copy(&buf->uuid, &uuid_regs.uuid); + regs += 3; + } prev_idx = cur_idx; } while (cur_idx < (count - 1)); From patchwork Mon Feb 17 15:38:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978162 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 2AC6CC021AA for ; Mon, 17 Feb 2025 15:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=3ldEvxm++ErwgHwnpJt3Ghq4YXVW+8w1frETmAkJhv0=; b=Xo5B0tpuVJiJbCL3FkJ2XtV+D6 uqZ5mcBUvbLFMibZwpoX8C6EU+/MA77HfBW58gEsiOUyn/CUs8xE3FBlV2WOcsSyk/VrnV23I3QTg jpUZJ5IpGPe9moahbsK9JMBvq6ESIDpoQOwg2c8VWbiTmhQHbncy5ONwoi5yhaquwLa2+acE/qlae Aw4WagDSYmYq0c3ZAnIbRFGMiujkm3YWjHRKyg1p7pXKuGUYMTk2FBh9H+s0eEYIHkScvSK8HhcJE LUDCa0sPs8BFzRmGqFJ3hPnq38ei3oAG0pqCqKhmpGMeLmbv9sbNeXH/Todvk01PXwGKMT0FJWpTd stJpww8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3U7-00000005ARC-2TPq; Mon, 17 Feb 2025 15:56:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Db-000000055Y5-0tx3 for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:36 +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 2E9F0176C; Mon, 17 Feb 2025 07:39:54 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4A9BD3F6A8; Mon, 17 Feb 2025 07:39:34 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:47 +0000 Subject: [PATCH v3 06/19] firmware: arm_ffa: Refactor addition of partition information into XArray MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-6-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2738; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=0rtRvJYON+bBWGuI7xH2qiK+GlnT4NIkX7bmwfVc55I=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1guRY129t9hXimLHH74gX733HjYK1vFoEV4y d/024VfviOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mMHKEADOvrF2of7ReK/hGLkBM+iIObw4IIA0HmrXAFytlxoBicuIytplDbeoHH79vLASlI/rxRH RpQTqCpnksJoCYpvbxG5VdmoT8OyNFcXiqqk8VefIf12hdJ0Gk9aeFcBPFTS+S+hNoyWfIxG6bD R14rbzRMW5EdcHjMfF6WmMDtwD/3O30WKnPI/lwPXnEXybXM+Xk3mluoLJqRZ7JuoaHXw2Fck+S nUhpNqofZpD7ZRh0iSEIjh7huhnndAtmBLnspDBZc3Jam1E4IXpBOup8J28856MA8tla1GY4E+3 34W01AUozEa4nBRE3i0C9cuoBBvdDso8ttYfyRgp8DJAnULg+pBO4474v8gpa8sOYRdreg9Ld7n brF9PGKN7J/BPecen8nTeHDH6c58ZgNFz0IB157P8VPM48IaFMUEUgBeZ1/DBc7Ddsf8Xi0Wq91 oEmJzoHf8T54WGQVu+W5YRt8LXwAMiI4Q954zF9R/n8OBducc+4U93WwIlDsO54/yUE5iEaP4sK saT4p2yXQ4CEVCnFiB40T2QEJIQpCDsgBkLKjtUQn96d+3iz/ZNiidEpQy1ZMiCMacwpWSlWqTF dZh7pbCu/nGirN5ZNj1pHcTL1y5SSY2jZXPfuLG/Vuo862zQztTYD+CyIgruVdY3PEnj14lP0+P Fs8G1PXRgcaYCBw== 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-20250217_073935_412634_592CA29B X-CRM114-Status: GOOD ( 13.25 ) 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 From: Viresh Kumar Move the common code handling addition of the FF-A partition information into the XArray as a new routine. No functional change. Signed-off-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 47 ++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 87e106c728b89f3ce7c11219cf7cad9cc166dda2..2994b5ee63bc7feafc15e535cf8a2d46e6003968 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1423,11 +1423,30 @@ static struct notifier_block ffa_bus_nb = { .notifier_call = ffa_bus_notifier, }; +static int ffa_xa_add_partition_info(int vm_id) +{ + struct ffa_dev_part_info *info; + int ret; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + rwlock_init(&info->rw_lock); + ret = xa_insert(&drv_info->partition_info, vm_id, info, GFP_KERNEL); + if (ret) { + pr_err("%s: failed to save partition ID 0x%x - ret:%d. Abort.\n", + __func__, vm_id, ret); + kfree(info); + } + + return ret; +} + static int ffa_setup_partitions(void) { int count, idx, ret; struct ffa_device *ffa_dev; - struct ffa_dev_part_info *info; struct ffa_partition_info *pbuf, *tpbuf; if (drv_info->version == FFA_VERSION_1_0) { @@ -1461,39 +1480,17 @@ static int ffa_setup_partitions(void) !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) ffa_mode_32bit_set(ffa_dev); - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { + if (ffa_xa_add_partition_info(ffa_dev->vm_id)) { ffa_device_unregister(ffa_dev); continue; } - rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, tpbuf->id, - info, GFP_KERNEL); - if (ret) { - pr_err("%s: failed to save partition ID 0x%x - ret:%d\n", - __func__, tpbuf->id, ret); - ffa_device_unregister(ffa_dev); - kfree(info); - } } kfree(pbuf); /* Allocate for the host */ - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { - /* Already registered devices are freed on bus_exit */ - ffa_partitions_cleanup(); - return -ENOMEM; - } - - rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, drv_info->vm_id, - info, GFP_KERNEL); + ret = ffa_xa_add_partition_info(drv_info->vm_id); if (ret) { - pr_err("%s: failed to save Host partition ID 0x%x - ret:%d. Abort.\n", - __func__, drv_info->vm_id, ret); - kfree(info); /* Already registered devices are freed on bus_exit */ ffa_partitions_cleanup(); } From patchwork Mon Feb 17 15:38:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978163 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 59BC2C021A9 for ; Mon, 17 Feb 2025 15:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=D8TvCK+RG35R/4gv0hNWzadg5EF52sa9a+taDqgEb+4=; b=vRfOOv5158QD4lSqSKfW9ba5Jd /v2TiO/i1QX0DYuJi0vA3DspfEAsjxgLBbKxAVApUtUKzmoka/ZM24nbYhNyUAyptym3JqlDSX72v b4grwafw29xp6tU1OrupH1qwrxI9rDDEjTL/ycKi+JoEpXLwn2TRiDb4L3AB6/9h5fv35rM4ifxDO O8TYypu9aWyl5VHPNpL9zu7Dslo6otOE34d/Lgx7RF8ONkHVQdgF9EsvjKCQwClSgD82u2l2DMK0U 5bAfF/FaOxVV5RLLSchdh16vmxNbt9Jq9oP6eocBuPeBZKTMbPXsOD7gBSrrFO8P7hrtrXH62imvt QssQayIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3VZ-00000005AlE-12Qu; Mon, 17 Feb 2025 15:58:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dc-000000055XP-0pTE for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:37 +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 34A01152B; Mon, 17 Feb 2025 07:39:55 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 50C3B3F6A8; Mon, 17 Feb 2025 07:39:35 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:48 +0000 Subject: [PATCH v3 07/19] firmware: arm_ffa: Handle the presence of host partition in the partition info MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-7-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1299; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=6tk8gj2eQR3xF36vKVIBCFo6uvkjtZ49zGerQFo2eXY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1guFR2P3ZAYTDXm79bampucM4MzsML2AAF1Z wlfbUOBIBOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mA9gEAC/s7Ip5MiS5BNwl3ycwMoksoHHeMdXCXWGldQWd4NYn/MI0Vp63/rrUiQp2ZPkfPobLD9 aIyQP/QiPRSsl0uPiJbJxUjgKVGWxtXzIkmuC6w6nqzEDWpw6lbSHe55e3WIVuMCBBSS24VRYN2 XsI91tS+cOQMftfLSXmBW4RJgwB4f7zVhz2nxOJTCe5zmlLl5hc4V1NFCFii5d4lRkx8wiKbK7g GvmeTPDyPFx+cwSfiCrVAhrQ12TW1HcoJTZ7L8Gb2OKdaLSDAJop6/HHzXL9SmuFHX2XVFfW/+K A20jqhQzcYikgSN5Gw5edq7eCiY9hSodIXBm7vfmpJxbzd8Ac7EkWlwcL0sB2EmKDnOhnMYe7Ka nKcGpQ3c9e4Jf9GojZ47uFmw8h8iOuQTTVpdd/Y8nJTetRb/VahjdnTDUouyTtNMc/nsSwSieKf J679LyxffXfO3gqNU1sFd9stK/Z8lU9cf99g5WzJV3y0NT5d1tjrn9MbBZZ/cQgIbpGaiA3k89L GckMHKc47WtYpJB1GUVoy6dLWANzF/YkvznKT0oB7olu5avlhOCBUm4lufyumg9i2zw4tfngNPD edeHnGh/82UGjpO5pF6o6+ahLiZzlQHrEc+QrJAi6jRTFXZcqbFY5z6DzZ9H6q4b9UHOjI7aq/4 VRN2Luipkw1WgDA== 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-20250217_073936_287355_D766245F X-CRM114-Status: GOOD ( 13.93 ) 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 it is assumed that the firmware doesn't present the host partition in the list of partitions presented as part of the response to PARTITION_INFO_GET from the firmware. However, there are few platforms that prefer to present the same in the list of partitions. It is not manadatory but not restricted as well. So handle the same by making sure to check the presence of the host VM ID in the XArray partition information maintained/managed in the driver before attempting to add it. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 2994b5ee63bc7feafc15e535cf8a2d46e6003968..320ae654cb968ef573995764d9d35c027d74a33b 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1488,6 +1488,10 @@ static int ffa_setup_partitions(void) kfree(pbuf); + /* Check if the host is already added as part of partition info */ + if (xa_load(&drv_info->partition_info, drv_info->vm_id)) + return 0; + /* Allocate for the host */ ret = ffa_xa_add_partition_info(drv_info->vm_id); if (ret) { From patchwork Mon Feb 17 15:38:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978164 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 9B811C021A9 for ; Mon, 17 Feb 2025 15:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=sZljUhDAaIbwBXVY0NW4JGKeQALy7gLhdnTD3y9QYGs=; b=PFHCD9s//+ibheVQwvLSkSn0Do 5YQ8TXTPhZI9zVbwAX1o/XXTDYv4sST7JGPKAB0dtzsid4HrIOtkHopMTuFdll4T9MVNjf1XPG7lQ NLYyaZUecah+IAbFRN1v68sc2naIJcbBS6snWS1Z8p6eiEvzBV2aRr7DGt1ZUcdPEMjogd4YTAoB8 qmHSuaRxoUwq1k8bShpUT+VUFuP429eYue5yaiGfNbuL9L/MvMXMRezJHcIb5S/AkrZ7KK0uchTvk SXhBgYhAbWgh4WGYOaJa+MAMesYZ8m6SWGK+0C3qKIxCLi0Y+vl3XRKWsxz745KmWuVcs0KfSXPc2 ATsMMIyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Wz-00000005B6U-3u6C; Mon, 17 Feb 2025 15:59:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dd-000000055Y5-18p1 for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:38 +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 3AF0E1692; Mon, 17 Feb 2025 07:39:56 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 56CF93F6A8; Mon, 17 Feb 2025 07:39:36 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:49 +0000 Subject: [PATCH v3 08/19] firmware: arm_ffa: Unregister the FF-A devices when cleaning up the partitions MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-8-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3415; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=CA2RijW3yPILwx1/OXMstwMKjb68ASRuKWZ5cgdYTQs=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1guyFPoPxfC649z/cShDaUBytdN/cFh7Om9t q5vMrXbLhmJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mMyYEACuESYGrK9KRhjys6cOVqqLW/jAYRg/LwHwJhd9ot3ZD+MFCPOtC+LqXemzo/0S2Yx7qFB /ndyi7IiC/PuVNvVpKHbm9gzKfDp2DZsezHD3cZO//V+yaiK89qJjDx/i8uBXbckCS/+f8ozmdx bgDF4z05j/GXIwk/kK9jvDEhVG5Qje3J638qPSc3b4O1jSXHP57lOJRN2oZt///hH+mgCPmPz4/ tusFTbCdhVd0HBWiSh8Q/EAgNY1hqMx/bUhw9IZ/BrjUc8QE4IGtRuxiWiDfAE7L//a6FAnf1Wx +eM/pDneWpqZE4jxPhNem8wjGGUGLme0CigUk3tgWbUGn0FTdDd3yERR1ktZFLE2p+3roD1sXm2 jP3TBBq3WeKs5S8dMLxqQCNrNtLK4CAt3pf1izRN9ShjEmUv2dUE1m75ySTehd60ty9gtnBTCNj xB6mMNqmWaxSTkWNMCEvPpLKphQW8FwRDSE5J29V1/TVPIYiG/UVbsaAI7oW33K5VxPsGSuGkja twI6oibVzAw7suI019KhCWVCxreKt2pWV36/0paIVe9ba+Fb3yaK0tC5GQaKckDeCcLKeVrmmI9 PronMylys9uSbAD/Ikpns2nECa399A44lovmL5COCS4XdSEfI1oLZNl1qymjihO8LG+QrE1WUU+ 3HVjghivFojaIkA== 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-20250217_073937_414620_4DDA7883 X-CRM114-Status: GOOD ( 13.21 ) 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 Both the FF-A core and the bus were in a single module before the commit 18c250bd7ed0 ("firmware: arm_ffa: Split bus and driver into distinct modules"). The arm_ffa_bus_exit() takes care of unregistering all the FF-A devices. Now that there are 2 distinct modules, if the core driver is unloaded and reloaded, it will end up adding duplicate FF-A devices as the previously registered devices weren't unregistered when we cleaned up the modules. Fix the same by unregistering all the FF-A devices on the FF-A bus during the cleaning up of the partitions and hence the cleanup of the module. Fixes: 18c250bd7ed0 ("firmware: arm_ffa: Split bus and driver into distinct modules") Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/bus.c | 3 ++- drivers/firmware/arm_ffa/driver.c | 7 ++++--- include/linux/arm_ffa.h | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index a90e2faa990219574ff20b8f573dbb7ca76137d9..98118823cf84969480fc25c937881f9b773a38c2 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -160,11 +160,12 @@ static int __ffa_devices_unregister(struct device *dev, void *data) return 0; } -static void ffa_devices_unregister(void) +void ffa_devices_unregister(void) { bus_for_each_dev(&ffa_bus_type, NULL, NULL, __ffa_devices_unregister); } +EXPORT_SYMBOL_GPL(ffa_devices_unregister); bool ffa_device_is_valid(struct ffa_device *ffa_dev) { diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 320ae654cb968ef573995764d9d35c027d74a33b..15305920ca9f2bcc72ac7453080f5c10430a3e26 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1494,10 +1494,8 @@ static int ffa_setup_partitions(void) /* Allocate for the host */ ret = ffa_xa_add_partition_info(drv_info->vm_id); - if (ret) { - /* Already registered devices are freed on bus_exit */ + if (ret) ffa_partitions_cleanup(); - } return ret; } @@ -1507,6 +1505,9 @@ static void ffa_partitions_cleanup(void) struct ffa_dev_part_info *info; unsigned long idx; + /* Clean up/free all registered devices */ + ffa_devices_unregister(); + xa_for_each(&drv_info->partition_info, idx, info) { xa_erase(&drv_info->partition_info, idx); kfree(info); diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index e8b8ae8b192ab11d5550c16fd33fa9d192b07f67..ca2ad5b0ac4309052d55dcf546d29423bbd40a67 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -176,6 +176,7 @@ void ffa_device_unregister(struct ffa_device *ffa_dev); int ffa_driver_register(struct ffa_driver *driver, struct module *owner, const char *mod_name); void ffa_driver_unregister(struct ffa_driver *driver); +void ffa_devices_unregister(void); bool ffa_device_is_valid(struct ffa_device *ffa_dev); #else @@ -188,6 +189,8 @@ ffa_device_register(const struct ffa_partition_info *part_info, static inline void ffa_device_unregister(struct ffa_device *dev) {} +static inline void ffa_devices_unregister(void) {} + static inline int ffa_driver_register(struct ffa_driver *driver, struct module *owner, const char *mod_name) From patchwork Mon Feb 17 15:38:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978165 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 B83D1C021A9 for ; Mon, 17 Feb 2025 16:01: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=r5Gz+eTflbpmy1n1NWxy8gWni1C+C4lEteb9Jr1lcBQ=; b=NKcVvgMLcEXxiXoyM/c2otw7Xx +iPECMNImCCq9pirnC7FiL4IT9PssMlDnzkh/FkaxSrchW0HB3b0Z7WJmQcefrmL8IFy5ImXgttrt 2Y1yIwJO/x7roKQ4N4LtW3GfaLnMTB+bm1bNYfQbiqfRuEuTCQSUaGqEyQGKFb0SmvmRn/+e70aMl YKwf4mDtkuDUaNJQyT//uccCDj9KAysGft59SWYaDHaeFr54W6Xar+/8DPVXwpIwWoGI6xQBB+Ct1 XbsEO+LAZOdSUPZpTBs2A9yXuBcJ38DZ9nN5BqaGxA9Eu4zYuFaR47LJk97VsvbDnwGSdlBQYCi2S QZTHOGhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3YR-00000005BUA-06WE; Mon, 17 Feb 2025 16:01:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3De-000000055XP-15GO for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:39 +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 41AE7152B; Mon, 17 Feb 2025 07:39:57 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5D1893F6A8; Mon, 17 Feb 2025 07:39:37 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:50 +0000 Subject: [PATCH v3 09/19] firmware: arm_ffa: Helper to check if a partition can receive REQUEST2 messages MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-9-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1512; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=zb/wqtoceP7rQokuw62BwnrJfaGX30KLx6uKJCNJ5iw=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1guSUwasvblxx/05UyIRKxy/I2B9unSMhxyG raJkTYz1OSJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mMp8D/4/tj2RDchJ64EabNb246U+JEB/pRicqivUqcuoWmC3Tsy4/aSFlfVEXIZmuhg/ilgVQ4e 2kTvf/7GSfe6YiSvES3quVM0Wf/LUD0KrRdlFBroWG0iHKc7e/VE3lwjaZEYanb8iKy5mqzJn6i 8HpvWx1N3ginxjHPAJHmmJ8hrPsU7C68YUOF7yl4byyqBn7csqg/W3dt3cjuIuhC2IRG309CiQI kf3N50b2GxkNe0z/Pire1vXcgzpVGsdmuVBJAAQdRMo+RNi9URFSje7Ka69uGoiv1UBGWE71cYr 0wPKPVLZv7C1yiYmPzrOL7lrvn7adANkfT7cp3mmgdkyb4s6jEuCGdLPZzctEzqzyDj0KbMXYWh /8OaoRlbcQfaPVYO3ldgrQ7GlcIgcfiI+O0VwYQD7BkaSbbbfrUmr4Ml5OY2S+BAHoaMFDxzZB8 42c9ro5qWFg4X/zoztQN7561Bj+ndVzjcKuKq+FT0OJs13AUTv5pBgZ9y4qiYyCTl7OjvBvkjFY xLPB2Go2S5os3L2NcIIbW63S2BrMTKIdinK2VwfR7DkU4TABTJyU942nB19dzE50sjHKhEhSn9M S5GXOLQDumOIsx++hDCMhUyOUxyeWZlysx4AcGZ0kjc1VeqkDL0MEFBpom57pvkKScjJ5JJvRcy QTijAplkgLHANMA== 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-20250217_073938_341826_34D09122 X-CRM114-Status: UNSURE ( 9.08 ) X-CRM114-Notice: Please train this message. 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 Add a helper that allows FF-A drivers to check if the partition can receive the direct requests via the FFA_MSG_SEND_DIRECT_REQ2 ABI. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- include/linux/arm_ffa.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index ca2ad5b0ac4309052d55dcf546d29423bbd40a67..761ea8fe3bb6080c893a5eb365358b62d6a4f3ff 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -240,6 +240,10 @@ struct ffa_partition_info { #define FFA_PARTITION_NOTIFICATION_RECV BIT(3) /* partition runs in the AArch64 execution state. */ #define FFA_PARTITION_AARCH64_EXEC BIT(8) +/* partition supports receipt of direct request2 */ +#define FFA_PARTITION_DIRECT_REQ2_RECV BIT(9) +/* partition can send direct request2. */ +#define FFA_PARTITION_DIRECT_REQ2_SEND BIT(10) u32 properties; uuid_t uuid; }; @@ -259,6 +263,10 @@ bool ffa_partition_check_property(struct ffa_device *dev, u32 property) #define ffa_partition_supports_direct_recv(dev) \ ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_RECV) +#define ffa_partition_supports_direct_req2_recv(dev) \ + (ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_REQ2_RECV) && \ + !dev->mode_32bit) + /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */ struct ffa_send_direct_data { unsigned long data0; /* w3/x3 */ From patchwork Mon Feb 17 15:38:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978166 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 18CE7C021AA for ; Mon, 17 Feb 2025 16:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=r1EFFVSKbR2MgjGy6X0+HcfFrrxAeGmYrZyOv60rVVA=; b=nIB95Tp1CxpDSxyOlaHtAHxr1b 8slKQ2pxpW5DjP03o6CZAQz2ayISJLRtjRpHcUHNVmX3Y1wvurOqWTBMEBgxx+2VH7rVUH3fHzson OZdGcOuWdmxK4d6wRhSa4ozlKXdm2MaEe2zaLnIFiIv3ZFaghDfwOtKCcR/J2XLW9n8E3wa0BVvxw a22vjYVFmCqrp06RQupcGqcBhkrq0Fs0PlIB7pjzSEbnK6wv6obsshJlMztyxblGBd3UCVX5bvvHV GmBKtYMSZLIeYFRvKG7aKAP9+qU+uw4wVdUPbQ3XmPGnZhCeHKd6bpNlliQ5U6+Df2UUPlPIBBVLO GqcykQjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Zr-00000005Bn1-2qZf; Mon, 17 Feb 2025 16:02:35 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Df-000000055Y5-1KMI for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:40 +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 4793D176C; Mon, 17 Feb 2025 07:39:58 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 63A1C3F6A8; Mon, 17 Feb 2025 07:39:38 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:51 +0000 Subject: [PATCH v3 10/19] firmware: arm_ffa: Add support for passing UUID in FFA_MSG_SEND2 MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-10-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2319; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=U2Pa8cgrduaKloppfthrgCFfrEI2zJBMeuwy12YpDv4=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gua4jzwB8ulT/HsdvweBObDE1MNmOMPFzpk RyPkgFi3/OJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mMiPD/4vawnoANQaxp+gh1u2/cX44bGHYZ5/NH28+CSRb0xMCouFdQzW5sJqifa9lzHIgJBku8T dmmkt3fGIjpBMxHbQt1rSRmQ+7jQgaz4mIGT3Wbg9YrmJ8TfQc3hQ3pCiV/2xHXe7WOQqDSO0AY jKM99UbiLYzLjQf1JdjXOa74Z0mZ3cBySjgQYtbXXwL9aGTMQBi96JIlsEsoAGUbpX3PQL0PF+8 KVHPGeoLfYs+ZdKRKqfLBR+uTbRCl0vPhid7KhT+jrdxr2Kf1apAnKiYZ/tnkb/Eq8RWugjYXi9 IPq0usqoqRHERdyu78TcoEPWC0mTylDZnd7hP1697xKocPFQLi17YkLcjwUsUdQK5SgN6oFtUrn 7AcfATZ6i7TLu5U1KZVGis6YLETe+bYPWRPxD8q16NWgoOClx7SQ2TrZlQx2O9INr68DSzsNsOc kqA7raV8CYynrpoemGbRLefBxODP7k8ha2B5knh+PK+EsUzLbGDDddqszTW3cx9uIRNRmEjFSSB s1tFPZ5e26fPYqBL+EQ52KdoTiDvjNDPQAyQ6ulCV9Lrb161E1WZ9/O1M5qiM1GY4hmyYssgzmG ZHGWf4s87GUs4mkli4Dj4k4O0fHJlsPXc7EkOHlPiS8hhtfhPSwIXOOSpPaeSzmbIsg5sMjiNfF nKiwdWZlibXW3yw== 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-20250217_073939_498597_41850CB7 X-CRM114-Status: GOOD ( 11.60 ) 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 v1.2 introduces UUID field in partition message header used in FFA_MSG_SEND2 to enable partitions/endpoints exposing multiple UUIDs. Add the support for passing UUID in FFA_MSG_SEND2. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 7 ++++--- include/linux/arm_ffa.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 15305920ca9f2bcc72ac7453080f5c10430a3e26..545b1772df0095787b20332a7d5189c71bd5cacd 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -484,9 +484,9 @@ static int ffa_msg_send_direct_req(u16 src_id, u16 dst_id, bool mode_32bit, return -EINVAL; } -static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz) +static int ffa_msg_send2(struct ffa_device *dev, u16 src_id, void *buf, size_t sz) { - u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id); + u32 src_dst_ids = PACK_TARGET_INFO(src_id, dev->vm_id); struct ffa_indirect_msg_hdr *msg; ffa_value_t ret; int retval = 0; @@ -502,6 +502,7 @@ static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz) msg->offset = sizeof(*msg); msg->send_recv_id = src_dst_ids; msg->size = sz; + uuid_copy(&msg->uuid, &dev->uuid); memcpy((u8 *)msg + msg->offset, buf, sz); /* flags = 0, sender VMID = 0 works for both physical/virtual NS */ @@ -1054,7 +1055,7 @@ static int ffa_sync_send_receive(struct ffa_device *dev, static int ffa_indirect_msg_send(struct ffa_device *dev, void *buf, size_t sz) { - return ffa_msg_send2(drv_info->vm_id, dev->vm_id, buf, sz); + return ffa_msg_send2(dev, drv_info->vm_id, buf, sz); } static int ffa_sync_send_receive2(struct ffa_device *dev, diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 761ea8fe3bb6080c893a5eb365358b62d6a4f3ff..bd78deeff284e2f46d42cfc7af218f4a0f3d1478 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -282,6 +282,7 @@ struct ffa_indirect_msg_hdr { u32 offset; u32 send_recv_id; u32 size; + uuid_t uuid; }; /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP}2 which pass data via registers */ From patchwork Mon Feb 17 15:38:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978167 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 98ADAC021AA for ; Mon, 17 Feb 2025 16:04: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=/aMdmdeuG4GwO+gqHcxrSjamR9dGEFQfEwNfU4KLuoQ=; b=pBdhZagK9sin4cdAYaGUORcIip mKQVSblgI+p+lv7reATxV/mkFJ7rO3Vvckcr4KHLZYuV7jIK2Q/6cFU4P+kVLy9wup18C7Hnw/WOY xHF/ujfeioJq2LoOsiAOPC2W/ORK1cDfKYSRz7QiNi3IfHPuSILa7ACeiHnG1LzIoLUKwcK3OePYP g352AVHxR2Jnt8s8uU5gOK3rHy5yF4ujXdss9VkGPbz8Irs9X4Ayp8G+Ddt7XOM2vPWL6VlGs5Ls3 vh/BslqtNRZhIAYgBgr1zDgnVQRjdEVpjGgsERk/bb+3Nz1VZ0t9eXlLHR/T+NRipEps5gmH9BJ9n D573qDiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3bJ-00000005C4p-1RAc; Mon, 17 Feb 2025 16:04:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dg-000000055XP-1Gan for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:41 +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 4E086152B; Mon, 17 Feb 2025 07:39:59 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A0AB3F6A8; Mon, 17 Feb 2025 07:39:39 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:52 +0000 Subject: [PATCH v3 11/19] firmware: arm_ffa: Upgrade FF-A version to v1.2 in the driver MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-11-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1423; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=hSnmX8m0IsvUg6QjDxQaXp5gbNOPxEHIjGzf5RS8CBA=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gutymg8h1/T86Z4nSr1TM+hJU4oaA7tvNo7 9DWTozgOcKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLgAKCRAAQbq8MX7i mMPdEACymHmnWTf7JKO7Y7K3csg+AiOXdSGzbiUCwVe6V+Fa8bQ5plLUh5t9vUjPJvUraFC4/Ac rvwwJ9BYf6CrurMqCa9hgnDrehOdAlMObRIkCZpWDh/2s48+p+mJkOvnHGLCc/7efYK/vzrOpiS 3bfCcFbRoUZqOPs6Gwnxjkh2ZqfECWCIBJquk+QYhqiXZTjkmuYsXQeyKUP6vCdt4n5ICCL/w4o WY6DWVlhC9bpkKJVbooYdRFAv9SyqCj3jT+TokwlHRVkSmdyhzmeOsS9B5+EaNQaQSPGBb4K90k Mj52pChrkVJKpwRll1T5BnCj4047Ikn0/q30pmCud/i7S4wTgS0x/KXv9vb4ri6vrtSwu6RLQLo +ppQ0JBgB+/0wqEQUmzNYfG+UhgAol+tSY9xPQuXvM+Fpdstbe5OApqAqi5x7wzgIJUhQ50Zliv F/y+7bWSGemN7DO5ZNPjQVvRi4Wv1AIVZ1393mu8gjamsk3kbnFt8JEW/6Lm3AgoJ+Bl7K9xwoW jCJfY1MQPttLpG6CBoogCSzsxSOvrkPA6qa+5ZMSKD86s7ZRenSIRulIMSxZvXxwBNNPWw7C65Q gN53nGe4vZIl9VPdts7ZrpWKrjkENfwWJly5HXaJ8CsfyrUJmQkG5e3jM/GlsRRe1wtFDX4bz0L GCbcHhIQ4XaXSdg== 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-20250217_073940_385187_7B7F1429 X-CRM114-Status: UNSURE ( 9.56 ) X-CRM114-Notice: Please train this message. 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 The basic and mandatory features of FF-A v1.2 are all supported now. The driver supported version can be bumped from v1.1 to v1.2 Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 2 +- include/linux/arm_ffa.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 545b1772df0095787b20332a7d5189c71bd5cacd..d8421a32a92fed6d56770cba282ea55b2571b155 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -44,7 +44,7 @@ #include "common.h" -#define FFA_DRIVER_VERSION FFA_VERSION_1_1 +#define FFA_DRIVER_VERSION FFA_VERSION_1_2 #define FFA_MIN_VERSION FFA_VERSION_1_0 #define SENDER_ID_MASK GENMASK(31, 16) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index bd78deeff284e2f46d42cfc7af218f4a0f3d1478..4fcbdc70cbc985eabb90733329c974384d229053 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -112,6 +112,7 @@ FIELD_PREP(FFA_MINOR_VERSION_MASK, (minor))) #define FFA_VERSION_1_0 FFA_PACK_VERSION_INFO(1, 0) #define FFA_VERSION_1_1 FFA_PACK_VERSION_INFO(1, 1) +#define FFA_VERSION_1_2 FFA_PACK_VERSION_INFO(1, 2) /** * FF-A specification mentions explicitly about '4K pages'. This should From patchwork Mon Feb 17 15:38:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978169 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 41E1BC021A9 for ; Mon, 17 Feb 2025 16:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=8oEYFSUCFe1XHtjsO3bK+GVD/JoxfCJBrcyddlpVWZg=; b=M96cUNl8WaDv18kUiBR7jbahm7 Fl42jVDAaXD7r/gXjGrwe1YCPaIe9pzf0rntf0LfDRiFQaIdvZZuOrA4N3r6RCRmkO8q/0juuzwkK 1W/z+L6wnfqMKg9ijfDLhGMvduFB62Wd4MFm/kkhodha9Lqhq8Xruz4BAatwErJUNpnlQghvZ2Xse PN5suPfCU+1Loylp987baC/SEX8uioHbIesCGqocowmZhXwGC6+EayZCCU+W9xZvepqt2rE2r6VDL e3BqEixbW0ymuOvRWaXIcbdtbv5WpK1fS2aTVnGjzNKmA8U6qo7D0DmEOqWs2Wll4WuysWSDHJ8zL lBi55zVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3cj-00000005CMk-46zu; Mon, 17 Feb 2025 16:05:33 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dh-000000055Y5-1OK8 for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:42 +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 542F61692; Mon, 17 Feb 2025 07:40:00 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 703B63F6A8; Mon, 17 Feb 2025 07:39:40 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:53 +0000 Subject: [PATCH v3 12/19] firmware: arm_ffa: Reject higher major version as incompatible MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-12-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1654; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=hUYLqZtlRI6Y6zWVPccEHPCN6XfeE5xkOBosV7oWkjw=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gvPBXUm+PU5UaWOx8OeaNF2Sib2Z4JpmBpW YHmcXla4vyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mHtID/42BE/x0L0hVj8+T1jkTQJeIPYpa2lZbI2IUchyI9APrySzXzTdsoGWa0Ybkf9LEt0wOI5 mW7qVAaxN4tTOPNpP+a7TvyMI/6J6ZDjA57obCdIeG2IvMaMivhpEjKNEPjiwxiNnTe56eyZmOC LOCuF76kcXILynWZrA/w68GonydunUrDqxU3mVuegw8E988ew4VNE5UIBeEAyaqM+10EqxlL9FU GKbu4TCJqpME7blSpbCpFAiZb4cFF+Pb9ES+T+xgN7MY0dbX6VIuZjmAP98VJ7oXYTQ2SX+jrRH usJnh0s/9GfMxGXE81z5GXCssmqjVTFq0pZpUNs+rtG+AyrNhweW3BgpqoWaQBu4bgYC0nzk6XJ jL4Xv6vX2/8gN/J3PI4werouYzfNxOfjgWoCmFHECW5LP34LvdHunOXVhwEbAO7EqOIDMgayVoy 26FYt4Tpu9J2h3WE/qFaZ+Aa074W0fL7Rz01yYoT7SRX+YV6bswsXkMdAr60++izvw67FJwE7aS +MvuyeF+sz+gnLSm3zlE0C15ZiYrObOPGJo0cPd285MAQHXX7aO+UeJVePvFy0tox0MZgQgy1zH NMNrxEHhVAnYaZb+4PQ8kw9boSB3jpPvHLSrahZn7kuYvuRzl1aAniq7AT8++PtWzKeboKK/EHh LJXYECxMv6cXqpA== 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-20250217_073941_428508_46D04321 X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. 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 When the firmware compatibility was handled previously in the commit 8e3f9da608f1 ("firmware: arm_ffa: Handle compatibility with different firmware versions"), we only addressed firmware versions that have higher minor versions compared to the driver version which is should be considered compatible unless the firmware returns NOT_SUPPORTED. However, if the firmware reports higher major version than the driver supported, we need to reject it. If the firmware can work in a compatible mode with the driver requested version, it must return the same major version as requested. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index d8421a32a92fed6d56770cba282ea55b2571b155..ad2f6b410e4431bb133fa0f05dd3eec802f5ee07 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -150,6 +150,14 @@ static int ffa_version_check(u32 *version) return -EOPNOTSUPP; } + if (FFA_MAJOR_VERSION(ver.a0) > FFA_MAJOR_VERSION(FFA_DRIVER_VERSION)) { + pr_err("Incompatible v%d.%d! Latest supported v%d.%d\n", + FFA_MAJOR_VERSION(ver.a0), FFA_MINOR_VERSION(ver.a0), + FFA_MAJOR_VERSION(FFA_DRIVER_VERSION), + FFA_MINOR_VERSION(FFA_DRIVER_VERSION)); + return -EINVAL; + } + if (ver.a0 < FFA_MIN_VERSION) { pr_err("Incompatible v%d.%d! Earliest supported v%d.%d\n", FFA_MAJOR_VERSION(ver.a0), FFA_MINOR_VERSION(ver.a0), From patchwork Mon Feb 17 15:38:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978170 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 9564FC021A9 for ; Mon, 17 Feb 2025 16:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=cLexOwpra+KhMNJ9Ul//pg1dp70XjarN9VD3z17dQ5c=; b=fd2DOB3nrgEetkjRkys8fyb1Ix cq0xb7LSSZIvNv0elWJh/Jkzn9d7iVqBtkjgyX4kczsH5/ATO8RqXNRXHVIf5TiWf+SrbkNVMGlVe BrN2wfK3hfmJNckbhUKtDA6ZmGkbqk8l3IRUW1kYWrRFaF61S7iW+6bChtZG5yiod8hzvI2/jnxxZ vRi/ZG60K644G/GkCOYMZDca57RhGIk0dv83xvRDzwq8UMuhZAPQWuWX2RXmWilvD3nyfeypc6BPe Cp21EQX172LNWFvPWAoQA8/6l4ZwySKqL2Qhk9NzFNJX4FfUNtckeh90grIVk1GcZM2YyMaZtG6y6 c05J5bkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3eA-00000005Cep-34DI; Mon, 17 Feb 2025 16:07:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Di-000000055XP-1jIN for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:43 +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 5A6F01063; Mon, 17 Feb 2025 07:40:01 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 765B53F6A8; Mon, 17 Feb 2025 07:39:41 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:54 +0000 Subject: [PATCH v3 13/19] firmware: arm_ffa: Remove unnecessary declaration of ffa_partitions_cleanup() MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-13-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1988; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=aidoWnRBdKS/bzj9yzmy9eXwgGR2HXGsyDF1QbYB0U0=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gv6fDyFE6SRIJTmRZSK7AGzajqpMcsbZ1Mf is3SarX/ISJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mGnKD/9nTGkCjRYMkNvtTNTZ+ba+EFDlgHhfCUjpG1zmPMjavtH3ijDKfC9w9dt9Nu9p4L5bn+c vjNaZ3Zui8C5Ui6FJjDyRaUm2O77nu73bYwuaD6t/mXHDwCh2hN1shp4KHrBtzR9u3lP3RhpkvR 8gyGvDLNZfsRn+MyR9ClEqn4gWCaMnQLdlsWOnlQsYn2ss0vYYh4f5GLzPRINldNr13B4OpVaL3 cD4vLjg8PHUNxv/No8Hy/InZvjwKMlpoOrCPxav/psSaQmbNKS/fmyXIkdxZfpZRe0tBKSEVsH5 ZNqjbVjvUPV/h5Z+MczXV3hFoeNXJ5+3t7GFIQ5eyPi607V+LXSk7FuMTO4iIGnTDo5LxM5almQ blkjh/bIhVzvudwKKaxoLW0rihZ0cX3fW2DWf2jh1BaDMatQ5Kkhf3/Q9GIAqzw7LfsiDG5z9h/ lGOWelMNCGy8YfjqkRLLbreFvaHFDqrMotSOBr6qQn5NZhriUDI9a/smuUllOZytYj8Ssyx7dEb LQLQhixX5ofSIDos2BbQaMnXxxW+XiyQ4y+K0Pvot+88jcjR9BEES0MApcRJDt4Euh22Cokfp8q BIY7vHs01M0rnP99lBSAFAMAlAJLs43BsbS/fXsidFQpQQNe0xKOnAu6XCGs29HM+hpAquJjkRE sgK1MQ/qfLcMVkw== 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-20250217_073942_543448_A357CD7E X-CRM114-Status: GOOD ( 10.86 ) 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 In order to keep the uniformity, just move the ffa_partitions_cleanup() before it's first usage and drop the unnecessary forward declaration. No functional change. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index ad2f6b410e4431bb133fa0f05dd3eec802f5ee07..43e033edd6c7cd16322c204e882a84cfe45abbba 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -114,7 +114,6 @@ struct ffa_drv_info { }; static struct ffa_drv_info *drv_info; -static void ffa_partitions_cleanup(void); /* * The driver must be able to support all the versions from the earliest @@ -1452,6 +1451,22 @@ static int ffa_xa_add_partition_info(int vm_id) return ret; } +static void ffa_partitions_cleanup(void) +{ + struct ffa_dev_part_info *info; + unsigned long idx; + + /* Clean up/free all registered devices */ + ffa_devices_unregister(); + + xa_for_each(&drv_info->partition_info, idx, info) { + xa_erase(&drv_info->partition_info, idx); + kfree(info); + } + + xa_destroy(&drv_info->partition_info); +} + static int ffa_setup_partitions(void) { int count, idx, ret; @@ -1509,22 +1524,6 @@ static int ffa_setup_partitions(void) return ret; } -static void ffa_partitions_cleanup(void) -{ - struct ffa_dev_part_info *info; - unsigned long idx; - - /* Clean up/free all registered devices */ - ffa_devices_unregister(); - - xa_for_each(&drv_info->partition_info, idx, info) { - xa_erase(&drv_info->partition_info, idx); - kfree(info); - } - - xa_destroy(&drv_info->partition_info); -} - /* FFA FEATURE IDs */ #define FFA_FEAT_NOTIFICATION_PENDING_INT (1) #define FFA_FEAT_SCHEDULE_RECEIVER_INT (2) From patchwork Mon Feb 17 15:38:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978171 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 D0A92C021A9 for ; Mon, 17 Feb 2025 16:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=2uGI9SGhy1snMcVxA2VPwvOU2J/XmtC5L5pxBa5Vy7U=; b=v9/V8eAkLtkhktqL4oKSqptcVH xPqwJfP98HyUhouEgiXQb/SVnBKB46TfHNKA3CSQU0AoDFNirpcfTIH+di+vaN8MlOHrz0lGv7WiI EtoLdSoUmeg275KI9G4LXhOipSAY77YXBH6+ydTb6RvO4Nwes/3QqsAtqqcsudDi9wKHI4VqZvBNL wJzZ1Btm1FRl5weBbUaDemmGN5PvBC9XRSEDThEc1CjfdhV/khRpDTmp1QQgxTgJ5Fa5gVKGx4NLA 39pNDi6+HKaoRxSBQiG7obv7xD+MgpCUGDkj78JPe7fH6Bd6NNuAw9M5ofQ0p6zIGpSOki7ye+N7M NapD9RxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3fc-00000005CyI-1UFG; Mon, 17 Feb 2025 16:08:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dj-000000055Y5-1cGL for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:44 +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 60D17152B; Mon, 17 Feb 2025 07:40:02 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7CADB3F6A8; Mon, 17 Feb 2025 07:39:42 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:55 +0000 Subject: [PATCH v3 14/19] firmware: arm_ffa: Refactoring to prepare for framework notification support MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-14-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4846; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=uPUgv0mLk6mKXfHHZQoNabuM20DP7Tz7q35RqzDweLQ=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gvD8PSV3+oN/oLts63Djl+9M8FM/+AD4Tm4 RUvVdWfSM+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mCZzEAC11Ij+667T8JKp6Kyu6monTKkZrfb3AWWtDbtEje5z0cOlnp1MZsCtbCv2VCOuS1BFr8z 3QAstRQ9c9sxuqufHmJi8qzAk5qvGVpyBi7V3fE6yc7vqWhw27AkLxTaQ2EabDhSJ4vv8lr6jbh DB2Xu771Vfxc6gzOsKA3yfbuZsNubgCHiGAcEzmaI5OHqRzhXtsuxTnPMVNKRczfAn06WC3iMQX EXxfrVu7A0h1ZH0Dn35iUbw+Ik1uUFU1srjbYjRL9XLQAlQXEC1/BcqAcDZ8UJGjRsvGFRhspFP ggWvcJw1h09vJMlcEsOef+r1tLoQA6T8YjmOqrK3YeWCWGhjoDBznZuO6kA/fBEWuSSh660uk02 oqFiEDVUYWTnDAutSnCtbKeULjeFKhXEF3+F9e2+SFEAGHEdrVTERpsLE8xxLMFhlAEMnH87KiS 3bJn+DVRQVQeqzBAs2TbAFWihsv864XltAXLYhe4ahxfjsyuQWuqtL6N7lhMF18D/Gnwn8Ph2Hm r7FXMVd7nuv7CqxUolOOtmvF+q7SeUHn+RjB4JimCxs9LE9eH9UrGeES94HhntMKc243wjUkIfE lRepaxWUjglAtzPqHavoU3nALbJXR/t0/e9rY07oaWL/PbM4PHCbougw/UF3B3dr9dvGGJTLLll kvDIxl0L4JOkhqw== 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-20250217_073943_556220_FF183927 X-CRM114-Status: GOOD ( 14.77 ) 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 framework notifications are not supported at all. handle_notif_callbacks() doesn't handle them though it is called with framework bitmap. Make that explicit by adding checks for the same. Also, we need to further classify the framework notifications as Secure Partition Manager(SPM) and NonSecure Hypervisor(NS_HYP). Extend/change notify_type enumeration to accommodate all the 4 type and rejig the values so that it can be reused in the bitmap enable mask macros. While at this, move ffa_notify_type_get() so that it can be used in notifier_hash_node_get() in the future. No functional change. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 57 +++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 43e033edd6c7cd16322c204e882a84cfe45abbba..0abbf08bc8d39c701947366bdf9c8fac8e64cf64 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -807,6 +807,13 @@ static int ffa_notification_bitmap_destroy(void) return 0; } +enum notify_type { + SECURE_PARTITION, + NON_SECURE_VM, + SPM_FRAMEWORK, + NS_HYP_FRAMEWORK, +}; + #define NOTIFICATION_LOW_MASK GENMASK(31, 0) #define NOTIFICATION_HIGH_MASK GENMASK(63, 32) #define NOTIFICATION_BITMAP_HIGH(x) \ @@ -830,10 +837,17 @@ static int ffa_notification_bitmap_destroy(void) #define MAX_IDS_32 10 #define PER_VCPU_NOTIFICATION_FLAG BIT(0) -#define SECURE_PARTITION_BITMAP BIT(0) -#define NON_SECURE_VM_BITMAP BIT(1) -#define SPM_FRAMEWORK_BITMAP BIT(2) -#define NS_HYP_FRAMEWORK_BITMAP BIT(3) +#define SECURE_PARTITION_BITMAP_ENABLE BIT(SECURE_PARTITION) +#define NON_SECURE_VM_BITMAP_ENABLE BIT(NON_SECURE_VM) +#define SPM_FRAMEWORK_BITMAP_ENABLE BIT(SPM_FRAMEWORK) +#define NS_HYP_FRAMEWORK_BITMAP_ENABLE BIT(NS_HYP_FRAMEWORK) +#define FFA_BITMAP_ENABLE_MASK \ + (SECURE_PARTITION_BITMAP_ENABLE | SPM_FRAMEWORK_BITMAP_ENABLE) + +#define FFA_SECURE_PARTITION_ID_FLAG BIT(15) + +#define SPM_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_LOW(x) +#define NS_HYP_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_HIGH(x) static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, u32 flags, bool is_bind) @@ -1098,16 +1112,8 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) return ffa_memory_ops(FFA_MEM_LEND, 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, - FRAMEWORK, -}; - struct notifier_cb_info { struct hlist_node hnode; ffa_notifier_cb cb; @@ -1166,6 +1172,14 @@ static int ffa_notification_unbind(u16 dst_id, u64 bitmap) return ffa_notification_bind_common(dst_id, bitmap, 0, false); } +static enum notify_type ffa_notify_type_get(u16 vm_id) +{ + if (vm_id & FFA_SECURE_PARTITION_ID_FLAG) + return SECURE_PARTITION; + else + return NON_SECURE_VM; +} + /* Should be called while the notify_lock is taken */ static struct notifier_cb_info * notifier_hash_node_get(u16 notify_id, enum notify_type type) @@ -1209,14 +1223,6 @@ update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, return 0; } -static enum notify_type ffa_notify_type_get(u16 vm_id) -{ - if (vm_id & FFA_SECURE_PARTITION_ID_FLAG) - return SECURE_PARTITION; - else - return NON_SECURE_VM; -} - static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) { int rc; @@ -1299,6 +1305,9 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) int notify_id; struct notifier_cb_info *cb_info = NULL; + if (type == SPM_FRAMEWORK || type == NS_HYP_FRAMEWORK) + return; + for (notify_id = 0; notify_id <= FFA_MAX_NOTIFICATIONS && bitmap; notify_id++, bitmap >>= 1) { if (!(bitmap & 1)) @@ -1318,16 +1327,18 @@ static void notif_get_and_handle(void *unused) int rc; struct ffa_notify_bitmaps bitmaps; - rc = ffa_notification_get(SECURE_PARTITION_BITMAP | - SPM_FRAMEWORK_BITMAP, &bitmaps); + rc = ffa_notification_get(FFA_BITMAP_ENABLE_MASK, &bitmaps); if (rc) { pr_err("Failed to retrieve notifications with %d!\n", rc); return; } + handle_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map), + SPM_FRAMEWORK); + handle_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map), + NS_HYP_FRAMEWORK); handle_notif_callbacks(bitmaps.vm_map, NON_SECURE_VM); handle_notif_callbacks(bitmaps.sp_map, SECURE_PARTITION); - handle_notif_callbacks(bitmaps.arch_map, FRAMEWORK); } static void From patchwork Mon Feb 17 15:38:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978172 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 D8345C021A9 for ; Mon, 17 Feb 2025 16:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=wBXpU0D8pq0jWUN+QTzkLXNljq9YczofYT2tGDbBbdg=; b=MInGgtg9P/xdw4K6rwJro/9v60 TWqIRsdMuUQ8pn0tSQu9nCNaPdZRsp2trKuHtIHIyorTCEIBMvKGB9HMCkgIblPcOfCL4u810dqk3 5G6tENF6M8krp+DSaenGkFaTGxKvzsEbNKhVLqykTZeEWOsaL6+2C6+rW4cIJ8iCY7tR1lvimKn0U FA6go3gF/nwoq8RMVx+8bKU9qTr6Pv6gtddjXdauqkUaMkyeEeFwFNiWA0f2D3ZFtw2JOSMryyuwe sU+OFY+qVGT0S8+uKcuoGNdsIGnlO5/au5w94BN4KPGOop+uhEuZndgHg7k6cEhbUuxEZGlXZYuKw EpV9Tg/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3h4-00000005DIv-0HYa; Mon, 17 Feb 2025 16:10:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dk-000000055XP-1iAF for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:45 +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 6731D1063; Mon, 17 Feb 2025 07:40:03 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 832F23F6A8; Mon, 17 Feb 2025 07:39:43 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:56 +0000 Subject: [PATCH v3 15/19] firmware: arm_ffa: Stash ffa_device instead of notify_type in notifier_cb_info MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-15-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3541; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=a+m7Jcn3/5rOXkUlDE7zE4WFeovCOPzxO6ncEsdu46s=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gvxHscpAJVylxg3E1rCxo/gAykEC9AxaQ4z GS5AInoSeWJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mMhtEACupYnhbABfRgAxOCIJthXbvk3V50VSPi3g8KQTIZwbypXqE5qWfBx+h9MM3j0AhJo1wzL e5Uw2G6k4bf+hh/X15ck5WKRLvsRALiDAhJo/PDd+g7/MD0zpFqcziJf9MLbA1zjXmydB0D9YKn AKFFDVh66J4BMHNKgJggC7xM+VjL3ipmixLruOX1UBENUkQY6rxwYl5bJ4/LAeFHXNWh85XYi5t BDyxdKci1QqmWhL9dq09vjytFTIsX/AvdmLe0BsrA8aytCfoqgZVICkcdKELQvYlJQuXogiYusO 0iPApcNZ21A37xIYxJbl6xnUhmREDtDYFhkqR5rD8Jjl2MkzyWdLYLs9GmrenFJBs7BGovb/WQu kYNYR86C/LL6ZKAbzzKrnmOiw0WKcf8460R4w+ZXEfVWHmecC0i2PZH/A9/2uoxZJF2vONc7Tbi pYLJl8HkqkFQk68aoTBqPsPbnhqQ0GTHKp6sGC4MILHZQaGhPF/LJWPbtqJ9R91NFXgB/5AWvoC jBnTao4tfQNep8mYTZhP6JJIH0yuj+FEXyJWYinL5WO/9NrVXI9uqLqJz3Rmqs/KwLK3aMPWerE LGvP7b5hQQQ/I4ofvKzn8c7SQnPfSOI/fE0170p35Pd22j2K0ZfuXjUEEeUo95D3UzcWrlPcGHb cQ8bhRJuIEgOZzg== 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-20250217_073944_602393_37AF1529 X-CRM114-Status: GOOD ( 12.38 ) 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, we store the type of the notification in the notifier_cb_info structure that is put into the hast list to identify if the notification block is for the secure partition or the non secure VM. In order to support framework notifications to reuse the hash list and to avoid creating one for each time, we need store the ffa_device pointer itself as the same notification ID in framework notifications can be registered by multiple FF-A devices. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 0abbf08bc8d39c701947366bdf9c8fac8e64cf64..5863272f45d9c075d8e86d45a90ac6b1fb743c98 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1116,9 +1116,9 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) struct notifier_cb_info { struct hlist_node hnode; + struct ffa_device *dev; ffa_notifier_cb cb; void *cb_data; - enum notify_type type; }; static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, @@ -1187,17 +1187,18 @@ notifier_hash_node_get(u16 notify_id, enum notify_type type) struct notifier_cb_info *node; hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (type == node->type) + if (type == ffa_notify_type_get(node->dev->vm_id)) return node; return NULL; } static int -update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, +update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, void *cb_data, bool is_registration) { struct notifier_cb_info *cb_info = NULL; + enum notify_type type = ffa_notify_type_get(dev->vm_id); bool cb_found; cb_info = notifier_hash_node_get(notify_id, type); @@ -1211,7 +1212,7 @@ update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, if (!cb_info) return -ENOMEM; - cb_info->type = type; + cb_info->dev = dev; cb_info->cb = cb; cb_info->cb_data = cb_data; @@ -1226,7 +1227,6 @@ update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, 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; @@ -1236,7 +1236,7 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) mutex_lock(&drv_info->notify_lock); - rc = update_notifier_cb(notify_id, type, NULL, NULL, false); + rc = update_notifier_cb(dev, notify_id, NULL, NULL, false); if (rc) { pr_err("Could not unregister notification callback\n"); mutex_unlock(&drv_info->notify_lock); @@ -1255,7 +1255,6 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, { int rc; u32 flags = 0; - enum notify_type type = ffa_notify_type_get(dev->vm_id); if (ffa_notifications_disabled()) return -EOPNOTSUPP; @@ -1274,7 +1273,7 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, return rc; } - rc = update_notifier_cb(notify_id, type, cb, cb_data, true); + rc = update_notifier_cb(dev, notify_id, cb, cb_data, true); if (rc) { pr_err("Failed to register callback for %d - %d\n", notify_id, rc); From patchwork Mon Feb 17 15:38:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978174 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 6BA85C021A9 for ; Mon, 17 Feb 2025 16:11:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=1wnTy3rvzRZOh0XJAgpCsH/inauOKla+7bwwaCtKGno=; b=x8DF+n9iSKrxqvtNB2BePPB/Xm o8ptLFmlpfEVEV+HNEOWustPW+aPwNxfeBQFraoBd1/VFrPCbU32SBLk767sXwJrMtRuXUatppgQi BZtI5Wo7GQqVhklozdDXPWzx/d7y9eOj8GCkiSovifyd/AZvpyMSzgTaV7HhPMsSVrOX8IVrWwSpZ zK6BvmSMdXNo7wOqvQ4A0v8NA7gkINpvDyqclLQrvMMAZsfAHgTIZgagB6oWd8lFzQjkgoNJktQPc gQD2k3XAxo92Th6tGkQ/ecUd+XSFyAM12J7RXEeCG62DmncZm3y2ayHyVBuUIAuxW8SC3hJQkDgE3 L0brlXbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3iU-00000005DXS-2sDT; Mon, 17 Feb 2025 16:11:30 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dl-000000055Y5-1pFN for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:46 +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 6D81A152B; Mon, 17 Feb 2025 07:40:04 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8993F3F6A8; Mon, 17 Feb 2025 07:39:44 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:57 +0000 Subject: [PATCH v3 16/19] firmware: arm_ffa: Add support for {un,}registration of framework notifications MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-16-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8743; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=WEGGckQePLXCqge512Wc1aWYVvJZWoS08KOioG13gpw=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gvdf2CmAUAPAUZs+JR7a1ajOQc2zyTwWOwq Ipl6qBs7OiJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mNDQEADVhP1zm04F73AeyXIyhiDBHA07Xvtm8OT8Uc4fMCE3qQdp7ou3tv4sIudOWEI9OrPSBvb cIyGrZeKUOaSqXgCr0tmRED3BsFLqX/bEDyBeBthK4WqbiLlGa9i7G0deimcCnpiQSuuQGNQvL0 hag5buHQ6TX6hPok3/FgyuvXjQkfov+J6Z+tNcltVLkpKpPo6tqRoEg1kEeFC1HWRGMc8hLiR5h +VwjQLZb243IVOl+9WArYS9QpjNU2ZAqu/HGT+cBG9j5ePicojJSl26+Sdqbe/jGso05ylo9XwN Q4rmqYlB93iVHwFOIxOTxm0P8dBqf5tWzYsYuGRRDpJSV40+NCMLCaXXGguNxNeG2bsWY6+/qr/ HLp7aVlpAQCYRQAMgr1LK3YCy9tGcmCMxQlB7DYM5OFcxFqedzOdIsjxQw+izm33rFViWPnIRcw 2iwP+IyQcEkKIACxpDHuFf6WY+/UHHeaBJ3XtH3OK5fPYZvsx35RYQhrM+GewhFl7uj/FDcNhMx Zn16gL/w40u12/RZ/NrbwqKVaoOv6pUyP0mG7NVAgl4o1gBt8s26RN4FO/xtEMmTWFQVkSum0vL cG8qbzIHqmFcCfiUy/ErPq22UGAq8dOTYxXbRkZFxjczMtODfnssqVKzUQtXTuAXq885EtAr5JY AYq+UgwBLjOSOhQ== 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-20250217_073945_578471_9BACF406 X-CRM114-Status: GOOD ( 17.28 ) 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 Framework notifications are doorbells that are rung by the partition managers to signal common events to an endpoint. These doorbells cannot be rung by an endpoint directly. A partition manager can signal a Framework notification in response to an FF-A ABI invocation by an endpoint. Two additional notify_ops interface is being added for any FF-A device/ driver to register and unregister for such a framework notifications. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 113 +++++++++++++++++++++++++++++++------- include/linux/arm_ffa.h | 5 ++ 2 files changed, 97 insertions(+), 21 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 5863272f45d9c075d8e86d45a90ac6b1fb743c98..a889ad6d94ac499cff869a138970c9dc7ae0a1f9 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1117,6 +1117,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) struct notifier_cb_info { struct hlist_node hnode; struct ffa_device *dev; + ffa_fwk_notifier_cb fwk_cb; ffa_notifier_cb cb; void *cb_data; }; @@ -1180,28 +1181,61 @@ static enum notify_type ffa_notify_type_get(u16 vm_id) return NON_SECURE_VM; } -/* Should be called while the notify_lock is taken */ +/* notifier_hnode_get* should be called with notify_lock held */ static struct notifier_cb_info * -notifier_hash_node_get(u16 notify_id, enum notify_type type) +notifier_hnode_get_by_vmid(u16 notify_id, int vmid) { struct notifier_cb_info *node; hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (type == ffa_notify_type_get(node->dev->vm_id)) + if (node->fwk_cb && vmid == node->dev->vm_id) + return node; + + return NULL; +} + +static struct notifier_cb_info * +notifier_hnode_get_by_vmid_uuid(u16 notify_id, int vmid, const uuid_t *uuid) +{ + struct notifier_cb_info *node; + + if (uuid_is_null(uuid)) + return notifier_hnode_get_by_vmid(notify_id, vmid); + + hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) + if (node->fwk_cb && vmid == node->dev->vm_id && + uuid_equal(&node->dev->uuid, uuid)) + return node; + + return NULL; +} + +static struct notifier_cb_info * +notifier_hnode_get_by_type(u16 notify_id, enum notify_type type) +{ + struct notifier_cb_info *node; + + hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) + if (node->cb && type == ffa_notify_type_get(node->dev->vm_id)) return node; return NULL; } static int -update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, - void *cb_data, bool is_registration) +update_notifier_cb(struct ffa_device *dev, int notify_id, void *cb, + void *cb_data, bool is_registration, bool is_framework) { struct notifier_cb_info *cb_info = NULL; enum notify_type type = ffa_notify_type_get(dev->vm_id); bool cb_found; - cb_info = notifier_hash_node_get(notify_id, type); + if (is_framework) + cb_info = notifier_hnode_get_by_vmid_uuid(notify_id, dev->vm_id, + &dev->uuid); + else + cb_info = notifier_hnode_get_by_type(notify_id, type); + cb_found = !!cb_info; if (!(is_registration ^ cb_found)) @@ -1213,8 +1247,11 @@ update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, return -ENOMEM; cb_info->dev = dev; - cb_info->cb = cb; cb_info->cb_data = cb_data; + if (is_framework) + cb_info->fwk_cb = cb; + else + cb_info->cb = cb; hash_add(drv_info->notifier_hash, &cb_info->hnode, notify_id); } else { @@ -1224,7 +1261,8 @@ update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, return 0; } -static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) +static int __ffa_notify_relinquish(struct ffa_device *dev, int notify_id, + bool is_framework) { int rc; @@ -1236,22 +1274,35 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) mutex_lock(&drv_info->notify_lock); - rc = update_notifier_cb(dev, notify_id, NULL, NULL, false); + rc = update_notifier_cb(dev, notify_id, NULL, NULL, false, + is_framework); if (rc) { pr_err("Could not unregister notification callback\n"); mutex_unlock(&drv_info->notify_lock); return rc; } - rc = ffa_notification_unbind(dev->vm_id, BIT(notify_id)); + if (!is_framework) + rc = ffa_notification_unbind(dev->vm_id, BIT(notify_id)); mutex_unlock(&drv_info->notify_lock); return rc; } -static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, - ffa_notifier_cb cb, void *cb_data, int notify_id) +static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) +{ + return __ffa_notify_relinquish(dev, notify_id, false); +} + +static int ffa_fwk_notify_relinquish(struct ffa_device *dev, int notify_id) +{ + return __ffa_notify_relinquish(dev, notify_id, true); +} + +static int __ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, + void *cb, void *cb_data, + int notify_id, bool is_framework) { int rc; u32 flags = 0; @@ -1264,26 +1315,44 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, mutex_lock(&drv_info->notify_lock); - if (is_per_vcpu) - flags = PER_VCPU_NOTIFICATION_FLAG; + if (!is_framework) { + if (is_per_vcpu) + flags = PER_VCPU_NOTIFICATION_FLAG; - rc = ffa_notification_bind(dev->vm_id, BIT(notify_id), flags); - if (rc) { - mutex_unlock(&drv_info->notify_lock); - return rc; + rc = ffa_notification_bind(dev->vm_id, BIT(notify_id), flags); + if (rc) { + mutex_unlock(&drv_info->notify_lock); + return rc; + } } - rc = update_notifier_cb(dev, notify_id, cb, cb_data, true); + rc = update_notifier_cb(dev, notify_id, cb, cb_data, true, + is_framework); if (rc) { pr_err("Failed to register callback for %d - %d\n", notify_id, rc); - ffa_notification_unbind(dev->vm_id, BIT(notify_id)); + if (!is_framework) + ffa_notification_unbind(dev->vm_id, BIT(notify_id)); } mutex_unlock(&drv_info->notify_lock); return rc; } +static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, + ffa_notifier_cb cb, void *cb_data, int notify_id) +{ + return __ffa_notify_request(dev, is_per_vcpu, cb, cb_data, notify_id, + false); +} + +static int +ffa_fwk_notify_request(struct ffa_device *dev, ffa_fwk_notifier_cb cb, + void *cb_data, int notify_id) +{ + return __ffa_notify_request(dev, false, cb, cb_data, notify_id, true); +} + static int ffa_notify_send(struct ffa_device *dev, int notify_id, bool is_per_vcpu, u16 vcpu) { @@ -1313,7 +1382,7 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) continue; mutex_lock(&drv_info->notify_lock); - cb_info = notifier_hash_node_get(notify_id, type); + cb_info = notifier_hnode_get_by_type(notify_id, type); mutex_unlock(&drv_info->notify_lock); if (cb_info && cb_info->cb) @@ -1386,6 +1455,8 @@ static const struct ffa_notifier_ops ffa_drv_notifier_ops = { .sched_recv_cb_unregister = ffa_sched_recv_cb_unregister, .notify_request = ffa_notify_request, .notify_relinquish = ffa_notify_relinquish, + .fwk_notify_request = ffa_fwk_notify_request, + .fwk_notify_relinquish = ffa_fwk_notify_relinquish, .notify_send = ffa_notify_send, }; diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 4fcbdc70cbc985eabb90733329c974384d229053..5bded24dc24fea8cdcbe42bf79c7c025c3fa5f4b 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -468,6 +468,7 @@ struct ffa_cpu_ops { typedef void (*ffa_sched_recv_cb)(u16 vcpu, bool is_per_vcpu, void *cb_data); typedef void (*ffa_notifier_cb)(int notify_id, void *cb_data); +typedef void (*ffa_fwk_notifier_cb)(int notify_id, void *cb_data, void *buf); struct ffa_notifier_ops { int (*sched_recv_cb_register)(struct ffa_device *dev, @@ -476,6 +477,10 @@ struct ffa_notifier_ops { int (*notify_request)(struct ffa_device *dev, bool per_vcpu, ffa_notifier_cb cb, void *cb_data, int notify_id); int (*notify_relinquish)(struct ffa_device *dev, int notify_id); + int (*fwk_notify_request)(struct ffa_device *dev, + ffa_fwk_notifier_cb cb, void *cb_data, + int notify_id); + int (*fwk_notify_relinquish)(struct ffa_device *dev, int notify_id); int (*notify_send)(struct ffa_device *dev, int notify_id, bool per_vcpu, u16 vcpu); }; From patchwork Mon Feb 17 15:38:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978175 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 88EEFC021A9 for ; Mon, 17 Feb 2025 16:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=FT5rzhdJbULQ380yD5HKFPOaijZr82Z1WbX0PL8FMtI=; b=sPEqYx/C+uspZgT9wDXMPiPP5C o468BGgFrSQLicAziTDnrVtiDKMcp35iZLaP8moyea2CySesNk8iZ4zkb6IFY4FwFp4ZaRFwYmBzl CTICc4Xpakx0jf6M/XpFH/M68q4CJ3m8320nxfWyVg6q7crGdSAz+en2JZiZmGGY6DXoodMh2tQcQ AJRay4HF/X15nv4zR3RJaF5XOQMSWuCMY0Gdw8wEQ/yphLnFqctlo7QPxfs7dRFHnWdhLe1zKN5UO y5q5mBdU94g8QjeUF9LSqBzG6RJpUVNSgBGUDCP/GLmu0/pJdDVIYW7II7KB4tQEfL8baTu7bSrxu hRUIrjjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3jv-00000005DkY-1vod; Mon, 17 Feb 2025 16:12:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dm-000000055XP-1w5A for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:47 +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 73ED11063; Mon, 17 Feb 2025 07:40:05 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8FE583F6A8; Mon, 17 Feb 2025 07:39:45 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:58 +0000 Subject: [PATCH v3 17/19] firmware: arm_ffa: Add support for handling framework notifications MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-17-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3917; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=zUw9jpCCHwbKRiqx7Z32FGOQBWRbtxyOOD74emf44tE=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gvyqk55MtjEByyz9lgsEdQeQbM/lstIDQKH 0JT4Odm8y2JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mDBRD/9ssBXMIPSl1evsnV27zqqtXe4QKXj8oq8NX8NxhTw8Wrgryq1vFwuaZb9NPEVHIHtorKn vBfs8KvUJHWMxQVYMkdFLPI2aoyCOWxsyQiJyImDEUJIs1VHexZ0ajDEexVYoY9n6LILCQVnoFA CpWr1oeqfzxY6Sb6C26FoHCOOGZcNmzkm0iEzz/mipzD1215FUYBdobgpP8kFqZkhypR87bllDi vciz18P6cz92e6R6iQ6/5oDcbRTmiubNAEG+ktRTIl8oH4OvMPCOpYad3/Qs7R2sZiJrXxlYrWj eL6ppsFXYf+3GUEnruKb3MFXOFi2fk9AYlEYitVLssK605uiFm2ASMjyKktwPPKxjD407RQPQwQ 9O6jLsP5q3HVSK2GvnzeOzEoz3dwG86qdpDqVJGYAlELz6qeL1c8Ks9F7Q9V/s+Ebfb3fRlbyXM sNBbaOxXiXiKw0+x8WlfQXkm0CGSzLdse/x12/e22ciNs09nkW6PL8eX9I60TeGuaesrrYFPKU+ 9GPm8WoBBZJhmQwmZQoOz9cY7jr0lRaCVWCCyad4mpcviqU/K3sthyshyAJr3ydmBpJETviOrxs ojpL0y486OUPwhvgZZ3mLafTCpGZKcLO1igt2e67jvLIpSVJ5jt/xnHc8uGnzAPV3quTdq1xTsC GMV2NtyvUdzaaPQ== 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-20250217_073946_586105_E290CCBC X-CRM114-Status: GOOD ( 13.40 ) 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 FF-A specification defines only one framework notification: RX buffer full notification. This notification is signaled by the partition manager during transmission of a partition message through indirect messaging to, 1. Notify an endpoint that it has a pending message in its Rx buffer. 2. Inform the message receiver’s scheduler via the schedule receiver interrupt that the receiver must be run. In response to an FFA_MSG_SEND2 invocation by a sender endpoint, the framework performs the following actions after the message is copied from the Tx buffer of the sender to the Rx buffer of the receiver: 1. The notification is pended in the framework notification bitmap of the receiver. 2. The partition manager of the endpoint that contains receiver’s scheduler pends the schedule receiver interrupt for this endpoint. The receiver receives the notification and copies out the message from its Rx buffer. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 50 +++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index a889ad6d94ac499cff869a138970c9dc7ae0a1f9..5441c4d8878023ad9107b185b711fd7b04224bb4 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -848,6 +848,7 @@ enum notify_type { #define SPM_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_LOW(x) #define NS_HYP_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_HIGH(x) +#define FRAMEWORK_NOTIFY_RX_BUFFER_FULL BIT(0) static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, u32 flags, bool is_bind) @@ -1373,9 +1374,6 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) int notify_id; struct notifier_cb_info *cb_info = NULL; - if (type == SPM_FRAMEWORK || type == NS_HYP_FRAMEWORK) - return; - for (notify_id = 0; notify_id <= FFA_MAX_NOTIFICATIONS && bitmap; notify_id++, bitmap >>= 1) { if (!(bitmap & 1)) @@ -1390,6 +1388,46 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) } } +static void handle_fwk_notif_callbacks(u32 bitmap) +{ + void *buf; + uuid_t uuid; + int notify_id = 0, target; + struct ffa_indirect_msg_hdr *msg; + struct notifier_cb_info *cb_info = NULL; + + /* Only one framework notification defined and supported for now */ + if (!(bitmap & FRAMEWORK_NOTIFY_RX_BUFFER_FULL)) + return; + + mutex_lock(&drv_info->rx_lock); + + msg = drv_info->rx_buffer; + buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL); + if (!buf) { + mutex_unlock(&drv_info->rx_lock); + return; + } + + target = SENDER_ID(msg->send_recv_id); + if (msg->offset >= sizeof(*msg)) + uuid_copy(&uuid, &msg->uuid); + else + uuid_copy(&uuid, &uuid_null); + + mutex_unlock(&drv_info->rx_lock); + + ffa_rx_release(); + + mutex_lock(&drv_info->notify_lock); + cb_info = notifier_hnode_get_by_vmid_uuid(notify_id, target, &uuid); + mutex_unlock(&drv_info->notify_lock); + + if (cb_info && cb_info->fwk_cb) + cb_info->fwk_cb(notify_id, cb_info->cb_data, buf); + kfree(buf); +} + static void notif_get_and_handle(void *unused) { int rc; @@ -1401,10 +1439,8 @@ static void notif_get_and_handle(void *unused) return; } - handle_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map), - SPM_FRAMEWORK); - handle_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map), - NS_HYP_FRAMEWORK); + handle_fwk_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map)); + handle_fwk_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map)); handle_notif_callbacks(bitmaps.vm_map, NON_SECURE_VM); handle_notif_callbacks(bitmaps.sp_map, SECURE_PARTITION); } From patchwork Mon Feb 17 15:38:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978176 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 CDCCAC021AA for ; Mon, 17 Feb 2025 16:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=QcQN+Jd93JczM+dd3WWlAiT8eErCObnNGF0AJ+RQ5nM=; b=TM8VKtHhfnZ9AZiS1HOyTytrjj FqJNvWbbsyO9mY8KAL9DsWSJ36G8s5GYp/msXCaAuoahJQJg8B7AusDYalZqvM41/E50RfkiU3Z90 PlwRRp0brSPIUriZkI2Xz/BdGh35OSYVB2ICyPdzBWxwhvPZNlGqDsIU4ItUUas2qV9ss1AsUDP+G n15hsoqePE98/dUfbxZz4BDiqcdo9KZfiDYG4V4wjA6USPwfDb3zgEDeHEc2DcaVsmisy8KhvWU96 ivgGY9+MeYg9FTLxVMxTDlL2UMvuL8ym+mdIAQeu4c8wCBQ4fdJPYIg6D1YPA8YEi6kvGnCR+zcJ2 wj6G3+Hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3lM-00000005DyQ-0Nem; Mon, 17 Feb 2025 16:14:28 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Dn-000000055Y5-2h0s for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:49 +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 79E9A1692; Mon, 17 Feb 2025 07:40:06 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9636E3F6A8; Mon, 17 Feb 2025 07:39:46 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:38:59 +0000 Subject: [PATCH v3 18/19] firmware: arm_ffa: Allow multiple UUIDs per partition to register SRI callback MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-18-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8280; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=u6lcDDwGq+4Z1B/VCc7uTlwjRc2gb5kTQ9pVpMg+eP8=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gvUT+CyjK120FZSB/TCAZ/EELkP9V3xvgPe nJmJyXEEzqJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mGnhEAC69hZaIx2JOfex0oN31tTLZFebu5sTS9bubNRzatou/H9RgGd+RtPeeD98hu/5qplge/X uj/YFQ5SdsGmvTxIyNi3FyBeSzV3K97mr7NLYh0VxRrRuuH3Sfe+ptPqWdhuTL785cGvIvuZNc9 DD1Bf4W3bFX7QhmA5uoIChXTfGrN8n8RibGVIvbbIQp/NOo0oZu+ifC3kvsZREUuG9TEF90VChf Pg0Z/u162kC+R+MvaElDImPrYvHCyFMG5rA7QJVP/BvWhBGKroNgHwOb83PsOToqTJeMTzuueB+ MXpMQqdO7KtR045zGu+8YJs6VgaV5qKhUQlw4A94OCiYiq+MvbaGflU9VkFOP+YAgbWezg3Mpz2 eVErP6e5Am5iyN3H/uc1BjUeutGHF+raQMPqrQjjZsfCu6H6mvXI0F3gG4tsrsx099gtQqVJNCx SEGOjLYMfY03fDxENVVpOEq0emwMoo3oWl4NLCfdNbkDvoRrGYtRFXtdWF2FdD2kfHcRLuUjPpT cO91hW6jcUX+j2d+MfZ6/rQDT7oggLf3nGRbfTJ6nBpk+gGD1PyN+aQJ1RVW5nSOwf77P5WvOjR kOKYZD0vZlInulnjoCcbjJGYRmHhyhZQ+F/A7IIKjOfd95Lf3uAhOmGjc8z/yGGrNwQhQIx4s8l qRN8h4dvWAf2f8A== 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-20250217_073947_788775_228BF7B4 X-CRM114-Status: GOOD ( 22.05 ) 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 A partition can implement multiple UUIDs and currently we successfully register each UUID service as a FF-A device. However when adding the same partition info to the XArray which tracks the SRI callbacks more than once, it fails. In order to allow multiple UUIDs per partition to register SRI callbacks the partition information stored in the XArray needs to be extended to a listed list. A function to remove the list of partition information in the XArray is not added as there are no users at the time. All the partitions are added at probe/initialisation and removed at cleanup stage. Tested-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 159 ++++++++++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 42 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 5441c4d8878023ad9107b185b711fd7b04224bb4..db6334f0c532566565246173373d8f0a42c836af 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -925,27 +925,32 @@ struct ffa_dev_part_info { ffa_sched_recv_cb callback; void *cb_data; rwlock_t rw_lock; + struct ffa_device *dev; + struct list_head node; }; static void __do_sched_recv_cb(u16 part_id, u16 vcpu, bool is_per_vcpu) { - struct ffa_dev_part_info *partition; + struct ffa_dev_part_info *partition = NULL, *tmp; ffa_sched_recv_cb callback; + struct list_head *phead; void *cb_data; - partition = xa_load(&drv_info->partition_info, part_id); - if (!partition) { + phead = xa_load(&drv_info->partition_info, part_id); + if (!phead) { pr_err("%s: Invalid partition ID 0x%x\n", __func__, part_id); return; } - read_lock(&partition->rw_lock); - callback = partition->callback; - cb_data = partition->cb_data; - read_unlock(&partition->rw_lock); + list_for_each_entry_safe(partition, tmp, phead, node) { + read_lock(&partition->rw_lock); + callback = partition->callback; + cb_data = partition->cb_data; + read_unlock(&partition->rw_lock); - if (callback) - callback(vcpu, is_per_vcpu, cb_data); + if (callback) + callback(vcpu, is_per_vcpu, cb_data); + } } static void ffa_notification_info_get(void) @@ -1123,18 +1128,29 @@ struct notifier_cb_info { void *cb_data; }; -static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, - void *cb_data, bool is_registration) +static int +ffa_sched_recv_cb_update(struct ffa_device *dev, ffa_sched_recv_cb callback, + void *cb_data, bool is_registration) { - struct ffa_dev_part_info *partition; + struct ffa_dev_part_info *partition = NULL, *tmp; + struct list_head *phead; bool cb_valid; if (ffa_notifications_disabled()) return -EOPNOTSUPP; - partition = xa_load(&drv_info->partition_info, part_id); + phead = xa_load(&drv_info->partition_info, dev->vm_id); + if (!phead) { + pr_err("%s: Invalid partition ID 0x%x\n", __func__, dev->vm_id); + return -EINVAL; + } + + list_for_each_entry_safe(partition, tmp, phead, node) + if (partition->dev == dev) + break; + if (!partition) { - pr_err("%s: Invalid partition ID 0x%x\n", __func__, part_id); + pr_err("%s: No such partition ID 0x%x\n", __func__, dev->vm_id); return -EINVAL; } @@ -1156,12 +1172,12 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, static int ffa_sched_recv_cb_register(struct ffa_device *dev, ffa_sched_recv_cb cb, void *cb_data) { - return ffa_sched_recv_cb_update(dev->vm_id, cb, cb_data, true); + return ffa_sched_recv_cb_update(dev, cb, cb_data, true); } static int ffa_sched_recv_cb_unregister(struct ffa_device *dev) { - return ffa_sched_recv_cb_update(dev->vm_id, NULL, NULL, false); + return ffa_sched_recv_cb_update(dev, NULL, NULL, false); } static int ffa_notification_bind(u16 dst_id, u64 bitmap, u32 flags) @@ -1548,37 +1564,101 @@ static struct notifier_block ffa_bus_nb = { .notifier_call = ffa_bus_notifier, }; -static int ffa_xa_add_partition_info(int vm_id) +static int ffa_xa_add_partition_info(struct ffa_device *dev) { struct ffa_dev_part_info *info; - int ret; + struct list_head *head, *phead; + int ret = -ENOMEM; + + phead = xa_load(&drv_info->partition_info, dev->vm_id); + if (phead) { + head = phead; + list_for_each_entry(info, head, node) { + if (info->dev == dev) { + pr_err("%s: duplicate dev %p part ID 0x%x\n", + __func__, dev, dev->vm_id); + return -EEXIST; + } + } + } info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) - return -ENOMEM; + return ret; rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, vm_id, info, GFP_KERNEL); - if (ret) { - pr_err("%s: failed to save partition ID 0x%x - ret:%d. Abort.\n", - __func__, vm_id, ret); - kfree(info); + info->dev = dev; + + if (!phead) { + phead = kzalloc(sizeof(*phead), GFP_KERNEL); + if (!phead) + goto free_out; + + INIT_LIST_HEAD(phead); + + ret = xa_insert(&drv_info->partition_info, dev->vm_id, phead, + GFP_KERNEL); + if (ret) { + pr_err("%s: failed to save part ID 0x%x Ret:%d\n", + __func__, dev->vm_id, ret); + goto free_out; + } + } + list_add(&info->node, phead); + return 0; + +free_out: + kfree(phead); + kfree(info); + return ret; +} + +static int ffa_setup_host_partition(int vm_id) +{ + struct ffa_partition_info buf = { 0 }; + struct ffa_device *ffa_dev; + int ret; + + buf.id = vm_id; + ffa_dev = ffa_device_register(&buf, &ffa_drv_ops); + if (!ffa_dev) { + pr_err("%s: failed to register host partition ID 0x%x\n", + __func__, vm_id); + return -EINVAL; } + ret = ffa_xa_add_partition_info(ffa_dev); + if (ret) + return ret; + + if (ffa_notifications_disabled()) + return 0; + + ret = ffa_sched_recv_cb_update(ffa_dev, ffa_self_notif_handle, + drv_info, true); + if (ret) + pr_info("Failed to register driver sched callback %d\n", ret); + return ret; } static void ffa_partitions_cleanup(void) { - struct ffa_dev_part_info *info; + struct list_head *phead; unsigned long idx; /* Clean up/free all registered devices */ ffa_devices_unregister(); - xa_for_each(&drv_info->partition_info, idx, info) { + xa_for_each(&drv_info->partition_info, idx, phead) { + struct ffa_dev_part_info *info, *tmp; + xa_erase(&drv_info->partition_info, idx); - kfree(info); + list_for_each_entry_safe(info, tmp, phead, node) { + list_del(&info->node); + kfree(info); + } + kfree(phead); } xa_destroy(&drv_info->partition_info); @@ -1621,7 +1701,7 @@ static int ffa_setup_partitions(void) !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) ffa_mode_32bit_set(ffa_dev); - if (ffa_xa_add_partition_info(ffa_dev->vm_id)) { + if (ffa_xa_add_partition_info(ffa_dev)) { ffa_device_unregister(ffa_dev); continue; } @@ -1629,12 +1709,16 @@ static int ffa_setup_partitions(void) kfree(pbuf); - /* Check if the host is already added as part of partition info */ + /* + * Check if the host is already added as part of partition info + * No multiple UUID possible for the host, so just checking if + * there is an entry will suffice + */ if (xa_load(&drv_info->partition_info, drv_info->vm_id)) return 0; /* Allocate for the host */ - ret = ffa_xa_add_partition_info(drv_info->vm_id); + ret = ffa_setup_host_partition(drv_info->vm_id); if (ret) ffa_partitions_cleanup(); @@ -1943,19 +2027,10 @@ static int __init ffa_init(void) ffa_notifications_setup(); ret = ffa_setup_partitions(); - if (ret) { - pr_err("failed to setup partitions\n"); - goto cleanup_notifs; - } - - 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; + if (!ret) + return ret; -cleanup_notifs: + pr_err("failed to setup partitions\n"); ffa_notifications_cleanup(); free_pages: if (drv_info->tx_buffer) From patchwork Mon Feb 17 15:39:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13978179 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 D62D4C021A9 for ; Mon, 17 Feb 2025 16:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type: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=pTQFM2801396naWh35lRT9WkJuMqqDxKG1z8AIEdHfE=; b=yyljQqTNunfhsQNXmuxTy0Egea PLNspRNAxi2B/1C5buPtsGOJb7tvINeho28YSorwUAJRFLrc4Ee//S3PnOJ0HxTXAAw5XC2A/X3JK pctgwGI2gdSC8yG4JSm5xHJWJW2ozg7vKGjBVyxdF6+lZyJhoussdP4H9OdMgTz3DrfaQyirN9Qzy M0UdD17BvZlm6SFVgunqfrzie9Fni2oItwjnpTQpS0opXYLwMvc4P/3aXStGPR3ORfBukcCgBQ02L NgBgplpw1nn8/DCrOAzh4Ed9c8Ta1/DKqnhnQKSdlU27ZpBWjibRPKbLWygLNWdr9fDUqxkF1zymr CZKRcBzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3mm-00000005EF1-3KLw; Mon, 17 Feb 2025 16:15:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3Do-000000055XP-2IUV for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:39:49 +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 80045152B; Mon, 17 Feb 2025 07:40:07 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9C5153F6A8; Mon, 17 Feb 2025 07:39:47 -0800 (PST) From: Sudeep Holla Date: Mon, 17 Feb 2025 15:39:00 +0000 Subject: [PATCH v3 19/19] firmware: arm_ffa: Handle ffa_notification_get correctly at virtual FF-A instance MIME-Version: 1.0 Message-Id: <20250217-ffa_updates-v3-19-bd1d9de615e7@arm.com> References: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> In-Reply-To: <20250217-ffa_updates-v3-0-bd1d9de615e7@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3134; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=glQcibRPZ3LfxkYdcYsdlJeo9DnLI2cUT7CIltYuAok=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBns1gvLiiYeNuHpZrc1TNX2jkRDa6aSrZvzKVhn Z9uHQpPgVaJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ7NYLwAKCRAAQbq8MX7i mLB8D/4jUASnurXChQYVGRrJFk2N+5zQlPN+hwPXF6W7okyL28JUVvKWTGrshQ28N/O2uns8NLM RJaSHgSMXPDsVpxbbshCUYUFBnzZ+9IXzIJCkNGzwGVHmM9aLGWGw7wAHo6JEJ74uJhcrJ2xb47 v3ZsSbyZx5gkxcakkKmXCr1mh/kTvv2m4opFRULoItyeKWrtFJSkTKkmlhNz4sh4kWroV7KGJEV CzgsmbHAnofrupMXj402hYBCgEVM+msMEhlPv9bHodefo+Z4VcY5hzHVtdpc8yjDL7JTvAKOPhL cQtj4/fzj/vfVRGsHV1I8WzzUWhEisxSPBWkkATj6itSJOMjH6tWx+xc29vYwi/Ro60t7QKv4Yk zUdvEx1WThdhKkwLTp+b+z6Sb8xyyNSM1aRO+w2GNvvu1xu3XqOwtp+AhIZz8TtTE6QEpwOsSH5 KGt3YYu/x0wKZu+Z2w8vmWbOnpKQbt3GT8cp+xAg6sNElC2IsqCWB1nNVMZYWs8bV52I0qGk5Ow Lm39R/o9Crxvgz8TNtqLZnGeq3rPgJPpkR/Fx0ZZO1lDtN8+20yBQS3MGNWQz5ujq91tO0Jk74a 4jfTgLsA4vzWl4bn2ipkWLdh+k2Z4gdichiq5VX8xXVT7Y7miU6WakJiNOoOfJ8yShRUlzF2+CC 2k4JyvqmWgsjuJQ== 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-20250217_073948_714394_E5FCF482 X-CRM114-Status: GOOD ( 14.35 ) 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 it is assumed that the driver always calls ffa_notification_get() at the NS physical FF-A instance to request the SPMC to return pending SP or SPM Framework notifications. However, in order to support the driver invoking ffa_notification_get() at virtual FF-A instance, we need to make sure correct bits are enabled in the bitmaps enable flag. It is expected to have hypervisor framework and VM notifications bitmap to be zero at the non-secure physical FF-A instance. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index db6334f0c532566565246173373d8f0a42c836af..f3ca703a44413b6394559c68b12fda6a75acadf0 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -841,8 +841,12 @@ enum notify_type { #define NON_SECURE_VM_BITMAP_ENABLE BIT(NON_SECURE_VM) #define SPM_FRAMEWORK_BITMAP_ENABLE BIT(SPM_FRAMEWORK) #define NS_HYP_FRAMEWORK_BITMAP_ENABLE BIT(NS_HYP_FRAMEWORK) -#define FFA_BITMAP_ENABLE_MASK \ +#define FFA_BITMAP_SECURE_ENABLE_MASK \ (SECURE_PARTITION_BITMAP_ENABLE | SPM_FRAMEWORK_BITMAP_ENABLE) +#define FFA_BITMAP_NS_ENABLE_MASK \ + (NON_SECURE_VM_BITMAP_ENABLE | NS_HYP_FRAMEWORK_BITMAP_ENABLE) +#define FFA_BITMAP_ALL_ENABLE_MASK \ + (FFA_BITMAP_SECURE_ENABLE_MASK | FFA_BITMAP_NS_ENABLE_MASK) #define FFA_SECURE_PARTITION_ID_FLAG BIT(15) @@ -914,9 +918,15 @@ static int ffa_notification_get(u32 flags, struct ffa_notify_bitmaps *notify) else if (ret.a0 != FFA_SUCCESS) return -EINVAL; /* Something else went wrong. */ - notify->sp_map = PACK_NOTIFICATION_BITMAP(ret.a2, ret.a3); - notify->vm_map = PACK_NOTIFICATION_BITMAP(ret.a4, ret.a5); - notify->arch_map = PACK_NOTIFICATION_BITMAP(ret.a6, ret.a7); + if (flags & SECURE_PARTITION_BITMAP_ENABLE) + notify->sp_map = PACK_NOTIFICATION_BITMAP(ret.a2, ret.a3); + if (flags & NON_SECURE_VM_BITMAP_ENABLE) + notify->vm_map = PACK_NOTIFICATION_BITMAP(ret.a4, ret.a5); + if (flags & SPM_FRAMEWORK_BITMAP_ENABLE) + notify->arch_map = SPM_FRAMEWORK_BITMAP(ret.a6); + if (flags & NS_HYP_FRAMEWORK_BITMAP_ENABLE) + notify->arch_map = PACK_NOTIFICATION_BITMAP(notify->arch_map, + ret.a7); return 0; } @@ -1444,12 +1454,19 @@ static void handle_fwk_notif_callbacks(u32 bitmap) kfree(buf); } -static void notif_get_and_handle(void *unused) +static void notif_get_and_handle(void *cb_data) { int rc; - struct ffa_notify_bitmaps bitmaps; + u32 flags; + struct ffa_drv_info *info = cb_data; + struct ffa_notify_bitmaps bitmaps = { 0 }; + + if (info->vm_id == 0) /* Non secure physical instance */ + flags = FFA_BITMAP_SECURE_ENABLE_MASK; + else + flags = FFA_BITMAP_ALL_ENABLE_MASK; - rc = ffa_notification_get(FFA_BITMAP_ENABLE_MASK, &bitmaps); + rc = ffa_notification_get(flags, &bitmaps); if (rc) { pr_err("Failed to retrieve notifications with %d!\n", rc); return;