Skip to content

Commit f183b1d

Browse files
committed
firmware: arm_ffa: Tie FF-A version checks to specific features
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>
1 parent 9fda364 commit f183b1d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/firmware/arm_ffa/driver.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ static int ffa_features(u32 func_feat_id, u32 input_props,
246246
}
247247

248248
#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0)
249+
#define FFA_SUPPORTS_GET_COUNT_ONLY(version) ((version) > FFA_VERSION_1_0)
250+
#define FFA_PART_INFO_HAS_SIZE_IN_RESP(version) ((version) > FFA_VERSION_1_0)
251+
#define FFA_PART_INFO_HAS_UUID_IN_RESP(version) ((version) > FFA_VERSION_1_0)
252+
#define FFA_PART_INFO_HAS_EXEC_STATE_IN_RESP(version) \
253+
((version) > FFA_VERSION_1_0)
249254

250255
/* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
251256
static int
@@ -255,7 +260,7 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
255260
int idx, count, flags = 0, sz, buf_sz;
256261
ffa_value_t partition_info;
257262

258-
if (drv_info->version > FFA_VERSION_1_0 &&
263+
if (FFA_SUPPORTS_GET_COUNT_ONLY(drv_info->version) &&
259264
(!buffer || !num_partitions)) /* Just get the count for now */
260265
flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
261266

@@ -273,12 +278,11 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
273278

274279
count = partition_info.a2;
275280

276-
if (drv_info->version > FFA_VERSION_1_0) {
281+
if (FFA_PART_INFO_HAS_SIZE_IN_RESP(drv_info->version)) {
277282
buf_sz = sz = partition_info.a3;
278283
if (sz > sizeof(*buffer))
279284
buf_sz = sizeof(*buffer);
280285
} else {
281-
/* FFA_VERSION_1_0 lacks size in the response */
282286
buf_sz = sz = 8;
283287
}
284288

@@ -1706,7 +1710,7 @@ static int ffa_setup_partitions(void)
17061710
struct ffa_device *ffa_dev;
17071711
struct ffa_partition_info *pbuf, *tpbuf;
17081712

1709-
if (drv_info->version == FFA_VERSION_1_0) {
1713+
if (!FFA_PART_INFO_HAS_UUID_IN_RESP(drv_info->version)) {
17101714
ret = bus_register_notifier(&ffa_bus_type, &ffa_bus_nb);
17111715
if (ret)
17121716
pr_err("Failed to register FF-A bus notifiers\n");
@@ -1733,7 +1737,7 @@ static int ffa_setup_partitions(void)
17331737
continue;
17341738
}
17351739

1736-
if (drv_info->version > FFA_VERSION_1_0 &&
1740+
if (FFA_PART_INFO_HAS_EXEC_STATE_IN_RESP(drv_info->version) &&
17371741
!(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC))
17381742
ffa_mode_32bit_set(ffa_dev);
17391743

0 commit comments

Comments
 (0)