summaryrefslogtreecommitdiff
path: root/src/drivers/i2c/tpm
diff options
context:
space:
mode:
authorRichard Spiegel <richard.spiegel@amd.corp-partner.google.com>2018-08-09 14:41:17 -0700
committerMartin Roth <martinroth@google.com>2018-08-14 21:51:58 +0000
commit7c1e959ff6cfe2280e9a2e9c635936768b661cd7 (patch)
tree7bedfac483d306bec2ae2fdfeb1307fb2562d476 /src/drivers/i2c/tpm
parenta5ac91c2565ee2fd588c0dbcb48694d12340a3fc (diff)
downloadcoreboot-7c1e959ff6cfe2280e9a2e9c635936768b661cd7.tar.xz
drivers/i2c/tpm/cr50.c: Check if TPM was read
Under some conditions, cr50_i2c_read() can return without actually reading the TPM, which will leave access uninitialized. Set an initial value for access, and if TPM fails to respond in time check if at least TPM was read. This way avoids printing an uninitialized value. BUG=b:112253891 TEST=Build and boot grunt. Change-Id: I5ec7a99396db32971dc8485b77158d735ab1d788 Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Reviewed-on: https://review.coreboot.org/27995 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Diffstat (limited to 'src/drivers/i2c/tpm')
-rw-r--r--src/drivers/i2c/tpm/cr50.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c
index 3c2f5bd198..14a84de96f 100644
--- a/src/drivers/i2c/tpm/cr50.c
+++ b/src/drivers/i2c/tpm/cr50.c
@@ -181,6 +181,7 @@ static int cr50_i2c_write(struct tpm_chip *chip,
static int process_reset(struct tpm_chip *chip)
{
struct stopwatch sw;
+ int rv = 0;
uint8_t access;
/*
@@ -193,7 +194,6 @@ static int process_reset(struct tpm_chip *chip)
*/
stopwatch_init_msecs_expire(&sw, CR50_TIMEOUT_INIT_MS);
do {
- int rv;
const uint8_t mask =
TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY;
@@ -214,9 +214,12 @@ static int process_reset(struct tpm_chip *chip)
return 0;
} while (!stopwatch_expired(&sw));
- printk(BIOS_ERR,
- "TPM failed to reset after %ld ms, status: %#x\n",
- stopwatch_duration_msecs(&sw), access);
+ if (rv)
+ printk(BIOS_ERR, "Failed to read TPM\n");
+ else
+ printk(BIOS_ERR,
+ "TPM failed to reset after %ld ms, status: %#x\n",
+ stopwatch_duration_msecs(&sw), access);
return -1;
}