From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Etienne Carriere <etienne.carriere@linaro.org>
Cc: u-boot@lists.denx.de, Jens Wiklander <jens.wiklander@linaro.org>,
Patrick Delaunay <patrick.delaunay@foss.st.com>
Subject: Re: [PATCH 1/2] drivers: tee: optee: discover OP-TEE services
Date: Mon, 6 Jun 2022 12:49:44 +0300 [thread overview]
Message-ID: <Yp3NuLByTDehL5s5@hades> (raw)
In-Reply-To: <20220601082752.301602-1-etienne.carriere@linaro.org>
Hi Etienne,
On Wed, Jun 01, 2022 at 10:27:51AM +0200, Etienne Carriere wrote:
> This change defines resources for OP-TEE service drivers to register
> themselves for being bound to when OP-TEE firmware reports the related
> service is supported. OP-TEE services are discovered during optee
> driver probe sequence. Discovery of optee services and binding to
> related U-Boot drivers is embedded upon configuration switch
> CONFIG_OPTEE_SERVICE_DISCOVERY.
>
> Cc: Jens Wiklander <jens.wiklander@linaro.org>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
> ---
> drivers/tee/optee/Kconfig | 8 ++
> drivers/tee/optee/core.c | 187 +++++++++++++++++++++++++++++++++++-
> include/tee/optee_service.h | 29 ++++++
> 3 files changed, 223 insertions(+), 1 deletion(-)
> create mode 100644 include/tee/optee_service.h
>
> diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
> index d03028070b..9dc65b0501 100644
> --- a/drivers/tee/optee/Kconfig
> +++ b/drivers/tee/optee/Kconfig
> @@ -37,6 +37,14 @@ config OPTEE_TA_SCP03
>
[...]
> +static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *count, u32 tee_sess)
> +{
> + size_t shm_size = 0;
> + int ret;
> +
> + ret = __enum_services(dev, NULL, &shm_size, tee_sess);
> + if (ret)
> + return ret;
> +
> + ret = tee_shm_alloc(dev, shm_size, 0, shm);
> + if (ret) {
> + dev_err(dev, "Failed to allocated shared memory: %d\n", ret);
> + return ret;
> + }
> +
> + ret = __enum_services(dev, *shm, &shm_size, tee_sess);
> + if (ret)
> + tee_shm_free(*shm);
I'd prefer if we handled this a bit differently. Instead of freeing the
buffer here, just release it on bind_service_drivers() always
> + else
> + *count = shm_size / sizeof(struct tee_optee_ta_uuid);
> +
> + return ret;
> +}
> +
> +
> static int optee_probe(struct udevice *dev)
> {
> struct optee_pdata *pdata = dev_get_plat(dev);
> u32 sec_caps;
> - struct udevice *child;
> int ret;
>
> if (!is_optee_api(pdata->invoke_fn)) {
> @@ -668,15 +842,23 @@ static int optee_probe(struct udevice *dev)
> return -ENOENT;
> }
>
> + ret = bind_service_drivers(dev);
> + if (ret)
> + return ret;
> +
> +#ifndef CONFIG_OPTEE_SERVICE_DISCOVERY
> /*
> * 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)) {
> + struct udevice *child;
> +
> ret = device_bind_driver(dev, "optee-rng", "optee-rng", &child);
The same principle applies for fTPM. Moreover the linux kernel supports
bus scanning, which creates a conflict when the fTPM is added on the .dts
(for u-boot to scan it).
Can we make this a bit more generic, even though only the rng is added on
this patch?
something like
struct devices {
const char *drv_name;
const char *dev_name;
} tee_bus_devices = {
{
"optee-rng",
"optee-rng",
},
}
and add an array of the 'scanable' devices? It would make adding the ftpm
and other devices trivial
> if (ret)
> return ret;
> }
> +#endif
[...]
Thanks!
/Ilias
next prev parent reply other threads:[~2022-06-06 9:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 8:27 [PATCH 1/2] drivers: tee: optee: discover OP-TEE services Etienne Carriere
2022-06-01 8:27 ` [PATCH 2/2] drivers: rng: optee_rng: register to CONFIG_OPTEE_SERVICE_DISCOVERY Etienne Carriere
2022-06-02 12:19 ` Patrick DELAUNAY
2022-06-02 11:59 ` [PATCH 1/2] drivers: tee: optee: discover OP-TEE services Patrick DELAUNAY
2022-06-06 9:49 ` Ilias Apalodimas [this message]
2022-06-07 9:46 ` Etienne Carriere
2022-06-07 10:29 ` Ilias Apalodimas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yp3NuLByTDehL5s5@hades \
--to=ilias.apalodimas@linaro.org \
--cc=etienne.carriere@linaro.org \
--cc=jens.wiklander@linaro.org \
--cc=patrick.delaunay@foss.st.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox