The runtime transport adds ffa_invoke_msg_send_direct_req() as the common implementation for FFA_MSG_SEND_DIRECT_REQ/RESP. Use the same helper from the boot-time ffa_msg_send_direct_req_hdlr() instead of keeping a second copy of the direct-message sequence in arm-ffa-uclass.c.
This keeps boot-time and runtime direct-message handling aligned. 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 | 60 ++--------------------- include/arm_ffa.h | 16 ++---- 2 files changed, 7 insertions(+), 69 deletions(-) diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c b/drivers/firmware/arm-ffa/arm-ffa-uclass.c index 13e22a1b7f7..668c2156f8b 100644 --- a/drivers/firmware/arm-ffa/arm-ffa-uclass.c +++ b/drivers/firmware/arm-ffa/arm-ffa-uclass.c @@ -818,16 +818,8 @@ static int ffa_cache_partitions_info(struct udevice *dev) * @msg: pointer to the message data preallocated by the client (in/out) * @is_smc64: select 64-bit or 32-bit FF-A ABI * - * Implement FFA_MSG_SEND_DIRECT_{REQ,RESP} - * FF-A functions. - * - * FFA_MSG_SEND_DIRECT_REQ is used to send the data to the secure partition. - * The response from the secure partition is handled by reading the - * FFA_MSG_SEND_DIRECT_RESP arguments. - * - * The maximum size of the data that can be exchanged is 40 bytes which is - * sizeof(struct ffa_send_direct_data) as defined by the FF-A specification 1.0 - * in the section relevant to FFA_MSG_SEND_DIRECT_{REQ,RESP} + * This function calls the ffa_invoke_msg_send_direct_req() function which + * invokes FFA_MSG_SEND_DIRECT_{REQ,RESP} FF-A functions. * * Return: * @@ -836,9 +828,6 @@ static int ffa_cache_partitions_info(struct udevice *dev) int ffa_msg_send_direct_req_hdlr(struct udevice *dev, u16 dst_part_id, struct ffa_send_direct_data *msg, bool is_smc64) { - ffa_value_t res = {0}; - int ffa_errno; - u64 req_mode, resp_mode; struct ffa_priv *uc_priv; uc_priv = dev_get_uclass_priv(dev); @@ -847,50 +836,7 @@ int ffa_msg_send_direct_req_hdlr(struct udevice *dev, u16 dst_part_id, if (!uc_priv->partitions.count || !uc_priv->partitions.descs) return -ENODEV; - if (is_smc64) { - req_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ); - resp_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP); - } else { - req_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_REQ); - resp_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_RESP); - } - - invoke_ffa_fn((ffa_value_t){ - .a0 = req_mode, - .a1 = PREP_SELF_ENDPOINT_ID(uc_priv->rt.id) | - PREP_PART_ENDPOINT_ID(dst_part_id), - .a2 = 0, - .a3 = msg->data0, - .a4 = msg->data1, - .a5 = msg->data2, - .a6 = msg->data3, - .a7 = msg->data4, - }, &res); - - while (res.a0 == FFA_SMC_32(FFA_INTERRUPT)) - invoke_ffa_fn((ffa_value_t){ - .a0 = FFA_SMC_32(FFA_RUN), - .a1 = res.a1, - }, &res); - - if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { - /* Message sent with no response */ - return 0; - } - - if (res.a0 == resp_mode) { - /* Message sent with response extract the return data */ - msg->data0 = res.a3; - msg->data1 = res.a4; - msg->data2 = res.a5; - msg->data3 = res.a6; - msg->data4 = res.a7; - - return 0; - } - - ffa_errno = res.a2; - return ffa_to_std_errno(ffa_errno); + return ffa_invoke_msg_send_direct_req(uc_priv->rt.id, dst_part_id, msg, is_smc64); } /* FF-A driver operations (used by clients for communicating with FF-A)*/ diff --git a/include/arm_ffa.h b/include/arm_ffa.h index 2994d8ee3ae..6a03aad81a8 100644 --- a/include/arm_ffa.h +++ b/include/arm_ffa.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]> @@ -129,21 +129,13 @@ int ffa_sync_send_receive(struct udevice *dev, u16 dst_part_id, /** * ffa_msg_send_direct_req_hdlr() - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function - * @dev: The arm_ffa bus device + * @dev: The FF-A bus device * @dst_part_id: destination partition ID * @msg: pointer to the message data preallocated by the client (in/out) * @is_smc64: select 64-bit or 32-bit FF-A ABI * - * This function implements FFA_MSG_SEND_DIRECT_{REQ,RESP} - * FF-A functions. - * - * FFA_MSG_SEND_DIRECT_REQ is used to send the data to the secure partition. - * The response from the secure partition is handled by reading the - * FFA_MSG_SEND_DIRECT_RESP arguments. - * - * The maximum size of the data that can be exchanged is 40 bytes which is - * sizeof(struct ffa_send_direct_data) as defined by the FF-A specification 1.0 - * in the section relevant to FFA_MSG_SEND_DIRECT_{REQ,RESP} + * This function calls the ffa_invoke_msg_send_direct_req() function which + * invokes FFA_MSG_SEND_DIRECT_{REQ,RESP} FF-A functions. * * Return: * -- 2.34.1
