]> git.itanic.dy.fi Git - linux-stable/commitdiff
firmware: arm_ffa: Add checks for the notification enabled state
authorSudeep Holla <sudeep.holla@arm.com>
Tue, 24 Oct 2023 10:56:19 +0000 (11:56 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 13 Nov 2023 11:51:26 +0000 (11:51 +0000)
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/20231024-ffa-notification-fixes-v1-3-d552c0ec260d@arm.com
Tested-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_ffa/driver.c

index 69ad3add31755045e8d0002a97de52411cc1b181..1724a0cbb2cf9bc1a85dc2ddad81daae26c47baa 100644 (file)
@@ -99,6 +99,7 @@ struct ffa_drv_info {
        void *tx_buffer;
        bool mem_ops_native;
        bool bitmap_created;
+       bool notif_enabled;
        unsigned int sched_recv_irq;
        unsigned int cpuhp_state;
        struct ffa_pcpu_irq __percpu *irq_pcpu;
@@ -889,6 +890,8 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *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,
@@ -908,6 +911,9 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback,
        struct ffa_dev_part_info *partition;
        bool cb_valid;
 
+       if (ffa_notifications_disabled())
+               return -EOPNOTSUPP;
+
        partition = xa_load(&drv_info->partition_info, part_id);
        write_lock(&partition->rw_lock);
 
@@ -1001,6 +1007,9 @@ 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;
+
        if (notify_id >= FFA_MAX_NOTIFICATIONS)
                return -EINVAL;
 
@@ -1027,6 +1036,9 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu,
        u32 flags = 0;
        enum notify_type type = ffa_notify_type_get(dev->vm_id);
 
+       if (ffa_notifications_disabled())
+               return -EOPNOTSUPP;
+
        if (notify_id >= FFA_MAX_NOTIFICATIONS)
                return -EINVAL;
 
@@ -1057,6 +1069,9 @@ static int ffa_notify_send(struct ffa_device *dev, int notify_id,
 {
        u32 flags = 0;
 
+       if (ffa_notifications_disabled())
+               return -EOPNOTSUPP;
+
        if (is_per_vcpu)
                flags |= (PER_VCPU_NOTIFICATION_FLAG | vcpu << 16);
 
@@ -1388,6 +1403,7 @@ static void ffa_notifications_cleanup(void)
                ffa_notification_bitmap_destroy();
                drv_info->bitmap_created = false;
        }
+       drv_info->notif_enabled = false;
 }
 
 static void ffa_notifications_setup(void)
@@ -1422,6 +1438,7 @@ static void ffa_notifications_setup(void)
        hash_init(drv_info->notifier_hash);
        mutex_init(&drv_info->notify_lock);
 
+       drv_info->notif_enabled = true;
        return;
 cleanup:
        pr_info("Notification setup failed %d, not enabled\n", ret);