* [PATCH] tpm: turn on TPM on suspend for TPM 1.x
@ 2019-03-22 10:51 Jarkko Sakkinen
2019-03-28 17:19 ` Domenico Andreoli
0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2019-03-22 10:51 UTC (permalink / raw)
To: linux-integrity
Cc: linux-security-module, pauldzim, Jarkko Sakkinen, Peter Huewe,
Jason Gunthorpe, Arnd Bergmann, Greg Kroah-Hartman, open list
tpm_chip_start/stop() should be also called for TPM 1.x devices on
suspend. Add that functionality back. Do not lock the chip because
it is unnecessary as there are no multiple threads using it when
doing the suspend.
Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
Reported-by: Paul Zimmerman <pauldzim@gmail.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm-interface.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 83ece5639f86..ae1030c9b086 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -402,15 +402,13 @@ int tpm_pm_suspend(struct device *dev)
if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
return 0;
- if (chip->flags & TPM_CHIP_FLAG_TPM2) {
- mutex_lock(&chip->tpm_mutex);
- if (!tpm_chip_start(chip)) {
+ if (!tpm_chip_start(chip)) {
+ if (chip->flags & TPM_CHIP_FLAG_TPM2)
tpm2_shutdown(chip, TPM2_SU_STATE);
- tpm_chip_stop(chip);
- }
- mutex_unlock(&chip->tpm_mutex);
- } else {
- rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
+ else
+ rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
+
+ tpm_chip_stop(chip);
}
return rc;
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tpm: turn on TPM on suspend for TPM 1.x
2019-03-22 10:51 [PATCH] tpm: turn on TPM on suspend for TPM 1.x Jarkko Sakkinen
@ 2019-03-28 17:19 ` Domenico Andreoli
2019-03-29 9:41 ` Jarkko Sakkinen
0 siblings, 1 reply; 3+ messages in thread
From: Domenico Andreoli @ 2019-03-28 17:19 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: linux-integrity, linux-security-module, pauldzim, Peter Huewe,
Jason Gunthorpe, Arnd Bergmann, Greg Kroah-Hartman, open list
On Fri, Mar 22, 2019 at 12:51:20PM +0200, Jarkko Sakkinen wrote:
> tpm_chip_start/stop() should be also called for TPM 1.x devices on
> suspend. Add that functionality back. Do not lock the chip because
> it is unnecessary as there are no multiple threads using it when
> doing the suspend.
>
> Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> Reported-by: Paul Zimmerman <pauldzim@gmail.com>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> drivers/char/tpm/tpm-interface.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index 83ece5639f86..ae1030c9b086 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -402,15 +402,13 @@ int tpm_pm_suspend(struct device *dev)
> if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
> return 0;
>
> - if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> - mutex_lock(&chip->tpm_mutex);
> - if (!tpm_chip_start(chip)) {
> + if (!tpm_chip_start(chip)) {
> + if (chip->flags & TPM_CHIP_FLAG_TPM2)
> tpm2_shutdown(chip, TPM2_SU_STATE);
> - tpm_chip_stop(chip);
> - }
> - mutex_unlock(&chip->tpm_mutex);
> - } else {
> - rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
> + else
> + rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
> +
> + tpm_chip_stop(chip);
> }
>
> return rc;
Tested-by: Domenico Andreoli <domenico.andreoli@linux.com>
--
3B10 0CA1 8674 ACBA B4FE FCD2 CE5B CF17 9960 DE13
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tpm: turn on TPM on suspend for TPM 1.x
2019-03-28 17:19 ` Domenico Andreoli
@ 2019-03-29 9:41 ` Jarkko Sakkinen
0 siblings, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2019-03-29 9:41 UTC (permalink / raw)
To: Domenico Andreoli
Cc: linux-integrity, linux-security-module, pauldzim, Peter Huewe,
Jason Gunthorpe, Arnd Bergmann, Greg Kroah-Hartman, open list
On Thu, Mar 28, 2019 at 06:19:26PM +0100, Domenico Andreoli wrote:
> On Fri, Mar 22, 2019 at 12:51:20PM +0200, Jarkko Sakkinen wrote:
> > tpm_chip_start/stop() should be also called for TPM 1.x devices on
> > suspend. Add that functionality back. Do not lock the chip because
> > it is unnecessary as there are no multiple threads using it when
> > doing the suspend.
> >
> > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > Reported-by: Paul Zimmerman <pauldzim@gmail.com>
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > ---
> > drivers/char/tpm/tpm-interface.c | 14 ++++++--------
> > 1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> > index 83ece5639f86..ae1030c9b086 100644
> > --- a/drivers/char/tpm/tpm-interface.c
> > +++ b/drivers/char/tpm/tpm-interface.c
> > @@ -402,15 +402,13 @@ int tpm_pm_suspend(struct device *dev)
> > if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
> > return 0;
> >
> > - if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> > - mutex_lock(&chip->tpm_mutex);
> > - if (!tpm_chip_start(chip)) {
> > + if (!tpm_chip_start(chip)) {
> > + if (chip->flags & TPM_CHIP_FLAG_TPM2)
> > tpm2_shutdown(chip, TPM2_SU_STATE);
> > - tpm_chip_stop(chip);
> > - }
> > - mutex_unlock(&chip->tpm_mutex);
> > - } else {
> > - rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
> > + else
> > + rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
> > +
> > + tpm_chip_stop(chip);
> > }
> >
> > return rc;
>
> Tested-by: Domenico Andreoli <domenico.andreoli@linux.com>
Thank you! I'll do a PR to James during the weekend.
/Jarkko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-29 9:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-22 10:51 [PATCH] tpm: turn on TPM on suspend for TPM 1.x Jarkko Sakkinen
2019-03-28 17:19 ` Domenico Andreoli
2019-03-29 9:41 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).