linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
@ 2019-11-11 23:34 Jerry Snitselaar
  2019-11-12  0:03 ` [PATCH v2] " Jerry Snitselaar
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Jerry Snitselaar @ 2019-11-11 23:34 UTC (permalink / raw)
  To: linux-integrity
  Cc: Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe, linux-kernel,
	linux-stable, Christian Bundy

With power gating moved out of the tpm_transmit code we need
to power on the TPM prior to calling tpm_get_timeouts.

Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-kernel@vger.kernel.org
Cc: linux-stable@vger.kernel.org
Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
Reported-by: Christian Bundy <christianbundy@fraction.io>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 270f43acbb77..cb101cec8f8b 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_stop_chip(chip);
 			goto out_err;
 		}
 
-		tpm_chip_start(chip);
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 		if (irq) {
 			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-11 23:34 [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts Jerry Snitselaar
@ 2019-11-12  0:03 ` Jerry Snitselaar
  2019-11-12 20:03 ` [PATCH] " Jarkko Sakkinen
  2019-11-13  0:02 ` [PATCH v3] " Jerry Snitselaar
  2 siblings, 0 replies; 18+ messages in thread
From: Jerry Snitselaar @ 2019-11-12  0:03 UTC (permalink / raw)
  To: linux-integrity
  Cc: Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe, linux-kernel,
	stable, Christian Bundy

With power gating moved out of the tpm_transmit code we need
to power on the TPM prior to calling tpm_get_timeouts.

Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
Reported-by: Christian Bundy <christianbundy@fraction.io>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
v2: fix stable cc to correct address

 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 270f43acbb77..cb101cec8f8b 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_stop_chip(chip);
 			goto out_err;
 		}
 
-		tpm_chip_start(chip);
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 		if (irq) {
 			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-11 23:34 [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts Jerry Snitselaar
  2019-11-12  0:03 ` [PATCH v2] " Jerry Snitselaar
@ 2019-11-12 20:03 ` Jarkko Sakkinen
  2019-11-12 20:23   ` Jerry Snitselaar
  2019-11-13  0:02 ` [PATCH v3] " Jerry Snitselaar
  2 siblings, 1 reply; 18+ messages in thread
From: Jarkko Sakkinen @ 2019-11-12 20:03 UTC (permalink / raw)
  To: Jerry Snitselaar
  Cc: linux-integrity, Peter Huewe, Jason Gunthorpe, linux-kernel,
	linux-stable, Christian Bundy

On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> With power gating moved out of the tpm_transmit code we need
> to power on the TPM prior to calling tpm_get_timeouts.
> 
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Cc: Peter Huewe <peterhuewe@gmx.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-stable@vger.kernel.org
> Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> Reported-by: Christian Bundy <christianbundy@fraction.io>
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> ---
>  drivers/char/tpm/tpm_tis_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index 270f43acbb77..cb101cec8f8b 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>  		 * to make sure it works. May as well use that command to set the
>  		 * proper timeouts for the driver.
>  		 */
> +		tpm_chip_start(chip);
>  		if (tpm_get_timeouts(chip)) {
>  			dev_err(dev, "Could not get TPM timeouts and durations\n");
>  			rc = -ENODEV;
> +			tpm_stop_chip(chip);
>  			goto out_err;
>  		}

Couldn't this call just be removed?

/Jarkko

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:03 ` [PATCH] " Jarkko Sakkinen
@ 2019-11-12 20:23   ` Jerry Snitselaar
  2019-11-12 20:26     ` Jason Gunthorpe
  0 siblings, 1 reply; 18+ messages in thread
From: Jerry Snitselaar @ 2019-11-12 20:23 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: linux-integrity, Peter Huewe, Jason Gunthorpe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
<jarkko.sakkinen@linux.intel.com> wrote:
>
> On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > With power gating moved out of the tpm_transmit code we need
> > to power on the TPM prior to calling tpm_get_timeouts.
> >
> > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > Cc: Peter Huewe <peterhuewe@gmx.de>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-stable@vger.kernel.org
> > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > ---
> >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > index 270f43acbb77..cb101cec8f8b 100644
> > --- a/drivers/char/tpm/tpm_tis_core.c
> > +++ b/drivers/char/tpm/tpm_tis_core.c
> > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> >                * to make sure it works. May as well use that command to set the
> >                * proper timeouts for the driver.
> >                */
> > +             tpm_chip_start(chip);
> >               if (tpm_get_timeouts(chip)) {
> >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> >                       rc = -ENODEV;
> > +                     tpm_stop_chip(chip);
> >                       goto out_err;
> >               }
>
> Couldn't this call just be removed?
>
> /Jarkko
>

Probably. It will eventually get called when tpm_chip_register
happens. I don't know what the reason was for trying it prior to the
irq probe.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:23   ` Jerry Snitselaar
@ 2019-11-12 20:26     ` Jason Gunthorpe
  2019-11-12 20:28       ` Jerry Snitselaar
  2019-11-14 16:49       ` Jarkko Sakkinen
  0 siblings, 2 replies; 18+ messages in thread
From: Jason Gunthorpe @ 2019-11-12 20:26 UTC (permalink / raw)
  To: Jerry Snitselaar
  Cc: Jarkko Sakkinen, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
> On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
> <jarkko.sakkinen@linux.intel.com> wrote:
> >
> > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > > With power gating moved out of the tpm_transmit code we need
> > > to power on the TPM prior to calling tpm_get_timeouts.
> > >
> > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > Cc: linux-kernel@vger.kernel.org
> > > Cc: linux-stable@vger.kernel.org
> > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > index 270f43acbb77..cb101cec8f8b 100644
> > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > >                * to make sure it works. May as well use that command to set the
> > >                * proper timeouts for the driver.
> > >                */
> > > +             tpm_chip_start(chip);
> > >               if (tpm_get_timeouts(chip)) {
> > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> > >                       rc = -ENODEV;
> > > +                     tpm_stop_chip(chip);
> > >                       goto out_err;
> > >               }
> >
> > Couldn't this call just be removed?
> >
> > /Jarkko
> >
> 
> Probably. It will eventually get called when tpm_chip_register
> happens. I don't know what the reason was for trying it prior to the
> irq probe.

At least tis once needed the timeouts before registration because it
was issuing TPM commands to complete its setup.

If timeouts have not been set then no TPM command should be executed.

Jason

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:26     ` Jason Gunthorpe
@ 2019-11-12 20:28       ` Jerry Snitselaar
  2019-11-12 20:31         ` Jerry Snitselaar
  2019-11-14 16:55         ` Jarkko Sakkinen
  2019-11-14 16:49       ` Jarkko Sakkinen
  1 sibling, 2 replies; 18+ messages in thread
From: Jerry Snitselaar @ 2019-11-12 20:28 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Jarkko Sakkinen, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Tue, Nov 12, 2019 at 1:26 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
> > On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
> > <jarkko.sakkinen@linux.intel.com> wrote:
> > >
> > > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > > > With power gating moved out of the tpm_transmit code we need
> > > > to power on the TPM prior to calling tpm_get_timeouts.
> > > >
> > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > > Cc: linux-kernel@vger.kernel.org
> > > > Cc: linux-stable@vger.kernel.org
> > > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > > > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > > index 270f43acbb77..cb101cec8f8b 100644
> > > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > > >                * to make sure it works. May as well use that command to set the
> > > >                * proper timeouts for the driver.
> > > >                */
> > > > +             tpm_chip_start(chip);
> > > >               if (tpm_get_timeouts(chip)) {
> > > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > >                       rc = -ENODEV;
> > > > +                     tpm_stop_chip(chip);
> > > >                       goto out_err;
> > > >               }
> > >
> > > Couldn't this call just be removed?
> > >
> > > /Jarkko
> > >
> >
> > Probably. It will eventually get called when tpm_chip_register
> > happens. I don't know what the reason was for trying it prior to the
> > irq probe.
>
> At least tis once needed the timeouts before registration because it
> was issuing TPM commands to complete its setup.
>
> If timeouts have not been set then no TPM command should be executed.
>
> Jason
>

Would it function with the timeout values set at the beginning of
tpm_tis_core_init (max values)?


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:28       ` Jerry Snitselaar
@ 2019-11-12 20:31         ` Jerry Snitselaar
  2019-11-12 20:46           ` Jason Gunthorpe
  2019-11-14 16:55         ` Jarkko Sakkinen
  1 sibling, 1 reply; 18+ messages in thread
From: Jerry Snitselaar @ 2019-11-12 20:31 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Jarkko Sakkinen, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Tue, Nov 12, 2019 at 1:28 PM Jerry Snitselaar <jsnitsel@redhat.com> wrote:
>
> On Tue, Nov 12, 2019 at 1:26 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> >
> > On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
> > > On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
> > > <jarkko.sakkinen@linux.intel.com> wrote:
> > > >
> > > > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > > > > With power gating moved out of the tpm_transmit code we need
> > > > > to power on the TPM prior to calling tpm_get_timeouts.
> > > > >
> > > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > > > Cc: linux-kernel@vger.kernel.org
> > > > > Cc: linux-stable@vger.kernel.org
> > > > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > > > > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > > > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > > > index 270f43acbb77..cb101cec8f8b 100644
> > > > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > > > >                * to make sure it works. May as well use that command to set the
> > > > >                * proper timeouts for the driver.
> > > > >                */
> > > > > +             tpm_chip_start(chip);
> > > > >               if (tpm_get_timeouts(chip)) {
> > > > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > > >                       rc = -ENODEV;
> > > > > +                     tpm_stop_chip(chip);
> > > > >                       goto out_err;
> > > > >               }
> > > >
> > > > Couldn't this call just be removed?
> > > >
> > > > /Jarkko
> > > >
> > >
> > > Probably. It will eventually get called when tpm_chip_register
> > > happens. I don't know what the reason was for trying it prior to the
> > > irq probe.
> >
> > At least tis once needed the timeouts before registration because it
> > was issuing TPM commands to complete its setup.
> >
> > If timeouts have not been set then no TPM command should be executed.
> >
> > Jason
> >
>
> Would it function with the timeout values set at the beginning of
> tpm_tis_core_init (max values)?

I guess that doesn't set the duration values though


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:31         ` Jerry Snitselaar
@ 2019-11-12 20:46           ` Jason Gunthorpe
  2019-11-12 21:14             ` Jerry Snitselaar
  0 siblings, 1 reply; 18+ messages in thread
From: Jason Gunthorpe @ 2019-11-12 20:46 UTC (permalink / raw)
  To: Jerry Snitselaar
  Cc: Jarkko Sakkinen, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Tue, Nov 12, 2019 at 01:31:09PM -0700, Jerry Snitselaar wrote:
> On Tue, Nov 12, 2019 at 1:28 PM Jerry Snitselaar <jsnitsel@redhat.com> wrote:
> >
> > On Tue, Nov 12, 2019 at 1:26 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> > >
> > > On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
> > > > On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
> > > > <jarkko.sakkinen@linux.intel.com> wrote:
> > > > >
> > > > > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > > > > > With power gating moved out of the tpm_transmit code we need
> > > > > > to power on the TPM prior to calling tpm_get_timeouts.
> > > > > >
> > > > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > > > > Cc: linux-kernel@vger.kernel.org
> > > > > > Cc: linux-stable@vger.kernel.org
> > > > > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > > > > > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > > > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > > > > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> > > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > > > > index 270f43acbb77..cb101cec8f8b 100644
> > > > > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > > > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > > > > >                * to make sure it works. May as well use that command to set the
> > > > > >                * proper timeouts for the driver.
> > > > > >                */
> > > > > > +             tpm_chip_start(chip);
> > > > > >               if (tpm_get_timeouts(chip)) {
> > > > > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > > > >                       rc = -ENODEV;
> > > > > > +                     tpm_stop_chip(chip);
> > > > > >                       goto out_err;
> > > > > >               }
> > > > >
> > > > > Couldn't this call just be removed?
> > > > >
> > > > > /Jarkko
> > > > >
> > > >
> > > > Probably. It will eventually get called when tpm_chip_register
> > > > happens. I don't know what the reason was for trying it prior to the
> > > > irq probe.
> > >
> > > At least tis once needed the timeouts before registration because it
> > > was issuing TPM commands to complete its setup.
> > >
> > > If timeouts have not been set then no TPM command should be executed.
> >
> > Would it function with the timeout values set at the beginning of
> > tpm_tis_core_init (max values)?
> 
> I guess that doesn't set the duration values though

There is no reason to use anything but the correct timeouts, as read
from the device.

Jason 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:46           ` Jason Gunthorpe
@ 2019-11-12 21:14             ` Jerry Snitselaar
  0 siblings, 0 replies; 18+ messages in thread
From: Jerry Snitselaar @ 2019-11-12 21:14 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Jarkko Sakkinen, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, stable, Christian Bundy

On Tue Nov 12 19, Jason Gunthorpe wrote:
>On Tue, Nov 12, 2019 at 01:31:09PM -0700, Jerry Snitselaar wrote:
>> On Tue, Nov 12, 2019 at 1:28 PM Jerry Snitselaar <jsnitsel@redhat.com> wrote:
>> >
>> > On Tue, Nov 12, 2019 at 1:26 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>> > >
>> > > On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
>> > > > On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
>> > > > <jarkko.sakkinen@linux.intel.com> wrote:
>> > > > >
>> > > > > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
>> > > > > > With power gating moved out of the tpm_transmit code we need
>> > > > > > to power on the TPM prior to calling tpm_get_timeouts.
>> > > > > >
>> > > > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
>> > > > > > Cc: Peter Huewe <peterhuewe@gmx.de>
>> > > > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
>> > > > > > Cc: linux-kernel@vger.kernel.org
>> > > > > > Cc: linux-stable@vger.kernel.org
>> > > > > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
>> > > > > > Reported-by: Christian Bundy <christianbundy@fraction.io>
>> > > > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
>> > > > > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
>> > > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
>> > > > > >
>> > > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
>> > > > > > index 270f43acbb77..cb101cec8f8b 100644
>> > > > > > +++ b/drivers/char/tpm/tpm_tis_core.c
>> > > > > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>> > > > > >                * to make sure it works. May as well use that command to set the
>> > > > > >                * proper timeouts for the driver.
>> > > > > >                */
>> > > > > > +             tpm_chip_start(chip);
>> > > > > >               if (tpm_get_timeouts(chip)) {
>> > > > > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
>> > > > > >                       rc = -ENODEV;
>> > > > > > +                     tpm_stop_chip(chip);
>> > > > > >                       goto out_err;
>> > > > > >               }
>> > > > >
>> > > > > Couldn't this call just be removed?
>> > > > >
>> > > > > /Jarkko
>> > > > >
>> > > >
>> > > > Probably. It will eventually get called when tpm_chip_register
>> > > > happens. I don't know what the reason was for trying it prior to the
>> > > > irq probe.
>> > >
>> > > At least tis once needed the timeouts before registration because it
>> > > was issuing TPM commands to complete its setup.
>> > >
>> > > If timeouts have not been set then no TPM command should be executed.
>> >
>> > Would it function with the timeout values set at the beginning of
>> > tpm_tis_core_init (max values)?
>>
>> I guess that doesn't set the duration values though
>
>There is no reason to use anything but the correct timeouts, as read
>from the device.
>
>Jason
>

Should there be a check in tpm1_get_timeouts and tpm2_get_timeouts:

	if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS)
		return 0;

to skip going through it again in the auto startup code if it was
already called and set?


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v3] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-11 23:34 [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts Jerry Snitselaar
  2019-11-12  0:03 ` [PATCH v2] " Jerry Snitselaar
  2019-11-12 20:03 ` [PATCH] " Jarkko Sakkinen
@ 2019-11-13  0:02 ` Jerry Snitselaar
  2019-11-14 16:59   ` Jarkko Sakkinen
  2 siblings, 1 reply; 18+ messages in thread
From: Jerry Snitselaar @ 2019-11-13  0:02 UTC (permalink / raw)
  To: linux-integrity
  Cc: Jerry Snitselaar, Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe,
	linux-kernel, stable, Christian Bundy

With power gating moved out of the tpm_transmit code we need
to power on the TPM prior to calling tpm_get_timeouts.

Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
Reported-by: Christian Bundy <christianbundy@fraction.io>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
v3: call tpm_chip_stop in error path
v2: fix stable cc to correct address

 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 270f43acbb77..806acc666696 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_chip_stop(chip);
 			goto out_err;
 		}
 
-		tpm_chip_start(chip);
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 		if (irq) {
 			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:26     ` Jason Gunthorpe
  2019-11-12 20:28       ` Jerry Snitselaar
@ 2019-11-14 16:49       ` Jarkko Sakkinen
  2019-11-14 16:51         ` Jason Gunthorpe
  1 sibling, 1 reply; 18+ messages in thread
From: Jarkko Sakkinen @ 2019-11-14 16:49 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Jerry Snitselaar, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Tue, Nov 12, 2019 at 04:26:23PM -0400, Jason Gunthorpe wrote:
> On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
> > On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
> > <jarkko.sakkinen@linux.intel.com> wrote:
> > >
> > > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > > > With power gating moved out of the tpm_transmit code we need
> > > > to power on the TPM prior to calling tpm_get_timeouts.
> > > >
> > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > > Cc: linux-kernel@vger.kernel.org
> > > > Cc: linux-stable@vger.kernel.org
> > > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > > > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > > index 270f43acbb77..cb101cec8f8b 100644
> > > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > > >                * to make sure it works. May as well use that command to set the
> > > >                * proper timeouts for the driver.
> > > >                */
> > > > +             tpm_chip_start(chip);
> > > >               if (tpm_get_timeouts(chip)) {
> > > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > >                       rc = -ENODEV;
> > > > +                     tpm_stop_chip(chip);
> > > >                       goto out_err;
> > > >               }
> > >
> > > Couldn't this call just be removed?
> > >
> > > /Jarkko
> > >
> > 
> > Probably. It will eventually get called when tpm_chip_register
> > happens. I don't know what the reason was for trying it prior to the
> > irq probe.
> 
> At least tis once needed the timeouts before registration because it
> was issuing TPM commands to complete its setup.
> 
> If timeouts have not been set then no TPM command should be executed.

Not true since you need a TPM command to set them. That is why they
have been set initially to maximum possible values.

/Jarkko

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-14 16:49       ` Jarkko Sakkinen
@ 2019-11-14 16:51         ` Jason Gunthorpe
  0 siblings, 0 replies; 18+ messages in thread
From: Jason Gunthorpe @ 2019-11-14 16:51 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: Jerry Snitselaar, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Thu, Nov 14, 2019 at 06:49:49PM +0200, Jarkko Sakkinen wrote:
> On Tue, Nov 12, 2019 at 04:26:23PM -0400, Jason Gunthorpe wrote:
> > On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
> > > On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
> > > <jarkko.sakkinen@linux.intel.com> wrote:
> > > >
> > > > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > > > > With power gating moved out of the tpm_transmit code we need
> > > > > to power on the TPM prior to calling tpm_get_timeouts.
> > > > >
> > > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > > > Cc: linux-kernel@vger.kernel.org
> > > > > Cc: linux-stable@vger.kernel.org
> > > > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > > > > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > > > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > > > index 270f43acbb77..cb101cec8f8b 100644
> > > > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > > > >                * to make sure it works. May as well use that command to set the
> > > > >                * proper timeouts for the driver.
> > > > >                */
> > > > > +             tpm_chip_start(chip);
> > > > >               if (tpm_get_timeouts(chip)) {
> > > > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > > >                       rc = -ENODEV;
> > > > > +                     tpm_stop_chip(chip);
> > > > >                       goto out_err;
> > > > >               }
> > > >
> > > > Couldn't this call just be removed?
> > > >
> > > > /Jarkko
> > > >
> > > 
> > > Probably. It will eventually get called when tpm_chip_register
> > > happens. I don't know what the reason was for trying it prior to the
> > > irq probe.
> > 
> > At least tis once needed the timeouts before registration because it
> > was issuing TPM commands to complete its setup.
> > 
> > If timeouts have not been set then no TPM command should be executed.
> 
> Not true since you need a TPM command to set them. That is why they
> have been set initially to maximum possible values.

getting timeouts is the exception

Jason

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-12 20:28       ` Jerry Snitselaar
  2019-11-12 20:31         ` Jerry Snitselaar
@ 2019-11-14 16:55         ` Jarkko Sakkinen
  2019-11-14 16:56           ` Jason Gunthorpe
  1 sibling, 1 reply; 18+ messages in thread
From: Jarkko Sakkinen @ 2019-11-14 16:55 UTC (permalink / raw)
  To: Jerry Snitselaar
  Cc: Jason Gunthorpe, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Tue, Nov 12, 2019 at 01:28:49PM -0700, Jerry Snitselaar wrote:
> On Tue, Nov 12, 2019 at 1:26 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> >
> > On Tue, Nov 12, 2019 at 01:23:33PM -0700, Jerry Snitselaar wrote:
> > > On Tue, Nov 12, 2019 at 1:03 PM Jarkko Sakkinen
> > > <jarkko.sakkinen@linux.intel.com> wrote:
> > > >
> > > > On Mon, Nov 11, 2019 at 04:34:18PM -0700, Jerry Snitselaar wrote:
> > > > > With power gating moved out of the tpm_transmit code we need
> > > > > to power on the TPM prior to calling tpm_get_timeouts.
> > > > >
> > > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > > > Cc: linux-kernel@vger.kernel.org
> > > > > Cc: linux-stable@vger.kernel.org
> > > > > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> > > > > Reported-by: Christian Bundy <christianbundy@fraction.io>
> > > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > > > >  drivers/char/tpm/tpm_tis_core.c | 3 ++-
> > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > > > index 270f43acbb77..cb101cec8f8b 100644
> > > > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > > > @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > > > >                * to make sure it works. May as well use that command to set the
> > > > >                * proper timeouts for the driver.
> > > > >                */
> > > > > +             tpm_chip_start(chip);
> > > > >               if (tpm_get_timeouts(chip)) {
> > > > >                       dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > > >                       rc = -ENODEV;
> > > > > +                     tpm_stop_chip(chip);
> > > > >                       goto out_err;
> > > > >               }
> > > >
> > > > Couldn't this call just be removed?
> > > >
> > > > /Jarkko
> > > >
> > >
> > > Probably. It will eventually get called when tpm_chip_register
> > > happens. I don't know what the reason was for trying it prior to the
> > > irq probe.
> >
> > At least tis once needed the timeouts before registration because it
> > was issuing TPM commands to complete its setup.
> >
> > If timeouts have not been set then no TPM command should be executed.
> >
> > Jason
> >
> 
> Would it function with the timeout values set at the beginning of
> tpm_tis_core_init (max values)?

tpm_get_timeouts() should be replaced with:

if (tpm_chip_start()) {
	dev_err(dev, "Could not get TPM timeouts and durations\n");
	rc = -ENODEV;
	goto out_err;
}

tpm_stop_chip(chip);

tpm_get_timeouts() is called by tpm_auto_startup(). Also the function
should be moved to tpm_chip.c and converted to a static function so
that it won't be called from random cal sites like above.

/Jarkko

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-14 16:55         ` Jarkko Sakkinen
@ 2019-11-14 16:56           ` Jason Gunthorpe
  2019-11-15 17:43             ` Jarkko Sakkinen
  0 siblings, 1 reply; 18+ messages in thread
From: Jason Gunthorpe @ 2019-11-14 16:56 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: Jerry Snitselaar, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Thu, Nov 14, 2019 at 06:55:06PM +0200, Jarkko Sakkinen wrote:
> > Would it function with the timeout values set at the beginning of
> > tpm_tis_core_init (max values)?
> 
> tpm_get_timeouts() should be replaced with:
> 
> if (tpm_chip_start()) {
> 	dev_err(dev, "Could not get TPM timeouts and durations\n");
> 	rc = -ENODEV;
> 	goto out_err;
> }
> 
> tpm_stop_chip(chip);
> 
> tpm_get_timeouts() is called by tpm_auto_startup(). Also the function
> should be moved to tpm_chip.c and converted to a static function so
> that it won't be called from random cal sites like above.

Careful, the design here was to allow a driver to do only
get_timeouts, then additional setup work, then do auto_startup()

Forcing a driver to do auto_startup too early may not be good.

Jason

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-13  0:02 ` [PATCH v3] " Jerry Snitselaar
@ 2019-11-14 16:59   ` Jarkko Sakkinen
  0 siblings, 0 replies; 18+ messages in thread
From: Jarkko Sakkinen @ 2019-11-14 16:59 UTC (permalink / raw)
  To: Jerry Snitselaar
  Cc: linux-integrity, Peter Huewe, Jason Gunthorpe, linux-kernel,
	stable, Christian Bundy

On Tue, Nov 12, 2019 at 05:02:43PM -0700, Jerry Snitselaar wrote:
> With power gating moved out of the tpm_transmit code we need
> to power on the TPM prior to calling tpm_get_timeouts.
> 
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Cc: Peter Huewe <peterhuewe@gmx.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
> Reported-by: Christian Bundy <christianbundy@fraction.io>
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> ---
> v3: call tpm_chip_stop in error path
> v2: fix stable cc to correct address
> 
>  drivers/char/tpm/tpm_tis_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index 270f43acbb77..806acc666696 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>  		 * to make sure it works. May as well use that command to set the
>  		 * proper timeouts for the driver.
>  		 */
> +		tpm_chip_start(chip);
>  		if (tpm_get_timeouts(chip)) {
>  			dev_err(dev, "Could not get TPM timeouts and durations\n");
>  			rc = -ENODEV;
> +			tpm_chip_stop(chip);
>  			goto out_err;
>  		}
>  
> -		tpm_chip_start(chip);

As the commit describes the call is not there for any other reason than
pinging the TPM.

/Jarkko

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-14 16:56           ` Jason Gunthorpe
@ 2019-11-15 17:43             ` Jarkko Sakkinen
  2019-11-15 18:36               ` Jason Gunthorpe
  0 siblings, 1 reply; 18+ messages in thread
From: Jarkko Sakkinen @ 2019-11-15 17:43 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Jerry Snitselaar, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Thu, Nov 14, 2019 at 12:56:29PM -0400, Jason Gunthorpe wrote:
> On Thu, Nov 14, 2019 at 06:55:06PM +0200, Jarkko Sakkinen wrote:
> > > Would it function with the timeout values set at the beginning of
> > > tpm_tis_core_init (max values)?
> > 
> > tpm_get_timeouts() should be replaced with:
> > 
> > if (tpm_chip_start()) {
> > 	dev_err(dev, "Could not get TPM timeouts and durations\n");
> > 	rc = -ENODEV;
> > 	goto out_err;
> > }
> > 
> > tpm_stop_chip(chip);
> > 
> > tpm_get_timeouts() is called by tpm_auto_startup(). Also the function
> > should be moved to tpm_chip.c and converted to a static function so
> > that it won't be called from random cal sites like above.
> 
> Careful, the design here was to allow a driver to do only
> get_timeouts, then additional setup work, then do auto_startup()
> 
> Forcing a driver to do auto_startup too early may not be good.

All drivers always do it anyway because all drivers always call
tpm_chip_register().

/Jarkko

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-15 17:43             ` Jarkko Sakkinen
@ 2019-11-15 18:36               ` Jason Gunthorpe
  2019-11-15 22:40                 ` Jarkko Sakkinen
  0 siblings, 1 reply; 18+ messages in thread
From: Jason Gunthorpe @ 2019-11-15 18:36 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: Jerry Snitselaar, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Fri, Nov 15, 2019 at 07:43:29PM +0200, Jarkko Sakkinen wrote:
> On Thu, Nov 14, 2019 at 12:56:29PM -0400, Jason Gunthorpe wrote:
> > On Thu, Nov 14, 2019 at 06:55:06PM +0200, Jarkko Sakkinen wrote:
> > > > Would it function with the timeout values set at the beginning of
> > > > tpm_tis_core_init (max values)?
> > > 
> > > tpm_get_timeouts() should be replaced with:
> > > 
> > > if (tpm_chip_start()) {
> > > 	dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > 	rc = -ENODEV;
> > > 	goto out_err;
> > > }
> > > 
> > > tpm_stop_chip(chip);
> > > 
> > > tpm_get_timeouts() is called by tpm_auto_startup(). Also the function
> > > should be moved to tpm_chip.c and converted to a static function so
> > > that it won't be called from random cal sites like above.
> > 
> > Careful, the design here was to allow a driver to do only
> > get_timeouts, then additional setup work, then do auto_startup()
> > 
> > Forcing a driver to do auto_startup too early may not be good.
> 
> All drivers always do it anyway because all drivers always call
> tpm_chip_register().

But chip_register is after the driver has done it's setup and after it
may have called get_timeouts

auto_setup should not be moved to before chip_register()

Jason

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts
  2019-11-15 18:36               ` Jason Gunthorpe
@ 2019-11-15 22:40                 ` Jarkko Sakkinen
  0 siblings, 0 replies; 18+ messages in thread
From: Jarkko Sakkinen @ 2019-11-15 22:40 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Jerry Snitselaar, linux-integrity, Peter Huewe,
	Linux List Kernel Mailing, linux-stable, Christian Bundy

On Fri, Nov 15, 2019 at 02:36:21PM -0400, Jason Gunthorpe wrote:
> On Fri, Nov 15, 2019 at 07:43:29PM +0200, Jarkko Sakkinen wrote:
> > On Thu, Nov 14, 2019 at 12:56:29PM -0400, Jason Gunthorpe wrote:
> > > On Thu, Nov 14, 2019 at 06:55:06PM +0200, Jarkko Sakkinen wrote:
> > > > > Would it function with the timeout values set at the beginning of
> > > > > tpm_tis_core_init (max values)?
> > > > 
> > > > tpm_get_timeouts() should be replaced with:
> > > > 
> > > > if (tpm_chip_start()) {
> > > > 	dev_err(dev, "Could not get TPM timeouts and durations\n");
> > > > 	rc = -ENODEV;
> > > > 	goto out_err;
> > > > }
> > > > 
> > > > tpm_stop_chip(chip);
> > > > 
> > > > tpm_get_timeouts() is called by tpm_auto_startup(). Also the function
> > > > should be moved to tpm_chip.c and converted to a static function so
> > > > that it won't be called from random cal sites like above.
> > > 
> > > Careful, the design here was to allow a driver to do only
> > > get_timeouts, then additional setup work, then do auto_startup()
> > > 
> > > Forcing a driver to do auto_startup too early may not be good.
> > 
> > All drivers always do it anyway because all drivers always call
> > tpm_chip_register().
> 
> But chip_register is after the driver has done it's setup and after it
> may have called get_timeouts
> 
> auto_setup should not be moved to before chip_register()

I do not see any sense calling from get_timeouts() from call sites
in the same initialization flow.

/Jarkko

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-11-15 22:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 23:34 [PATCH] tpm_tis: turn on TPM before calling tpm_get_timeouts Jerry Snitselaar
2019-11-12  0:03 ` [PATCH v2] " Jerry Snitselaar
2019-11-12 20:03 ` [PATCH] " Jarkko Sakkinen
2019-11-12 20:23   ` Jerry Snitselaar
2019-11-12 20:26     ` Jason Gunthorpe
2019-11-12 20:28       ` Jerry Snitselaar
2019-11-12 20:31         ` Jerry Snitselaar
2019-11-12 20:46           ` Jason Gunthorpe
2019-11-12 21:14             ` Jerry Snitselaar
2019-11-14 16:55         ` Jarkko Sakkinen
2019-11-14 16:56           ` Jason Gunthorpe
2019-11-15 17:43             ` Jarkko Sakkinen
2019-11-15 18:36               ` Jason Gunthorpe
2019-11-15 22:40                 ` Jarkko Sakkinen
2019-11-14 16:49       ` Jarkko Sakkinen
2019-11-14 16:51         ` Jason Gunthorpe
2019-11-13  0:02 ` [PATCH v3] " Jerry Snitselaar
2019-11-14 16:59   ` 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).