mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	 Sudeep Holla <sudeep.holla@arm.com>,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: [PATCH v2 14/18] firmware: arm_ffa: Refactoring to prepare for framework notification support
Date: Fri, 31 Jan 2025 11:24:14 +0000	[thread overview]
Message-ID: <20250131-ffa_updates-v2-14-544ba4e35387@arm.com> (raw)
In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com>

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.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 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 7282aeb3ee498b09010aa2867ef94bf3e0248008..dc2d05bb361272b4100802503dd883c17f8900f3 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

-- 
2.34.1


  parent reply	other threads:[~2025-01-31 11:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31 11:24 [PATCH v2 00/18] firmware: arm_ffa: Framework notification support + other updates and fixes Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 01/18] firmware: arm_ffa: Replace SCMI by FF-A in the macro Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 02/18] firmware: arm_ffa: Replace UUID buffer to standard UUID format Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 03/18] firmware: arm_ffa: Align sync_send_receive{,2} function prototypes Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 04/18] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get() Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 05/18] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get() Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 06/18] firmware: arm_ffa: Refactor addition of partition information into XArray Sudeep Holla
2025-02-14  4:50   ` Viresh Kumar
2025-02-17 14:13     ` Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 07/18] firmware: arm_ffa: Handle the presence of host partition in the partition info Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 08/18] firmware: arm_ffa: Unregister the FF-A devices when cleaning up the partitions Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 09/18] firmware: arm_ffa: Helper to check if a partition can receive REQUEST2 messages Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 10/18] firmware: arm_ffa: Add support for passing UUID in FFA_MSG_SEND2 Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 11/18] firmware: arm_ffa: Upgrade FF-A version to v1.2 in the driver Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 12/18] firmware: arm_ffa: Reject higher major version as incompatible Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 13/18] firmware: arm_ffa: Remove unnecessary declaration of ffa_partitions_cleanup() Sudeep Holla
2025-01-31 11:24 ` Sudeep Holla [this message]
2025-01-31 11:24 ` [PATCH v2 15/18] firmware: arm_ffa: Stash ffa_device instead of notify_type in notifier_cb_info Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 16/18] firmware: arm_ffa: Add support for {un,}registration of framework notifications Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 17/18] firmware: arm_ffa: Add support for handling " Sudeep Holla
2025-02-10 10:17   ` Viresh Kumar
2025-02-12 10:57     ` Sudeep Holla
2025-01-31 11:24 ` [PATCH v2 18/18] firmware: arm_ffa: Allow multiple UUIDs per partition to register SRI callback Sudeep Holla
2025-02-12 11:05   ` Sudeep Holla
2025-02-14 11:36 ` [PATCH v2 00/18] firmware: arm_ffa: Framework notification support + other updates and fixes Viresh Kumar
2025-02-17 14:14   ` Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250131-ffa_updates-v2-14-544ba4e35387@arm.com \
    --to=sudeep.holla@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®