Skip to content

Commit b7ae9f0

Browse files
author
James Morris
committed
Merge branch 'tpmdd-04-17-13' of git://github.com/shpedoikal/linux into my-next
2 parents df2c2af + 32d33b2 commit b7ae9f0

6 files changed

Lines changed: 207 additions & 87 deletions

File tree

‎Documentation/devicetree/bindings/i2c/trivial-devices.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ fsl,mc13892 MC13892: Power Management Integrated Circuit (PMIC) for i.MX35/51
3535
fsl,mma8450 MMA8450Q: Xtrinsic Low-power, 3-axis Xtrinsic Accelerometer
3636
fsl,mpr121 MPR121: Proximity Capacitive Touch Sensor Controller
3737
fsl,sgtl5000 SGTL5000: Ultra Low-Power Audio Codec
38+
infineon,slb9635tt Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
39+
infineon,slb9645tt Infineon SLB9645 I2C TPM (new protocol, max 400khz)
3840
maxim,ds1050 5 Bit Programmable, Pulse-Width Modulator
3941
maxim,max1237 Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs
4042
maxim,max6625 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface

‎drivers/char/tpm/tpm.c‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ int tpm_pm_suspend(struct device *dev)
13371337
{
13381338
struct tpm_chip *chip = dev_get_drvdata(dev);
13391339
struct tpm_cmd_t cmd;
1340-
int rc;
1340+
int rc, try;
13411341

13421342
u8 dummy_hash[TPM_DIGEST_SIZE] = { 0 };
13431343

@@ -1355,9 +1355,32 @@ int tpm_pm_suspend(struct device *dev)
13551355
}
13561356

13571357
/* now do the actual savestate */
1358-
cmd.header.in = savestate_header;
1359-
rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE,
1360-
"sending savestate before suspend");
1358+
for (try = 0; try < TPM_RETRY; try++) {
1359+
cmd.header.in = savestate_header;
1360+
rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, NULL);
1361+
1362+
/*
1363+
* If the TPM indicates that it is too busy to respond to
1364+
* this command then retry before giving up. It can take
1365+
* several seconds for this TPM to be ready.
1366+
*
1367+
* This can happen if the TPM has already been sent the
1368+
* SaveState command before the driver has loaded. TCG 1.2
1369+
* specification states that any communication after SaveState
1370+
* may cause the TPM to invalidate previously saved state.
1371+
*/
1372+
if (rc != TPM_WARN_RETRY)
1373+
break;
1374+
msleep(TPM_TIMEOUT_RETRY);
1375+
}
1376+
1377+
if (rc)
1378+
dev_err(chip->dev,
1379+
"Error (%d) sending savestate before suspend\n", rc);
1380+
else if (try > 0)
1381+
dev_warn(chip->dev, "TPM savestate took %dms\n",
1382+
try * TPM_TIMEOUT_RETRY);
1383+
13611384
return rc;
13621385
}
13631386
EXPORT_SYMBOL_GPL(tpm_pm_suspend);

‎drivers/char/tpm/tpm.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ enum tpm_const {
3232
TPM_MINOR = 224, /* officially assigned */
3333
TPM_BUFSIZE = 4096,
3434
TPM_NUM_DEVICES = 256,
35+
TPM_RETRY = 50, /* 5 seconds */
3536
};
3637

3738
enum tpm_timeout {
3839
TPM_TIMEOUT = 5, /* msecs */
40+
TPM_TIMEOUT_RETRY = 100 /* msecs */
3941
};
4042

4143
/* TPM addresses */
@@ -44,6 +46,7 @@ enum tpm_addr {
4446
TPM_ADDR = 0x4E,
4547
};
4648

49+
#define TPM_WARN_RETRY 0x800
4750
#define TPM_WARN_DOING_SELFTEST 0x802
4851
#define TPM_ERR_DEACTIVATED 0x6
4952
#define TPM_ERR_DISABLED 0x7

0 commit comments

Comments
 (0)