Commit 3c032814 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Sasha Levin

tpm: Provide a generic means to override the chip returned timeouts

Some Atmel TPMs provide completely wrong timeouts from their
TPM_CAP_PROP_TIS_TIMEOUT query. This patch detects that and returns
new correct values via a DID/VID table in the TIS driver.

Tested on ARM using an AT97SC3204T FW version 37.16

Cc: <stable@vger.kernel.org>
[PHuewe: without this fix these 'broken' Atmel TPMs won't function on
older kernels]
Signed-off-by: default avatar"Berg, Christopher" <Christopher.Berg@atmel.com>
Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: default avatarPeter Huewe <peterhuewe@gmx.de>

(cherry picked from commit 8e54caf4)
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 4589263b
...@@ -577,6 +577,32 @@ int tpm_get_timeouts(struct tpm_chip *chip) ...@@ -577,6 +577,32 @@ int tpm_get_timeouts(struct tpm_chip *chip)
} }
} }
old_timeout[0] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.a);
old_timeout[1] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.b);
old_timeout[2] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.c);
old_timeout[3] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.d);
memcpy(new_timeout, old_timeout, sizeof(new_timeout));
/*
* Provide ability for vendor overrides of timeout values in case
* of misreporting.
*/
if (chip->vendor.update_timeouts != NULL)
chip->vendor.timeout_adjusted =
chip->vendor.update_timeouts(chip, new_timeout);
if (!chip->vendor.timeout_adjusted) {
/* Don't overwrite default if value is 0 */
if (new_timeout[0] != 0 && new_timeout[0] < 1000) {
int i;
/* timeouts in msec rather usec */
for (i = 0; i != ARRAY_SIZE(new_timeout); i++)
new_timeout[i] *= 1000;
chip->vendor.timeout_adjusted = true;
}
}
/* Report adjusted timeouts */ /* Report adjusted timeouts */
if (chip->vendor.timeout_adjusted) { if (chip->vendor.timeout_adjusted) {
dev_info(chip->dev, dev_info(chip->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment