Skip to content

Commit b98722f

Browse files
committed
firmware: arm_ffa: Add support for handling framework notifications
JIRA: https://issues.redhat.com/browse/RHEL-102691 commit 285a5ea Author: Sudeep Holla <sudeep.holla@arm.com> Date: Mon, 17 Feb 2025 15:38:58 +0000 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 <viresh.kumar@linaro.org> Message-Id: <20250217-ffa_updates-v3-17-bd1d9de615e7@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
1 parent 8f67099 commit b98722f

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ enum notify_type {
848848

849849
#define SPM_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_LOW(x)
850850
#define NS_HYP_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_HIGH(x)
851+
#define FRAMEWORK_NOTIFY_RX_BUFFER_FULL BIT(0)
851852

852853
static int ffa_notification_bind_common(u16 dst_id, u64 bitmap,
853854
u32 flags, bool is_bind)
@@ -1373,9 +1374,6 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type)
13731374
int notify_id;
13741375
struct notifier_cb_info *cb_info = NULL;
13751376

1376-
if (type == SPM_FRAMEWORK || type == NS_HYP_FRAMEWORK)
1377-
return;
1378-
13791377
for (notify_id = 0; notify_id <= FFA_MAX_NOTIFICATIONS && bitmap;
13801378
notify_id++, bitmap >>= 1) {
13811379
if (!(bitmap & 1))
@@ -1390,6 +1388,46 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type)
13901388
}
13911389
}
13921390

1391+
static void handle_fwk_notif_callbacks(u32 bitmap)
1392+
{
1393+
void *buf;
1394+
uuid_t uuid;
1395+
int notify_id = 0, target;
1396+
struct ffa_indirect_msg_hdr *msg;
1397+
struct notifier_cb_info *cb_info = NULL;
1398+
1399+
/* Only one framework notification defined and supported for now */
1400+
if (!(bitmap & FRAMEWORK_NOTIFY_RX_BUFFER_FULL))
1401+
return;
1402+
1403+
mutex_lock(&drv_info->rx_lock);
1404+
1405+
msg = drv_info->rx_buffer;
1406+
buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL);
1407+
if (!buf) {
1408+
mutex_unlock(&drv_info->rx_lock);
1409+
return;
1410+
}
1411+
1412+
target = SENDER_ID(msg->send_recv_id);
1413+
if (msg->offset >= sizeof(*msg))
1414+
uuid_copy(&uuid, &msg->uuid);
1415+
else
1416+
uuid_copy(&uuid, &uuid_null);
1417+
1418+
mutex_unlock(&drv_info->rx_lock);
1419+
1420+
ffa_rx_release();
1421+
1422+
mutex_lock(&drv_info->notify_lock);
1423+
cb_info = notifier_hnode_get_by_vmid_uuid(notify_id, target, &uuid);
1424+
mutex_unlock(&drv_info->notify_lock);
1425+
1426+
if (cb_info && cb_info->fwk_cb)
1427+
cb_info->fwk_cb(notify_id, cb_info->cb_data, buf);
1428+
kfree(buf);
1429+
}
1430+
13931431
static void notif_get_and_handle(void *unused)
13941432
{
13951433
int rc;
@@ -1401,10 +1439,8 @@ static void notif_get_and_handle(void *unused)
14011439
return;
14021440
}
14031441

1404-
handle_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map),
1405-
SPM_FRAMEWORK);
1406-
handle_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map),
1407-
NS_HYP_FRAMEWORK);
1442+
handle_fwk_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map));
1443+
handle_fwk_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map));
14081444
handle_notif_callbacks(bitmaps.vm_map, NON_SECURE_VM);
14091445
handle_notif_callbacks(bitmaps.sp_map, SECURE_PARTITION);
14101446
}

0 commit comments

Comments
 (0)