Skip to content

Commit f4bfcae

Browse files
committed
firmware: arm_ffa: Add checks for the notification enabled state
We need to check if the FF-A notifications are enabled or not in all the notification operations that are accessible for the FF-A device from the FF-A driver. This helps to avoid making calls to the FF-A firmware even if the notification setup has failed. Link: https://lore.kernel.org/r/[email protected] Tested-by: Jens Wiklander <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 6f47023 commit f4bfcae

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct ffa_drv_info {
9999
void *tx_buffer;
100100
bool mem_ops_native;
101101
bool bitmap_created;
102+
bool notif_enabled;
102103
unsigned int sched_recv_irq;
103104
unsigned int cpuhp_state;
104105
struct ffa_pcpu_irq __percpu *irq_pcpu;
@@ -889,6 +890,8 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
889890

890891
#define FFA_SECURE_PARTITION_ID_FLAG BIT(15)
891892

893+
#define ffa_notifications_disabled() (!drv_info->notif_enabled)
894+
892895
enum notify_type {
893896
NON_SECURE_VM,
894897
SECURE_PARTITION,
@@ -908,6 +911,9 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback,
908911
struct ffa_dev_part_info *partition;
909912
bool cb_valid;
910913

914+
if (ffa_notifications_disabled())
915+
return -EOPNOTSUPP;
916+
911917
partition = xa_load(&drv_info->partition_info, part_id);
912918
write_lock(&partition->rw_lock);
913919

@@ -1001,6 +1007,9 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id)
10011007
int rc;
10021008
enum notify_type type = ffa_notify_type_get(dev->vm_id);
10031009

1010+
if (ffa_notifications_disabled())
1011+
return -EOPNOTSUPP;
1012+
10041013
if (notify_id >= FFA_MAX_NOTIFICATIONS)
10051014
return -EINVAL;
10061015

@@ -1027,6 +1036,9 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu,
10271036
u32 flags = 0;
10281037
enum notify_type type = ffa_notify_type_get(dev->vm_id);
10291038

1039+
if (ffa_notifications_disabled())
1040+
return -EOPNOTSUPP;
1041+
10301042
if (notify_id >= FFA_MAX_NOTIFICATIONS)
10311043
return -EINVAL;
10321044

@@ -1057,6 +1069,9 @@ static int ffa_notify_send(struct ffa_device *dev, int notify_id,
10571069
{
10581070
u32 flags = 0;
10591071

1072+
if (ffa_notifications_disabled())
1073+
return -EOPNOTSUPP;
1074+
10601075
if (is_per_vcpu)
10611076
flags |= (PER_VCPU_NOTIFICATION_FLAG | vcpu << 16);
10621077

@@ -1388,6 +1403,7 @@ static void ffa_notifications_cleanup(void)
13881403
ffa_notification_bitmap_destroy();
13891404
drv_info->bitmap_created = false;
13901405
}
1406+
drv_info->notif_enabled = false;
13911407
}
13921408

13931409
static void ffa_notifications_setup(void)
@@ -1422,6 +1438,7 @@ static void ffa_notifications_setup(void)
14221438
hash_init(drv_info->notifier_hash);
14231439
mutex_init(&drv_info->notify_lock);
14241440

1441+
drv_info->notif_enabled = true;
14251442
return;
14261443
cleanup:
14271444
pr_info("Notification setup failed %d, not enabled\n", ret);

0 commit comments

Comments
 (0)