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 00071ECAAD4 for ; Mon, 29 Aug 2022 06:34:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5DE2A83FFF; Mon, 29 Aug 2022 08:34:11 +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="bihtxNd9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7879C83F9A; Mon, 29 Aug 2022 08:34:09 +0200 (CEST) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (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 9E3BD83FFF for ; Mon, 29 Aug 2022 08:34: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-ed1-x534.google.com with SMTP id z2so8858897edc.1 for ; Sun, 28 Aug 2022 23:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=P5ShWM1YofKtJEh+ZD7P6274wnsF3u2opoPt/cKpMFg=; b=bihtxNd9rSGNQMCAv87T9ZGFlCon1CohaoVGt2CUsbX11K6VwPvbzK06sD4IGGW1fz sDDVT0yltxrrs8CvTZTAp+4xf4xDB8O3tKevWE4Gfo9H7fYQd9BkCyFVCRQGagCqyAGd iYqQVK/0j4F8H5szIop2HlSiQAzUXhI25KSSK9ZnYNczebO/tfPsYXELlYKXzW0QBO4O b9fb6uI4qt4D11hiRvN5PLwJIMpmirPVO4fFEn1ppjhMrQvVr8ssN+DScL6VUkxEWUQe J4kSkGf4UOs5JPl++NQksPetQHSYjlj4Re00aKGv3a3m9TKt0IcEMpsE6RYnlMCpOwQM TldA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=P5ShWM1YofKtJEh+ZD7P6274wnsF3u2opoPt/cKpMFg=; b=wVWT/v4LqKEwTbzILNss5NUiL1OA1Uwf9ypN5yxmIcLRjmqWtg/cZmFmOcYo0K9+LY Z7VP4cvoKusKD33HGSwrJHh/CpsBjRDXykk3hgCE85EugA5JRVeDfbKKbTPqr+OIPrlV 6uIVjuGUNLLA4mpGvnHbgXKQ7wpl75WbpJQDMbx9sbu58SnVnnTlwREEBepEOQnHTodL Vqo594F8+wN3lB1GZbcpJ6GiHNXpfKP7NLBrhB+aswj9R0iTfSe9K+i0mKDuHdqI+lRK AQe+eQ0sb4Gf3Bg1r0sqGyvf8sSv/0r67Ljm20i6gEYiiKAAqEG+2EXL8u9iPVypX9tc e9/g== X-Gm-Message-State: ACgBeo2FnR2hqMzFqHeHm7T65VU27vsCo52w8xcwAWSrEkePTO0o56N+ 1QrtUgflLRoU11fdy7Yt9N0wr7zSvKEf5Q== X-Google-Smtp-Source: AA6agR7l+4JdgKzCFDTS+mA4AHhOvFj+f/o1M5FIBtzOy6+Rxu12PPMkIQBfz6IKd0pSFA1ko8g0Aw== X-Received: by 2002:a05:6402:14e:b0:443:f58:17e9 with SMTP id s14-20020a056402014e00b004430f5817e9mr15640521edu.106.1661754846230; Sun, 28 Aug 2022 23:34:06 -0700 (PDT) Received: from hades.. ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id k7-20020a17090632c700b0073d218af237sm4087655ejk.216.2022.08.28.23.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 23:34:05 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: etienne.carriere@linaro.org, Ilias Apalodimas , Jens Wiklander , Patrick Delaunay Subject: [PATCH v2] tee: optee: rework TA bus scanning code Date: Mon, 29 Aug 2022 09:33:59 +0300 Message-Id: <20220829063400.421456-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 --- 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