From patchwork Wed May 10 07:43:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 680513 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2697522wrs; Wed, 10 May 2023 00:46:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42BAtzemflpahthHifvKDSCLdql3z8k9b+tHKUD5va2b2UPFJ6vJSIYP9PgEBKh1cf7N/G X-Received: by 2002:a17:90b:3b8b:b0:252:7114:b37a with SMTP id pc11-20020a17090b3b8b00b002527114b37amr208014pjb.47.1683704770517; Wed, 10 May 2023 00:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683704770; cv=none; d=google.com; s=arc-20160816; b=MbRln0/bJFv4YlY/77MOCLG6ePuotDtM8tePRM6GJHV/ZjNBVMqg2z62ZDNnDKebT9 Bbxcq13SRwTl6yz2Xs6dGa9h0psHj5STsh1AvTenAFeU+5I7fydmlB1wNVisS9BRIve8 1jNe2v71xCLxLaxIzs9czgsdxiO1rUlnq3THrvGo4ZdViJUUUrIlnE1V0QAS6WMAuskl VfRZv6aumi2fjeHzmsI7BgIPOqfHdrjeH2x57CybJEfLGwaHtIFVTNIeaUwV+LIm0egx 8JwZUn2NMMoyJmGBTyHlR5xTq1wvdQJer5vxvVtcjO/sapGwO03lxYTA5XB5yLpnmFVM Sl2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ULpKd4H7HpwPG50zCreAsLpCihJiqLcHXj/HctRxXOk=; b=mrUTMsHeOBsm7FJE59pjzexV85uJoQVFPqbX9/46ic64FBpBXdA06/UYfVy3e7dnxh i/GFntogM7Jw0lHcM3omCiTbRQ08hvSkShc7vHE5Wu52HZvqK/erUyvSvEq2eFbVST4U TNzpKV0B+XulLG7tfQ5o3M6GtoAWEwrUTOBfbB+TYlvBNC/Rai/S9QUEVtG0JuJC7qYA 2fWIWHoOVNws88J/23vavRRmYEcfqH8zsF2YiprlrcUh8uV/6QaG4Uv6vxMUti+JdLDM TgTq+zGBmRrAJSdQRDrtFD6bEQ2P1CmX5mOz7KQQbo0QLv+qGYIoW8gNIZIXJv2iW6JV nf4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W9I7rOAN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id o10-20020a17090a3d4a00b002448f1b24d5si16933867pjf.139.2023.05.10.00.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 00:46:10 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W9I7rOAN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CCE386072; Wed, 10 May 2023 09:44:51 +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="W9I7rOAN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D999F860A4; Wed, 10 May 2023 09:44:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 96E8A86075 for ; Wed, 10 May 2023 09:44:46 +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-x32d.google.com with SMTP id 5b1f17b1804b1-3f475366514so3198895e9.2 for ; Wed, 10 May 2023 00:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683704686; x=1686296686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ULpKd4H7HpwPG50zCreAsLpCihJiqLcHXj/HctRxXOk=; b=W9I7rOANENYf6rjl3rMP1+p2zLvgVKD/afgfGqkqcE/TxHEMhX0iTnCDnSQZb6Xc14 4uOax04kbbCH5hiVxgHq/az+uekw4C79gwlcz8YFR+h948rNwVUItayzjJLQ+6oc/wVq waaD87nJcLIT104SL1jxs8f8Xtl2Bmz8r62yi/mPIqlcmBB7llYyEZLLwrSc/JpkgVW4 8KMN5z+TQ/XGw7pi7eeF2sJgLI5tyMjBdj6ppbtZ5jZKIUYKwnzD00E3ho0Njq6t7fO9 bnpWEkQTr3FK3lJ3eM0I+9XoMWD1lRFv2tfociKn5qmVOldtiDyySGjrEXAVFTnIuZon nKBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683704686; x=1686296686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ULpKd4H7HpwPG50zCreAsLpCihJiqLcHXj/HctRxXOk=; b=E7d1RrLzTXxoaKgGVRwwkVcuyxysymfhmZSu546NH3Vd78Oa1j8aGqUvHPaRNQqeBp l/t7CTe+Ub5jDwY5pB3Rh5wM0UWj0a9TT1dnYOQs8k+Ct6kqcQzxBArsk6bgxdNvPmcY owQCC184Yi9bc2pc5BeR3wtMy+EPd0vOkukToOzyhZHVSP4vZg5k6m94vKf+tGkZSohn /uvaqT49tJANXhJC3pejqC86IpS5fP3nU1oy5V8jmGl8qKqvjqD73a1GXp2XOjdUyuov CIxQq5joKSywQO/c8uC2BwRT/UQxsIOOKmVV7rp3UNq0hnKbUu5AMXO+U38/PYC8DWxc XUgg== X-Gm-Message-State: AC+VfDzo6BILYdUIriFIABhkan9fUiJassQ0ZEjTQPv0R2kY+AVQXG9Y HwUC5U/HDC1bPKnExuBIU/Dg6/NxHVldHPZJol0abQ== X-Received: by 2002:a1c:f711:0:b0:3ee:775:c573 with SMTP id v17-20020a1cf711000000b003ee0775c573mr10930727wmh.20.1683704686101; Wed, 10 May 2023 00:44:46 -0700 (PDT) Received: from localhost.localdomain (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id p20-20020a1c7414000000b003f435652aaesm2022446wmc.11.2023.05.10.00.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 00:44:45 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Eddie James , Michal Suchanek , Rasmus Villemoes , Dzmitry Sankouski , Robert Marko , Sean Anderson , Nikhil M Jain , Abdellatif El Khlifi , Andrew Davis , Daniel Golle , Safae Ouajih , Mattijs Korpershoek , =?utf-8?q?Pali_Roh=C3=A1r?= , Sughosh Ganu , Roger Knecht , Steven Lawrance , Linus Walleij , Rui Miguel Silva , Stephen Carlson , Marek Vasut , Kautuk Consul , Leo Yu-Chi Liang , Brandon Maier , Patrick Delaunay Subject: [PATCH 9/9] tpm: Make 'tpm init' to call tpm_auto_start() Date: Wed, 10 May 2023 10:43:57 +0300 Message-Id: <20230510074359.2837818-9-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230510074359.2837818-1-ilias.apalodimas@linaro.org> References: <20230510074359.2837818-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean For a TPM device to be operational we need to initialize it and perform its startup sequence. The 'tpm init' command currently calls tpm_init() which ends up calling the ->open() per-device callback and performs the initial hardware configuration as well as requesting locality 0 for the caller. We recently added tpm_auto_start() though, which automates the initialization process -- On top of that calling tpm_init() on selftests is a bit problematic, since calling it twice will return -EBUSY the second time although there is no actual problem with the TPM or the software stack. So let's wire up the 'tpm init' command and call tpm_auto_start() which leaves the device in an operational state. It's worth noting that calling tpm_init() only, doesn't allow a someone to use the TPM since the startup sequence is mandatory. We keep repeating the pattern of calling - tpm_init - tpm_startup - tpm_self_test_full or tpm_continue_self_test So we don't expect any regression or boot delays with the current change. While at it fix the identation of test_tpm_autostart() comments as well Signed-off-by: Ilias Apalodimas --- cmd/tpm-common.c | 3 ++- test/dm/tpm.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c index d0c63cadf413..9b1ad0b371df 100644 --- a/cmd/tpm-common.c +++ b/cmd/tpm-common.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "tpm-user-utils.h" static struct udevice *tpm_dev; @@ -364,7 +365,7 @@ int do_tpm_init(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (rc) return rc; - return report_return_code(tpm_init(dev)); + return report_return_code(tpm_auto_start(dev)); } int do_tpm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) diff --git a/test/dm/tpm.c b/test/dm/tpm.c index 3defb3c3da1f..cde933ab2848 100644 --- a/test/dm/tpm.c +++ b/test/dm/tpm.c @@ -98,10 +98,11 @@ static int test_tpm_autostart(struct unit_test_state *uts, if (reinit) ut_assertok(tpm_init(dev)); - /* - * tpm_auto_start will rerun tpm_init() if reinit, but handles the - * -EBUSY return code internally. - */ + + /* + * tpm_auto_start will rerun tpm_init() if reinit, but handles the + * -EBUSY return code internally. + */ ut_assertok(tpm_auto_start(dev)); return 0;