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 B7B1FC38145 for ; Tue, 6 Sep 2022 21:23:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABF6F84A56; Tue, 6 Sep 2022 23:23:10 +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="qY/EXYGB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E831784A4A; Tue, 6 Sep 2022 23:23:08 +0200 (CEST) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (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 4DA1584A48 for ; Tue, 6 Sep 2022 23:23:06 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x336.google.com with SMTP id c131-20020a1c3589000000b003a84b160addso9725012wma.2 for ; Tue, 06 Sep 2022 14:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=S/V3WNp93gNlLB5vAb3Uaa3oOAbGrKNzexYRdoDJVdA=; b=qY/EXYGBOeQCEEffjwt2b7u+JMgXphw3p2SWwQvu87gI/g9VJpJ0qqXJeOtZhFBxRw Z+LpzUa/kO9PIhKGai2I/dDHu8uHp6J1zAsdxXFrbPB5/dWaRlfMAppRMiWm2q73sLgB pBqMvxy0qg/S14jMt6yCng/iCNfNOVKu9rkA8XkZ0xEomlGpYRfYLNg3hK6MjLp3rnxv yNeSa0RHzOYiBXbzNt7Waq8kA5DuuVQjYU4Gyc7I5ukbuvv2my49JhNMHqtFWk8v4kib 8Dea9KeDM4iHfa2MOVqIZxKLueKkzsWI2TbCgj7NSxBDr5lMTi0bhFaUQHBUq7o4eN7u G3SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=S/V3WNp93gNlLB5vAb3Uaa3oOAbGrKNzexYRdoDJVdA=; b=OeLK44NeQf4x4vq2d2BHoDlt8Yy0uPwfpW64GwZy5eI5IG/8d2/VZZV0/7gK074J7Z M8oYQPCALPWsLY+AWmJbhJ2XCubJ4Rzom+lpzaLz8uKJEkI6pbEShGuf4LiDkFxIlYx1 4PlcJrRji+x1G5eO9ofF1tbvy785EwMg3HA64zQ5CbsPL7TT/8sE3Zl3Tcl5dz2Ljxpo T/ugZSFJOMm5AQLcUYittS4SdeZmbIH7WqcVcHdCLY6DJT7heloKPhzHCCbp6TugYza2 C+s8USFFrP3o10vAyWxZrFWBJWqkdsvHIQ3TKpzxEeZ4yTtPhjZrwGppaZKyvtlqqhfW GQXQ== X-Gm-Message-State: ACgBeo2dmYW2yFgqiwxCd756bu54na9gTsu3CwAa3dBxuA4S/7Ju4Ebu d8uawaOopeyKC4wne/01RgNHQQ== X-Google-Smtp-Source: AA6agR6NmCwLdmRtCpkP1J9e+Hc5tqntYj3lOGqyFwWzK2d7YKHRRQehZQ57wBBphvcZ3d1QLZQH9Q== X-Received: by 2002:a7b:c7d8:0:b0:3a6:34d2:1705 with SMTP id z24-20020a7bc7d8000000b003a634d21705mr14745985wmk.206.1662499385746; Tue, 06 Sep 2022 14:23:05 -0700 (PDT) Received: from hades ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id h23-20020a05600c2cb700b003a2f2bb72d5sm28020215wmc.45.2022.09.06.14.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 14:23:05 -0700 (PDT) Date: Wed, 7 Sep 2022 00:23:03 +0300 From: Ilias Apalodimas To: Simon Glass Cc: U-Boot Mailing List , Etienne Carriere , Jens Wiklander , Patrick Delaunay Subject: Re: [PATCH v4] tee: optee: rework TA bus scanning code Message-ID: References: <20220906093703.35658-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Simon, On Tue, Sep 06, 2022 at 03:18:28PM -0600, Simon Glass wrote: > Hi, > > On Tue, 6 Sept 2022 at 03:37, 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 > > Reviewed-by: Etienne Carriere > > --- > > Changes since v3: > > - Use NULL instead of a child ptr on device_bind_driver(), since it's not > > really needed > > - Changed the style of the optee_bus_probe[] definition to > > {.drv_name = xxx, .dev_name = yyy } > > > > Changes since v2: > > - Fixed typo on driver name ftpm-tee -> ftpm_tee > > > > Changes since v1: > > - remove a macro and use ARRAY_SIZE directly > > drivers/tee/optee/core.c | 24 +++++++++++++++++++----- > > 1 file changed, 19 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c > > index a89d62aaf0b3..c201a4635e6b 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 > > + { .drv_name = "optee-rng", .dev_name = "optee-rng" }, > > +#endif > > +#ifdef CONFIG_TPM2_FTPM_TEE > > + { .drv_name = "ftpm_tee", .dev_name = "ftpm_tee" }, > > +#endif > > +}; > > + > > struct rpc_param { > > u32 a0; > > u32 a1; > > @@ -642,8 +654,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 +683,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, NULL); > > if (ret) > > - return ret; > > + dev_warn(dev, "Failed to bind device %s\n", > > + optee_bus_probe[i].dev_name); > > Please add device tree nodes for these and all this code can go away. That's the exact opposite of what the commit message describes. OP-TEE supports a scannable bus ifor TAs that behave like hardware blocks and doesn't need a DT entry. Since it's really the TAs compilation decision to support that or not having them as a DT node is not always the right choice. Thanks /Ilias > > Regards, > Simon