The FF-A runtime transport needs the framework version and U-Boot
endpoint ID after ExitBootServices(). Keep these fields in a dedicated
runtime sub-structure inside struct ffa_priv so they can be copied into
resident storage later.

Update existing users to access the values through uc_priv->rt. This
does not enable runtime behaviour yet.

Reviewed-by: Simon Glass <[email protected]>
Acked-by: Abdellatif El Khlifi <[email protected]>
Signed-off-by: Harsimran Singh Tungal <[email protected]>
---
 drivers/firmware/arm-ffa/arm-ffa-uclass.c | 12 ++++++------
 include/arm_ffa_priv.h                    | 22 +++++++++++++++++-----
 test/dm/ffa.c                             |  6 +++---
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c 
b/drivers/firmware/arm-ffa/arm-ffa-uclass.c
index 76a8775e911..eb159dbfade 100644
--- a/drivers/firmware/arm-ffa/arm-ffa-uclass.c
+++ b/drivers/firmware/arm-ffa/arm-ffa-uclass.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2022-2023 Arm Limited and/or its affiliates 
<[email protected]>
+ * Copyright 2022-2023, 2026 Arm Limited and/or its affiliates 
<[email protected]>
  *
  * Authors:
  *   Abdellatif El Khlifi <[email protected]>
@@ -204,7 +204,7 @@ int ffa_get_version_hdlr(struct udevice *dev)
                if (dev) {
                        uc_priv = dev_get_uclass_priv(dev);
                        if (uc_priv)
-                               uc_priv->fwk_version = res.a0;
+                               uc_priv->rt.fwk_version = res.a0;
                }
 
                return 0;
@@ -238,8 +238,8 @@ static int ffa_get_endpoint_id(struct udevice *dev)
                        }, &res);
 
        if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) {
-               uc_priv->id = GET_SELF_ENDPOINT_ID((u32)res.a2);
-               log_debug("FF-A endpoint ID is %u\n", uc_priv->id);
+               uc_priv->rt.id = GET_SELF_ENDPOINT_ID((u32)res.a2);
+               log_debug("FF-A endpoint ID is %u\n", uc_priv->rt.id);
 
                return 0;
        }
@@ -461,7 +461,7 @@ int ffa_unmap_rxtx_buffers_hdlr(struct udevice *dev)
 
        invoke_ffa_fn((ffa_value_t){
                        .a0 = FFA_SMC_32(FFA_RXTX_UNMAP),
-                       .a1 = PREP_SELF_ENDPOINT_ID(uc_priv->id),
+                       .a1 = PREP_SELF_ENDPOINT_ID(uc_priv->rt.id),
                        }, &res);
 
        if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) {
@@ -890,7 +890,7 @@ int ffa_msg_send_direct_req_hdlr(struct udevice *dev, u16 
dst_part_id,
 
        invoke_ffa_fn((ffa_value_t){
                        .a0 = req_mode,
-                       .a1 = PREP_SELF_ENDPOINT_ID(uc_priv->id) |
+                       .a1 = PREP_SELF_ENDPOINT_ID(uc_priv->rt.id) |
                                PREP_PART_ENDPOINT_ID(dst_part_id),
                        .a2 = 0,
                        .a3 = msg->data0,
diff --git a/include/arm_ffa_priv.h b/include/arm_ffa_priv.h
index d564c33c647..3c74c63dfa6 100644
--- a/include/arm_ffa_priv.h
+++ b/include/arm_ffa_priv.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright 2022-2023 Arm Limited and/or its affiliates 
<[email protected]>
+ * Copyright 2022-2023, 2026 Arm Limited and/or its affiliates 
<[email protected]>
  *
  * Authors:
  *   Abdellatif El Khlifi <[email protected]>
@@ -200,11 +200,24 @@ struct ffa_partitions {
 };
 
 /**
- * struct ffa_priv - the driver private data structure
+ * struct ffa_priv_runtime - the driver's private runtime data structure
  *
  * @fwk_version:       FF-A framework version
- * @emul:      FF-A sandbox emulator
  * @id:        u-boot endpoint ID
+ *
+ * The device private runtime data structure containing all the
+ * data read from secure world.
+ */
+struct ffa_priv_runtime {
+       u32 fwk_version;
+       u16 id;
+};
+
+/**
+ * struct ffa_priv - the driver private data structure
+ *
+ * @rt:                Runtime data captured at boot time
+ * @emul:      FF-A sandbox emulator
  * @partitions:        The partitions descriptors structure
  * @pair:      The RX/TX buffers pair
  *
@@ -212,9 +225,8 @@ struct ffa_partitions {
  * data read from secure world.
  */
 struct ffa_priv {
-       u32 fwk_version;
+       struct ffa_priv_runtime rt;
        struct udevice *emul;
-       u16 id;
        struct ffa_partitions partitions;
        struct ffa_rxtxpair pair;
 };
diff --git a/test/dm/ffa.c b/test/dm/ffa.c
index 593b7177fce..a0c95e62607 100644
--- a/test/dm/ffa.c
+++ b/test/dm/ffa.c
@@ -2,7 +2,7 @@
 /*
  * Functional tests for UCLASS_FFA  class
  *
- * Copyright 2022-2023 Arm Limited and/or its affiliates 
<[email protected]>
+ * Copyright 2022-2023, 2026 Arm Limited and/or its affiliates 
<[email protected]>
  *
  * Authors:
  *   Abdellatif El Khlifi <[email protected]>
@@ -26,14 +26,14 @@ static int check_fwk_version(struct ffa_priv *uc_priv, 
struct unit_test_state *u
        func_data.data0 = &fwk_version;
        func_data.data0_size = sizeof(fwk_version);
        ut_assertok(sandbox_query_ffa_emul_state(FFA_VERSION, &func_data));
-       ut_asserteq(uc_priv->fwk_version, fwk_version);
+       ut_asserteq(uc_priv->rt.fwk_version, fwk_version);
 
        return 0;
 }
 
 static int check_endpoint_id(struct ffa_priv *uc_priv, struct unit_test_state 
*uts)
 {
-       ut_asserteq(0, uc_priv->id);
+       ut_asserteq(0, uc_priv->rt.id);
 
        return 0;
 }
-- 
2.34.1

Reply via email to