]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: arm_ffa: Tie FF-A version checks to specific features
authorSudeep Holla <sudeep.holla@arm.com>
Thu, 16 Oct 2025 09:41:11 +0000 (10:41 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 15 Dec 2025 10:31:15 +0000 (10:31 +0000)
The FF-A driver currently performs loose comparisons when checking the
supported FF-A feature, which can inadvertently treat future or
intermediate revisions as compatible.

Replace generic `version {>,<} FFA_VERSION_1_*` pattern checks with
feature-specific macros that clearly express which functionality
depends on FF-A versioning.

This improves readability and future maintainability by tying each
feature (e.g. GET_COUNT_ONLY, size/UUID/exec state in responses) to
explicit version requirements instead of relying on generic version
comparisons. This improves robustness and clarity as the FF-A
specification evolves.

No functional change, only improves code readability.

Message-Id: <20251016094111.946236-1-sudeep.holla@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_ffa/driver.c

index 7209a630f6d16ddc3a6a8a6e97e3030185209711..351780ac8d72512d653b037af39ad730be724183 100644 (file)
@@ -246,6 +246,11 @@ static int ffa_features(u32 func_feat_id, u32 input_props,
 }
 
 #define PARTITION_INFO_GET_RETURN_COUNT_ONLY   BIT(0)
+#define FFA_SUPPORTS_GET_COUNT_ONLY(version)   ((version) > FFA_VERSION_1_0)
+#define FFA_PART_INFO_HAS_SIZE_IN_RESP(version)        ((version) > FFA_VERSION_1_0)
+#define FFA_PART_INFO_HAS_UUID_IN_RESP(version)        ((version) > FFA_VERSION_1_0)
+#define FFA_PART_INFO_HAS_EXEC_STATE_IN_RESP(version)  \
+       ((version) > FFA_VERSION_1_0)
 
 /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
 static int
@@ -255,7 +260,7 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
        int idx, count, flags = 0, sz, buf_sz;
        ffa_value_t partition_info;
 
-       if (drv_info->version > FFA_VERSION_1_0 &&
+       if (FFA_SUPPORTS_GET_COUNT_ONLY(drv_info->version) &&
            (!buffer || !num_partitions)) /* Just get the count for now */
                flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
 
@@ -273,12 +278,11 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
 
        count = partition_info.a2;
 
-       if (drv_info->version > FFA_VERSION_1_0) {
+       if (FFA_PART_INFO_HAS_SIZE_IN_RESP(drv_info->version)) {
                buf_sz = sz = partition_info.a3;
                if (sz > sizeof(*buffer))
                        buf_sz = sizeof(*buffer);
        } else {
-               /* FFA_VERSION_1_0 lacks size in the response */
                buf_sz = sz = 8;
        }
 
@@ -1706,7 +1710,7 @@ static int ffa_setup_partitions(void)
        struct ffa_device *ffa_dev;
        struct ffa_partition_info *pbuf, *tpbuf;
 
-       if (drv_info->version == FFA_VERSION_1_0) {
+       if (!FFA_PART_INFO_HAS_UUID_IN_RESP(drv_info->version)) {
                ret = bus_register_notifier(&ffa_bus_type, &ffa_bus_nb);
                if (ret)
                        pr_err("Failed to register FF-A bus notifiers\n");
@@ -1733,7 +1737,7 @@ static int ffa_setup_partitions(void)
                        continue;
                }
 
-               if (drv_info->version > FFA_VERSION_1_0 &&
+               if (FFA_PART_INFO_HAS_EXEC_STATE_IN_RESP(drv_info->version) &&
                    !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC))
                        ffa_mode_32bit_set(ffa_dev);