[PATCH v3] tee: optee: rework TA bus scanning code

Etienne Carriere etienne.carriere at linaro.org
Mon Sep 5 11:28:21 CEST 2022


Hi Ilias,

I commented v2 instead of you're latest post.
Please find my few comments below.
Addressed or not, Reviewed-by: Etienne Carriere <etienne.carriere at linaro.org>


On Sat, 3 Sept 2022 at 09:54, Ilias Apalodimas
<ilias.apalodimas at linaro.org> wrote:
>
> Late versions of OP-TEE support a pseudo bus.  TAs that behave as
> hardware blocks (e.g TPM, RNG etc) present themselves on a bus which we can
> scan.  Unfortunately U-Boot doesn't support that yet. It's worth noting
> that we already have a workaround for RNG.  The details are in
> commit 70812bb83da6 ("tee: optee: bind rng optee driver")
>
> So let's add a list of devices based on U-Boot Kconfig options that we will
> scan until we properly implement the tee-bus functionality.
>
> While at it change the behaviour of the tee core itself wrt to device
> binding.  If some device binding fails, print a warning instead of
> disabling OP-TEE.
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> Reviewed-by: Jens Wiklander <jens.wiklander at linaro.org>
> ---
> Changes since v:2
> - Fixed typo on driver name ftpm-tee -> ftpm_tee
>
> Changes since v1:
> - remove a macro and use ARRAY_SIZE directly
> - print a warning instead of disabling op-tee if a driver binding fails
>  drivers/tee/optee/core.c | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> index a89d62aaf0b3..1437ba1b676b 100644
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -31,6 +31,18 @@ struct optee_pdata {
>         optee_invoke_fn *invoke_fn;
>  };
>
> +static const struct {
> +       const char *drv_name;
> +       const char *dev_name;
> +} optee_bus_probe[] = {
> +#ifdef CONFIG_RNG_OPTEE
> +       { "optee-rng", "optee-rng" },

Prefer
      { .drv_name = "optee-rng", .dev_name = "optee-rng" },

> +#endif
> +#ifdef CONFIG_TPM2_FTPM_TEE
> +       { "ftpm_tee", "ftpm_tee" },
> +#endif
> +};
> +
>  struct rpc_param {
>         u32     a0;
>         u32     a1;
> @@ -643,7 +655,7 @@ static int optee_probe(struct udevice *dev)
>         struct optee_pdata *pdata = dev_get_plat(dev);
>         u32 sec_caps;
>         struct udevice *child;
> -       int ret;
> +       int ret, i;
>
>         if (!is_optee_api(pdata->invoke_fn)) {
>                 dev_err(dev, "OP-TEE api uid mismatch\n");
> @@ -672,10 +684,13 @@ static int optee_probe(struct udevice *dev)
>          * in U-Boot, the discovery of TA on the TEE bus is not supported:
>          * only bind the drivers associated to the supported OP-TEE TA
>          */
> -       if (IS_ENABLED(CONFIG_RNG_OPTEE)) {
> -               ret = device_bind_driver(dev, "optee-rng", "optee-rng", &child);
> +
> +       for (i = 0; i < ARRAY_SIZE(optee_bus_probe); i++) {
> +               ret = device_bind_driver(dev, optee_bus_probe[i].drv_name,
> +                                        optee_bus_probe[i].dev_name, &child);

Could s/&child/NULL/.

Br,
etienne

>                 if (ret)
> -                       return ret;
> +                       dev_warn(dev, "Failed to bind device %s\n",
> +                                optee_bus_probe[i].dev_name);
>         }
>
>         return 0;
> --
> 2.34.1
>


More information about the U-Boot mailing list