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 7E8DAECAAD8 for ; Wed, 31 Aug 2022 05:59:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6CF79845F3; Wed, 31 Aug 2022 07:59:20 +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="rb4RuZ/B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7CBE3849BA; Wed, 31 Aug 2022 07:59:18 +0200 (CEST) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (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 BEFD380019 for ; Wed, 31 Aug 2022 07:59:15 +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=jens.wiklander@linaro.org Received: by mail-pl1-x631.google.com with SMTP id v5so6989900plo.9 for ; Tue, 30 Aug 2022 22:59:15 -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; bh=/Mx5VuqGzETHbwDMDzCG/ErhRGG3PskYDzYvIRDnnR4=; b=rb4RuZ/BMjJgt0fCg5NPu99mFGoiThZy1AdpndvKWLCKdNh4o+hP+xyqvug2VEFzg3 NAo/VZ/7Uz3ASa2B5ocRZYkyjpd77B0jcOqSkKsurjvjIkl89LUM4UUYgtoez7vklW/j P3KqoeGtOpbezvYzvyLJkdd39YhAj5bxAQA4o/eM3makNr5Bc76ZwNm1uBcpV7sXVTHz wc50ZIkLAnj2Mg5yLChzlJCzmLYWlujn7xYri9unGi3kIdOee06UZ1wna+tTSHz0fmYq 6Ncf+UNJRz7w0qL6+utdv18YDWLSfZRyMVIdA0Ktj7gMiMqhPAbX8aq+LKZ966q39WFh ghow== 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; bh=/Mx5VuqGzETHbwDMDzCG/ErhRGG3PskYDzYvIRDnnR4=; b=6HbTrlRWWRvu5XTss7rXy9UEYgr7e7COmWoSwcTj5kBtppj8KadTnx/tF4/yEZ6QRa 2sW6jy83hf/wWkQza5q3RVefEDV1vGU/bCTO2zXCrXNo+W765XnUiRSuiCYndyi42vza 8IuBq+hJ8+EiGonH42EkvBG15/2tU20sFHHRL+dErEVsT00plm6NzqWGBkXrM4BXJJeR kmrn0azXWykeYO2LWhfRK9ekHw3SwqJRpf1Gf/BTlTCdMYO15uZxgjACwkAvPqqwpZTO e9YrbghEfTVMP0V8Or4lw79aQWooPy9Qg1sd1EiAdBqNpN5lBuC8tSfwGGqMZ4XPCUoF Hqag== X-Gm-Message-State: ACgBeo0GPoz7H+ehqognT0JRYOAjd+vdp8/QmMvYp8941hQjtjIW/7U4 5JGIuSP2LPDUrqljNFjvbPQZmBZ60jb0dqIaeLuXqg== X-Google-Smtp-Source: AA6agR4/zWKTraevHKsNdOygRpMZicW9VDf+a643WgHqPfqYrt6RJlkThmopTHSlcdrP38FZYOy7RnoTn9KRuDGhnsU= X-Received: by 2002:a17:902:f684:b0:172:d54d:6f9e with SMTP id l4-20020a170902f68400b00172d54d6f9emr24477538plg.174.1661925553867; Tue, 30 Aug 2022 22:59:13 -0700 (PDT) MIME-Version: 1.0 References: <20220829063400.421456-1-ilias.apalodimas@linaro.org> In-Reply-To: <20220829063400.421456-1-ilias.apalodimas@linaro.org> From: Jens Wiklander Date: Wed, 31 Aug 2022 07:59:02 +0200 Message-ID: Subject: Re: [PATCH v2] tee: optee: rework TA bus scanning code To: Ilias Apalodimas Cc: u-boot@lists.denx.de, etienne.carriere@linaro.org, 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 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 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" }, > +#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); > if (ret) > - return ret; > + dev_warn(dev, "Failed to bind device %s\n", > + optee_bus_probe[i].dev_name); > } > > return 0; > -- > 2.34.1 >