From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9492AECAAD5 for ; Mon, 5 Sep 2022 09:24:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9390380F60; Mon, 5 Sep 2022 11:24:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="q8sLCRws"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A179184595; Mon, 5 Sep 2022 11:23:58 +0200 (CEST) Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ADE1A80517 for ; Mon, 5 Sep 2022 11:23:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-1272fc7f51aso6813220fac.12 for ; Mon, 05 Sep 2022 02:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=Hwx0NVt3lux+9QN5BuaF6wm+L44DZukc4iTWgnK3Drs=; b=q8sLCRwsHRBN4ye+O/00KXH90ok4Kttz7fpeCunXaE1pIzChsJuCRO0DezmRNd2niZ qNXBXU8nVekWMMjIRsjEcl52//XKJVoGuyI/XVT1PNBltIYnhjJPgaecZV++st/+RTpX jDf+xMPTXPC/h72BFM9DPhFJDsUQpPimKBlwuCxVRlHquIbF9eYSC3QMTmE1Yj7/K6yU SwreJgW4PCMwSv3R1ijmZVfKdJix48aVAVKUA2RCpnHzFMdo49XcEEipmpmILxgnRKMC ew8V+ka6WV6142HrhIzeIyONv6U+H6TSmggNZlRii1idZF3lb7I32286V/WMF0XwGne3 2t0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=Hwx0NVt3lux+9QN5BuaF6wm+L44DZukc4iTWgnK3Drs=; b=ixvjOzBDL3sKaX+v3WcV1Nf2UvA5diVAbgr66K6ZJCNH59tFf/QvhfhESUOpudCx0b UFgOj9vGYNrv42JLsyP7dHki4TFML6GE3XbWfxpgmc/0dQioDwLBTxtZE9tfGGQsUXhi HTK4eeEat//5QZ89aM/8C+64wE9PEKXHDUsBTX+BRDutC1/nY0mOt23edlVrmNkMlWBk ttb2Ie/teZ0QWbf/+s9WFLzlfhR6lO5s+qpQkccZ7yCClZt74/S5IXoiArqsQ8mJ+5HM SAppI0JB97O97SAbt2RnGkLdhuSxNbC3TJMfwwyQCmuG85Qy7fs1HfBkAVS1tzxsiHJR J8fg== X-Gm-Message-State: ACgBeo14w1TRDgVPAkSJiPuZ7CNYg+JmmWcesHS73gPrSennjbetsId0 3K3XDGCBD/pW2QpLjhx6NyX6snNEhZxAj94XCtm67beNQ+CE04TO X-Google-Smtp-Source: AA6agR7/UKegadVz/Wz31hb3fBGTKPPNrWAmLcqTBrbzgjlOLslvHDC8zdM0uM+fsruAz1j656ZEDA5f0iMVXh4J6fI= X-Received: by 2002:a05:6808:1483:b0:344:ac63:b87a with SMTP id e3-20020a056808148300b00344ac63b87amr7376555oiw.104.1662369834180; Mon, 05 Sep 2022 02:23:54 -0700 (PDT) MIME-Version: 1.0 References: <20220829063400.421456-1-ilias.apalodimas@linaro.org> In-Reply-To: From: Etienne Carriere Date: Mon, 5 Sep 2022 11:23:43 +0200 Message-ID: Subject: Re: [PATCH v2] tee: optee: rework TA bus scanning code To: Ilias Apalodimas Cc: Jens Wiklander , u-boot@lists.denx.de, Patrick Delaunay Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi Ilias, Reviewed-by: Etienne Carriere with minor comments. On Fri, 2 Sept 2022 at 21:11, Ilias Apalodimas wrote: > > Thanks Jens > > On Wed, 31 Aug 2022 at 08:59, Jens Wiklander wrote: > > > > On Mon, Aug 29, 2022 at 8:34 AM Ilias Apalodimas > > 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 > > > --- > > > > Reviewed-by: Jens Wiklander > > There's a typo in that patch. For the tpm to work the string needs to > be ftpm_tee instead of ftpm-tee. I'll send a v3, shall I keep your > RB? > > Cheers > /Ilias > > > > Cheers, > > Jens > > > > > 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..3cc92f09d299 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" }, By the way, 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); Can drop child here. NULL is fine. > > > if (ret) > > > - return ret; > > > + dev_warn(dev, "Failed to bind device %s\n", > > > + optee_bus_probe[i].dev_name); > > > } > > > > > > return 0; > > > -- > > > 2.34.1 > > >