Skip to content

Commit 1398aa8

Browse files
committed
tpm_tis: Use tpm_chip_{start,stop} decoration inside tpm_tis_resume
Before sending a TPM command, CLKRUN protocol must be disabled. This is not done in the case of tpm1_do_selftest() call site inside tpm_tis_resume(). Address this by decorating the calls with tpm_chip_{start,stop}, which should be always used to arm and disarm the TPM chip for transmission. Finally, move the call to the main TPM driver callback as the last step because it should arm the chip by itself, if it needs that type of functionality. Cc: [email protected] Reported-by: Jason A. Donenfeld <[email protected]> Closes: https://lore.kernel.org/linux-integrity/CS68AWILHXS4.3M36M1EKZLUMS@suppilovahvero/ Fixes: a3fbfae ("tpm: take TPM chip power gating out of tpm_transmit()") Reviewed-by: Jerry Snitselaar <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent f1fcbaa commit 1398aa8

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,53 +1209,48 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
12091209
u32 intmask;
12101210
int rc;
12111211

1212-
if (chip->ops->clk_enable != NULL)
1213-
chip->ops->clk_enable(chip, true);
1214-
1215-
/* reenable interrupts that device may have lost or
1216-
* BIOS/firmware may have disabled
1212+
/*
1213+
* Re-enable interrupts that device may have lost or BIOS/firmware may
1214+
* have disabled.
12171215
*/
12181216
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), priv->irq);
1219-
if (rc < 0)
1220-
goto out;
1217+
if (rc < 0) {
1218+
dev_err(&chip->dev, "Setting IRQ failed.\n");
1219+
return;
1220+
}
12211221

12221222
intmask = priv->int_mask | TPM_GLOBAL_INT_ENABLE;
1223-
1224-
tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
1225-
1226-
out:
1227-
if (chip->ops->clk_enable != NULL)
1228-
chip->ops->clk_enable(chip, false);
1229-
1230-
return;
1223+
rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
1224+
if (rc < 0)
1225+
dev_err(&chip->dev, "Enabling interrupts failed.\n");
12311226
}
12321227

12331228
int tpm_tis_resume(struct device *dev)
12341229
{
12351230
struct tpm_chip *chip = dev_get_drvdata(dev);
12361231
int ret;
12371232

1238-
ret = tpm_tis_request_locality(chip, 0);
1239-
if (ret < 0)
1233+
ret = tpm_chip_start(chip);
1234+
if (ret)
12401235
return ret;
12411236

12421237
if (chip->flags & TPM_CHIP_FLAG_IRQ)
12431238
tpm_tis_reenable_interrupts(chip);
12441239

1245-
ret = tpm_pm_resume(dev);
1246-
if (ret)
1247-
goto out;
1248-
12491240
/*
12501241
* TPM 1.2 requires self-test on resume. This function actually returns
12511242
* an error code but for unknown reason it isn't handled.
12521243
*/
12531244
if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
12541245
tpm1_do_selftest(chip);
1255-
out:
1256-
tpm_tis_relinquish_locality(chip, 0);
12571246

1258-
return ret;
1247+
tpm_chip_stop(chip);
1248+
1249+
ret = tpm_pm_resume(dev);
1250+
if (ret)
1251+
return ret;
1252+
1253+
return 0;
12591254
}
12601255
EXPORT_SYMBOL_GPL(tpm_tis_resume);
12611256
#endif

0 commit comments

Comments
 (0)