[PATCH 9/9] tpm: Make 'tpm init' to call tpm_auto_start()
Ilias Apalodimas
ilias.apalodimas at linaro.org
Wed May 10 09:43:57 CEST 2023
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 <ilias.apalodimas at linaro.org>
---
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 <asm/unaligned.h>
#include <linux/string.h>
#include <tpm-common.h>
+#include <tpm_api.h>
#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;
--
2.39.2
More information about the U-Boot
mailing list