mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
tpm: tis_i2c: Limit read bursts to I2C_SMBUS_BLOCK_MAX (32) bytes
Underlying I2C bus drivers not always support longer transfers and
imx-lpi2c for instance doesn't. SLB 9673 offers 427-bytes packets.
Visible symptoms are:
tpm tpm0: Error left over data
tpm tpm0: tpm_transmit: tpm_recv: error -5
tpm_tis_i2c: probe of 1-002e failed with error -5
Cc: stable@vger.kernel.org # v5.20+
Fixes: bbc23a07b0
("tpm: Add tpm_tis_i2c backend for tpm_tis_core")
Tested-by: Michael Haener <michael.haener@siemens.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This commit is contained in:
parent
f0afba4042
commit
f3b70b6e33
@ -189,21 +189,28 @@ static int tpm_tis_i2c_read_bytes(struct tpm_tis_data *data, u32 addr, u16 len,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for (i = 0; i < TPM_RETRY; i++) {
|
for (i = 0; i < TPM_RETRY; i++) {
|
||||||
/* write register */
|
u16 read = 0;
|
||||||
msg.len = sizeof(reg);
|
|
||||||
msg.buf = ®
|
|
||||||
msg.flags = 0;
|
|
||||||
ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* read data */
|
while (read < len) {
|
||||||
msg.buf = result;
|
/* write register */
|
||||||
msg.len = len;
|
msg.len = sizeof(reg);
|
||||||
msg.flags = I2C_M_RD;
|
msg.buf = ®
|
||||||
ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg);
|
msg.flags = 0;
|
||||||
if (ret < 0)
|
ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg);
|
||||||
return ret;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* read data */
|
||||||
|
msg.buf = result + read;
|
||||||
|
msg.len = len - read;
|
||||||
|
msg.flags = I2C_M_RD;
|
||||||
|
if (msg.len > I2C_SMBUS_BLOCK_MAX)
|
||||||
|
msg.len = I2C_SMBUS_BLOCK_MAX;
|
||||||
|
ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
read += msg.len;
|
||||||
|
}
|
||||||
|
|
||||||
ret = tpm_tis_i2c_sanity_check_read(reg, len, result);
|
ret = tpm_tis_i2c_sanity_check_read(reg, len, result);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user