Skip to content

Commit faa1962

Browse files
committed
firmware: arm_ffa: Implement the FFA_NOTIFICATION_GET interface
The framework provides an interface to the receiver to determine the identity of the notification. A receiver endpoint must use the FFA_NOTIFICATION_GET interface to retrieve its pending notifications and handle them. Add the support for FFA_NOTIFICATION_GET to allow the caller(receiver) to fetch its pending notifications from other partitions in the system. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sudeep Holla <[email protected]>
1 parent 4756177 commit faa1962

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,14 @@ static int ffa_notification_bitmap_destroy(void)
593593
((u32)(FIELD_GET(NOTIFICATION_HIGH_MASK, (x))))
594594
#define NOTIFICATION_BITMAP_LOW(x) \
595595
((u32)(FIELD_GET(NOTIFICATION_LOW_MASK, (x))))
596+
#define PACK_NOTIFICATION_BITMAP(low, high) \
597+
(FIELD_PREP(NOTIFICATION_LOW_MASK, (low)) | \
598+
FIELD_PREP(NOTIFICATION_HIGH_MASK, (high)))
599+
600+
#define RECEIVER_VCPU_MASK GENMASK(31, 16)
601+
#define PACK_NOTIFICATION_GET_RECEIVER_INFO(vcpu_r, r) \
602+
(FIELD_PREP(RECEIVER_VCPU_MASK, (vcpu_r)) | \
603+
FIELD_PREP(RECEIVER_ID_MASK, (r)))
596604

597605
static int ffa_notification_bind_common(u16 dst_id, u64 bitmap,
598606
u32 flags, bool is_bind)
@@ -636,6 +644,35 @@ int ffa_notification_set(u16 src_id, u16 dst_id, u32 flags, u64 bitmap)
636644
return 0;
637645
}
638646

647+
struct ffa_notify_bitmaps {
648+
u64 sp_map;
649+
u64 vm_map;
650+
u64 arch_map;
651+
};
652+
653+
static int ffa_notification_get(u32 flags, struct ffa_notify_bitmaps *notify)
654+
{
655+
ffa_value_t ret;
656+
u16 src_id = drv_info->vm_id;
657+
u16 cpu_id = smp_processor_id();
658+
u32 rec_vcpu_ids = PACK_NOTIFICATION_GET_RECEIVER_INFO(cpu_id, src_id);
659+
660+
invoke_ffa_fn((ffa_value_t){
661+
.a0 = FFA_NOTIFICATION_GET, .a1 = rec_vcpu_ids, .a2 = flags,
662+
}, &ret);
663+
664+
if (ret.a0 == FFA_ERROR)
665+
return ffa_to_linux_errno((int)ret.a2);
666+
else if (ret.a0 != FFA_SUCCESS)
667+
return -EINVAL; /* Something else went wrong. */
668+
669+
notify->sp_map = PACK_NOTIFICATION_BITMAP(ret.a2, ret.a3);
670+
notify->vm_map = PACK_NOTIFICATION_BITMAP(ret.a4, ret.a5);
671+
notify->arch_map = PACK_NOTIFICATION_BITMAP(ret.a6, ret.a7);
672+
673+
return 0;
674+
}
675+
639676
static int ffa_run(struct ffa_device *dev, u16 vcpu)
640677
{
641678
ffa_value_t ret;

0 commit comments

Comments
 (0)