Raul Rangel has submitted this change. ( https://review.coreboot.org/c/coreboot/+/77491?usp=email )
(
33 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: drivers/tpm: Add return codes to TPM driver ......................................................................
drivers/tpm: Add return codes to TPM driver
Add additional failure mode reporting to the TPM driver to provide additional visibility into what failures are occurring.
BUG=b:296439237 TEST=Verify code paths on Skyrim, ensure behavior is unchanged. BRANCH=None
Change-Id: I77a653201acf1bddc1ed1e2af701c8d3dd4f0606 Signed-off-by: Jon Murphy jpmurphy@google.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/77491 Reviewed-by: Eric Lai eric_lai@quanta.corp-partner.google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Jan Samek jan.samek@siemens.com --- M src/drivers/i2c/tpm/cr50.c M src/drivers/i2c/tpm/tpm.c 2 files changed, 10 insertions(+), 10 deletions(-)
Approvals: Eric Lai: Looks good to me, approved build bot (Jenkins): Verified Jan Samek: Looks good to me, approved
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index d207f2b..3351ca2 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -61,7 +61,7 @@ static tpm_result_t cr50_i2c_read(uint8_t addr, uint8_t *buffer, size_t len) { if (tpm_dev.addr == 0) - return TPM_CB_FAIL; + return TPM_CB_INVALID_ARG;
/* Clear interrupt before starting transaction */ cr50_plat_irq_status(); @@ -69,17 +69,17 @@ /* Send the register address byte to the TPM */ if (i2c_write_raw(tpm_dev.bus, tpm_dev.addr, &addr, 1)) { printk(BIOS_ERR, "%s: Address write failed\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_COMMUNICATION_ERROR; }
/* Wait for TPM to be ready with response data */ if (cr50_wait_tpm_ready() != CB_SUCCESS) - return TPM_CB_FAIL; + return TPM_CB_TIMEOUT;
/* Read response data from the TPM */ if (i2c_read_raw(tpm_dev.bus, tpm_dev.addr, buffer, len)) { printk(BIOS_ERR, "%s: Read response failed\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_COMMUNICATION_ERROR; }
return TPM_SUCCESS; @@ -115,11 +115,11 @@ /* Send write request buffer with address */ if (i2c_write_raw(tpm_dev.bus, tpm_dev.addr, tpm_dev.buf, len + 1)) { printk(BIOS_ERR, "%s: Error writing to TPM\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_COMMUNICATION_ERROR; }
/* Wait for TPM to be ready */ - return cr50_wait_tpm_ready() == CB_SUCCESS ? TPM_SUCCESS : TPM_CB_FAIL; + return cr50_wait_tpm_ready() == CB_SUCCESS ? TPM_SUCCESS : TPM_CB_TIMEOUT; }
/* @@ -276,7 +276,7 @@ printk(BIOS_ERR, "%s: Timeout reading burst and status with error %#x\n", __func__, rc); if (rc) return rc; - return TPM_CB_TIMEOUT; + return TPM_CB_COMMUNICATION_ERROR; }
static int cr50_i2c_tis_recv(uint8_t *buf, size_t buf_len) @@ -464,7 +464,7 @@ printk(BIOS_ERR, "DID_VID 0x%08x not recognized\n", *did_vid); return TPM_CB_FAIL; } - return rc; + return TPM_CB_COMMUNICATION_ERROR; }
tpm_result_t tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr) @@ -474,7 +474,7 @@
if (dev_addr == 0) { printk(BIOS_ERR, "%s: missing device address\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_INVALID_ARG; }
tpm_dev.bus = bus; diff --git a/src/drivers/i2c/tpm/tpm.c b/src/drivers/i2c/tpm/tpm.c index 4dbefb4..91c310b 100644 --- a/src/drivers/i2c/tpm/tpm.c +++ b/src/drivers/i2c/tpm/tpm.c @@ -498,7 +498,7 @@
if (dev_addr == 0) { printk(BIOS_ERR, "%s: missing device address\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_INVALID_ARG; }
tpm_dev.chip_type = UNKNOWN;