aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm-interface.c
diff options
context:
space:
mode:
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2018-11-05 02:07:56 +0200
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2019-02-13 09:48:40 +0200
commita3fbfae82b4cb3ff9928e29f34c64d0507cad874 (patch)
treeebe97b36432fb956646a9a039fc7a3fdeae456ad /drivers/char/tpm/tpm-interface.c
parenttpm: introduce tpm_chip_start() and tpm_chip_stop() (diff)
downloadlinux-dev-a3fbfae82b4cb3ff9928e29f34c64d0507cad874.tar.xz
linux-dev-a3fbfae82b4cb3ff9928e29f34c64d0507cad874.zip
tpm: take TPM chip power gating out of tpm_transmit()
Call tpm_chip_start() and tpm_chip_stop() in * tpm_chip_register() * tpm_class_shutdown() * tpm_del_char_device() * tpm_pm_suspend() * tpm_try_get_ops() and tpm_put_ops() * tpm2_del_space() And remove these calls from tpm_transmit(). The core reason for this change is that in tpm_vtpm_proxy a locality change requires a virtual TPM command (a command made up just for that driver). The consequence of this is that this commit removes the remaining nested calls. Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Tested-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: James Bottomley <James.Bottomley@HansenPartnership.com> Tested-by: Alexander Steffen <Alexander.Steffen@infineon.com>
Diffstat (limited to 'drivers/char/tpm/tpm-interface.c')
-rw-r--r--drivers/char/tpm/tpm-interface.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 038a4767d9d6..744f1b96128e 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -177,13 +177,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
memcpy(save, buf, save_size);
for (;;) {
- ret = tpm_chip_start(chip, flags);
- if (ret)
- return ret;
-
ret = tpm_try_transmit(chip, buf, bufsiz, flags);
-
- tpm_chip_stop(chip, flags);
if (ret < 0)
break;
rc = be32_to_cpu(header->return_code);
@@ -420,10 +414,16 @@ int tpm_pm_suspend(struct device *dev)
if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
return 0;
- if (chip->flags & TPM_CHIP_FLAG_TPM2)
- tpm2_shutdown(chip, TPM2_SU_STATE);
- else
+ if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+ mutex_lock(&chip->tpm_mutex);
+ if (!tpm_chip_start(chip, 0)) {
+ tpm2_shutdown(chip, TPM2_SU_STATE);
+ tpm_chip_stop(chip, 0);
+ }
+ mutex_unlock(&chip->tpm_mutex);
+ } else {
rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
+ }
return rc;
}