Skip to content

Commit 1c183c9

Browse files
committed
tpm_tis: Use tpm_chip_{start,stop} decoration inside tpm_tis_resume
JIRA: https://issues.redhat.com/browse/RHEL-72765 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 1398aa8 Author: Jarkko Sakkinen <jarkko@kernel.org> Date: Wed Apr 26 20:29:27 2023 +0300 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: stable@vger.kernel.org Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> 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 <jsnitsel@redhat.com> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
1 parent 2020ee7 commit 1c183c9

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
@@ -1186,53 +1186,48 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
11861186
u32 intmask;
11871187
int rc;
11881188

1189-
if (chip->ops->clk_enable != NULL)
1190-
chip->ops->clk_enable(chip, true);
1191-
1192-
/* reenable interrupts that device may have lost or
1193-
* BIOS/firmware may have disabled
1189+
/*
1190+
* Re-enable interrupts that device may have lost or BIOS/firmware may
1191+
* have disabled.
11941192
*/
11951193
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), priv->irq);
1196-
if (rc < 0)
1197-
goto out;
1194+
if (rc < 0) {
1195+
dev_err(&chip->dev, "Setting IRQ failed.\n");
1196+
return;
1197+
}
11981198

11991199
intmask = priv->int_mask | TPM_GLOBAL_INT_ENABLE;
1200-
1201-
tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
1202-
1203-
out:
1204-
if (chip->ops->clk_enable != NULL)
1205-
chip->ops->clk_enable(chip, false);
1206-
1207-
return;
1200+
rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
1201+
if (rc < 0)
1202+
dev_err(&chip->dev, "Enabling interrupts failed.\n");
12081203
}
12091204

12101205
int tpm_tis_resume(struct device *dev)
12111206
{
12121207
struct tpm_chip *chip = dev_get_drvdata(dev);
12131208
int ret;
12141209

1215-
ret = tpm_tis_request_locality(chip, 0);
1216-
if (ret < 0)
1210+
ret = tpm_chip_start(chip);
1211+
if (ret)
12171212
return ret;
12181213

12191214
if (chip->flags & TPM_CHIP_FLAG_IRQ)
12201215
tpm_tis_reenable_interrupts(chip);
12211216

1222-
ret = tpm_pm_resume(dev);
1223-
if (ret)
1224-
goto out;
1225-
12261217
/*
12271218
* TPM 1.2 requires self-test on resume. This function actually returns
12281219
* an error code but for unknown reason it isn't handled.
12291220
*/
12301221
if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
12311222
tpm1_do_selftest(chip);
1232-
out:
1233-
tpm_tis_relinquish_locality(chip, 0);
12341223

1235-
return ret;
1224+
tpm_chip_stop(chip);
1225+
1226+
ret = tpm_pm_resume(dev);
1227+
if (ret)
1228+
return ret;
1229+
1230+
return 0;
12361231
}
12371232
EXPORT_SYMBOL_GPL(tpm_tis_resume);
12381233
#endif

0 commit comments

Comments
 (0)