[PATCH 3/8] arm_ffa: Add FFA_MEM_RECLAIM support
Ilias Apalodimas
ilias.apalodimas at linaro.org
Fri Nov 1 16:21:26 CET 2024
[...]
> }
>
> +/**
> + * ffa_memory_reclaim_hdlr() - FFA_MEM_RECLAIM handler function
> + * @dev: The FF-A bus device
> + * @g_handle: The memory region globally unique Handle
> + * @flags: Zero memory and time slicing flags
> + *
> + * Implement FFA_MEM_RECLAIM FF-A function
> + * to restore exclusive access to a memory region back to its Owner.
> + *
> + * Return:
> + *
> + * 0 on success. Otherwise, failure
> + */
> +int ffa_memory_reclaim_hdlr(struct udevice *dev, u64 g_handle, u32 flags)
> +{
> + ffa_value_t res;
> + int ffa_errno;
> +
> + invoke_ffa_fn((ffa_value_t){
> + .a0 = FFA_SMC_32(FFA_MEM_RECLAIM),
> + .a1 = HANDLE_LOW(g_handle), .a2 = HANDLE_HIGH(g_handle),
> + .a3 = flags,
> + },
> + &res
> + );
> +
> + if (res.a0 != FFA_SMC_32(FFA_SUCCESS)) {
> + ffa_errno = res.a2;
> + ffa_print_error_log(FFA_MEM_RECLAIM, ffa_errno);
> + return ffa_to_std_errno(ffa_errno);
> + }
> +
> + return 0;
> +}
Is there a reason you have to define both ffa_memory_reclaim_hdlr() and ffa_memory_reclaim()?
Can't you just move the checks of ffa_memory_reclaim() to
ffa_memory_reclaim_hdlr()?
> +
> /* FF-A driver operations (used by clients for communicating with FF-A)*/
>
> /**
> @@ -1214,6 +1261,29 @@ int ffa_memory_share(struct udevice *dev, struct ffa_mem_ops_args *args)
> return ops->memory_share(dev, args);
> }
>
> +/**
> + * ffa_memory_reclaim() - FFA_MEM_RECLAIM driver operation
> + * @dev: The FF-A bus device
> + * @g_handle: The memory region globally unique Handle
> + * @flags: Zero memory and time slicing flags
> + *
> + * Driver operation for FFA_MEM_RECLAIM.
> + * Please see ffa_memory_reclaim_hdlr() description for more details.
> + *
> + * Return:
> + *
> + * 0 on success. Otherwise, failure
> + */
> +int ffa_memory_reclaim(struct udevice *dev, u64 g_handle, u32 flags)
> +{
> + struct ffa_bus_ops *ops = ffa_get_ops(dev);
> +
> + if (!ops || !ops->memory_reclaim)
> + return -ENOSYS;
> +
> + return ops->memory_reclaim(dev, g_handle, flags);
> +}
> +
> /**
> * ffa_do_probe() - probing FF-A framework
> * @dev: the FF-A bus device (arm_ffa)
> diff --git a/drivers/firmware/arm-ffa/arm-ffa.c b/drivers/firmware/arm-ffa/arm-ffa.c
> index c4211c953ef..b7e751e3821 100644
> --- a/drivers/firmware/arm-ffa/arm-ffa.c
> +++ b/drivers/firmware/arm-ffa/arm-ffa.c
> @@ -85,6 +85,7 @@ static const struct ffa_bus_ops ffa_ops = {
> .sync_send_receive = ffa_msg_send_direct_req_hdlr,
> .rxtx_unmap = ffa_unmap_rxtx_buffers_hdlr,
> .memory_share = ffa_memory_share_hdlr,
> + .memory_reclaim = ffa_memory_reclaim_hdlr,
> };
>
[...]
Thanks
/Ilias
More information about the U-Boot
mailing list