[PATCH v2 02/11] arm-ffa: add FF-A bus runtime support

Simon Glass sjg at chromium.org
Fri May 15 20:25:35 CEST 2026


Hi Harsimran,

On 2026-05-14T12:49:13, Harsimran Singh Tungal
<harsimransingh.tungal at arm.com> wrote:
> arm-ffa: add FF-A bus runtime support
>
> Enable FF-A runtime transport for EFI services
>
> Add the FF-A runtime infrastructure needed after ExitBootServices() so
> EFI runtime services can continue to use the FF-A transport layer.
> Introduce drivers/firmware/arm-ffa/arm-ffa-runtime.c and
> include/arm_ffa_runtime.h with runtime-resident FF-A helpers for
> direct messaging, SMC invocation, and error translation. Add the
> sandbox runtime SMC wrapper, the ARM_FFA_RT_MODE Kconfig option, and
> the ExitBootServices hook that copies the required FF-A runtime data
> into resident storage before enabling the runtime context.
>
> Tag the runtime code and data with __efi_runtime and
> __efi_runtime_data so they remain available after
> ExitBootServices().
>
> Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal at arm.com>
>
> ----
> [...]
>
> drivers/firmware/arm-ffa/Kconfig           |  11 ++
>  drivers/firmware/arm-ffa/Makefile          |   4 +-
>  drivers/firmware/arm-ffa/arm-ffa-runtime.c | 295 +++++++++++++++++++++++++++++
>  drivers/firmware/arm-ffa/arm-ffa-uclass.c  | 113 ++---------
>  drivers/firmware/arm-ffa/arm-ffa.c         |  16 +-
>  drivers/firmware/arm-ffa/ffa-emul-uclass.c |  12 ++
>  include/arm_ffa.h                          |  16 +-
>  include/arm_ffa_priv.h                     |  22 ++-
>  include/arm_ffa_runtime.h                  | 191 +++++++++++++++++++
>  test/dm/ffa.c                              |   6 +-
>  10 files changed, 566 insertions(+), 120 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

> diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c b/drivers/firmware/arm-ffa/arm-ffa-uclass.c
> @@ -1024,6 +937,7 @@ int ffa_rxtx_unmap(struct udevice *dev)
>  static int ffa_do_probe(struct udevice *dev)
>  {
>       int ret;
> +     struct ffa_priv *uc_priv = dev_get_uclass_priv(dev);
>
>       ret = ffa_get_version_hdlr(dev);
>       if (ret)
> @@ -1033,6 +947,12 @@ static int ffa_do_probe(struct udevice *dev)
>       if (ret)
>               return ret;
>
> +     if (IS_ENABLED(CONFIG_ARM_FFA_RT_MODE)) {
> +             ret = ffa_setup_efi_exit_boot_services_event(uc_priv);
> +             if (ret)
> +                     return ret;
> +     }
> +
>       ret = ffa_get_rxtx_map_features_hdlr(dev);

The event is installed before the rxtx-map and partition-cache steps.
If any of those later steps fail, probe returns nonzero but the EBS
event stays registered against this uc_priv. When ExitBootServices()
fires the notifier still copies priv->rt and calls
ffa_enable_runtime_context(), so runtime FF-A appears ready even
though the bus never finished probing. Either install the event at the
end of probe, or tear it down on the error paths.

> diff --git a/drivers/firmware/arm-ffa/arm-ffa-runtime.c b/drivers/firmware/arm-ffa/arm-ffa-runtime.c
> @@ -0,0 +1,295 @@
> +#if IS_ENABLED(CONFIG_ARM_FFA_RT_MODE)
> +static void EFIAPI ffa_rt_exit_boot_services_notify(struct efi_event *event,
> +                                                 void *context)
> +{
> +     struct ffa_priv *priv = context;
> +
> +     if (priv) {
> +             ffa_copy_runtime_priv(&priv->rt);
> +     } else {
> +             log_err("FF-A: runtime data missing, keeping RT mode disabled\n");
> +             return;
> +     }
> +
> +     ffa_enable_runtime_context();
> +}

Please flip this around - the usual U-Boot thing is an early-return guard:

   if (!priv) {
           log_err("FF-A: runtime data missing, keeping RT mode disabled\n");
           return;
   }
   ffa_copy_runtime_priv(&priv->rt);
   ffa_enable_runtime_context();

Also, since the context is set when we create the event, this is
essentially can't happen - drop to log_warn() or an assert.

> diff --git a/drivers/firmware/arm-ffa/arm-ffa-runtime.c b/drivers/firmware/arm-ffa/arm-ffa-runtime.c
> @@ -0,0 +1,295 @@
> +/* Error mapping declarations */
> +
> +int __ffa_runtime_data ffa_to_std_errmap[MAX_NUMBER_FFA_ERR] = {
> +     [NOT_SUPPORTED] = -EOPNOTSUPP,

Only referenced inside ffa_to_std_errno() in this file — please make
it static. Also this is a definition, not a declaration.

> diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c b/drivers/firmware/arm-ffa/arm-ffa-uclass.c
> @@ -1046,7 +966,6 @@ static int ffa_do_probe(struct udevice *dev)
>               ffa_unmap_rxtx_buffers_hdlr(dev);
>               return ret;
>       }
> -
>       return 0;
>  }

Unrelated whitespace change - please drop (we normally have a blank
line before the final return in a function).

> diff --git a/drivers/firmware/arm-ffa/arm-ffa-runtime.c b/drivers/firmware/arm-ffa/arm-ffa-runtime.c
> @@ -0,0 +1,295 @@
> +bool __ffa_runtime ffa_get_status_runtime_context(void)
> +{
> +     return ffa_runtime_enabled;
> +}

The name reads awkwardly - how about ffa_runtime_is_ready() or
ffa_runtime_context_ready() ?. Same for ffa_enable_runtime_context() /
ffa_reset_runtime_context() if you want to keep them parallel.

>     arm-ffa: add FF-A bus runtime support
>
>     Enable FF-A runtime transport for EFI services
>
>     Add the FF-A runtime infrastructure needed after ExitBootServices() so
>     EFI runtime services can continue to use the FF-A transport layer.
>     Introduce drivers/firmware/arm-ffa/arm-ffa-runtime.c and
>     include/arm_ffa_runtime.h with runtime-resident FF-A helpers for

Please use single quotes rather than backticks throughout the commit
message if you need them at all, also for CONFIG_ARM_FFA_RT_MODE /
efi_memset_runtime() later on. Filenames such as
drivers/firmware/arm-ffa/arm-ffa-runtime.c don't need quoting at all.

Also, the single-line lede ('Enable FF-A runtime transport for EFI
services') is redundant with the paragraph that follows - drop it and
let the first paragraph carry the motivation.

Regards,
Simon


More information about the U-Boot mailing list