[tpmdd-devel,v3,3/5] tpm: return error code from tpm_gen_interrupt()
diff mbox

Message ID 1468935171-7815-4-git-send-email-jarkko.sakkinen@linux.intel.com
State New
Headers show

Commit Message

Jarkko Sakkinen July 19, 2016, 1:32 p.m. UTC
Return error code from tpm_gen_interrupt() and fail tpm_tis family of
drivers on a system error. It doesn't make sense to continue if we
cannot even reach the TPM.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 drivers/char/tpm/tpm.h           | 2 +-
 drivers/char/tpm/tpm_tis_core.c  | 4 +++-
 3 files changed, 7 insertions(+), 5 deletions(-)

Comments

Jason Gunthorpe July 19, 2016, 8:27 p.m. UTC | #1
On Tue, Jul 19, 2016 at 04:32:47PM +0300, Jarkko Sakkinen wrote:
> Return error code from tpm_gen_interrupt() and fail tpm_tis family of
> drivers on a system error. It doesn't make sense to continue if we
> cannot even reach the TPM.
> 
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
>  drivers/char/tpm/tpm-interface.c | 6 +++---
>  drivers/char/tpm/tpm.h           | 2 +-
>  drivers/char/tpm/tpm_tis_core.c  | 4 +++-
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index 88dafcd..35b2722 100644
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
>   * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
>   * a TPM error code.
>   */
> -void tpm_gen_interrupt(struct tpm_chip *chip)
> +int tpm_gen_interrupt(struct tpm_chip *chip)

drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.

I looked at st33zp24.c and it looks broken, I don't see any logic that
de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by
tpm_gen_interrupt, so presumably it should not be calling it at all.

IMHO, DT binding devices should never auto-probe IRQS anyhow, we only
do it on PC because PC is insane...

If we fix st33 then I suggest just moving tpm_gen_interrupt into
tpm_tis - nothing else should really be using it..

Jason

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
Jarkko Sakkinen July 19, 2016, 8:31 p.m. UTC | #2
On Tue, Jul 19, 2016 at 02:27:41PM -0600, Jason Gunthorpe wrote:
> On Tue, Jul 19, 2016 at 04:32:47PM +0300, Jarkko Sakkinen wrote:
> > Return error code from tpm_gen_interrupt() and fail tpm_tis family of
> > drivers on a system error. It doesn't make sense to continue if we
> > cannot even reach the TPM.
> > 
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> >  drivers/char/tpm/tpm-interface.c | 6 +++---
> >  drivers/char/tpm/tpm.h           | 2 +-
> >  drivers/char/tpm/tpm_tis_core.c  | 4 +++-
> >  3 files changed, 7 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> > index 88dafcd..35b2722 100644
> > +++ b/drivers/char/tpm/tpm-interface.c
> > @@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
> >   * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
> >   * a TPM error code.
> >   */
> > -void tpm_gen_interrupt(struct tpm_chip *chip)
> > +int tpm_gen_interrupt(struct tpm_chip *chip)
> 
> drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.
> 
> I looked at st33zp24.c and it looks broken, I don't see any logic that
> de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by
> tpm_gen_interrupt, so presumably it should not be calling it at all.
> 
> IMHO, DT binding devices should never auto-probe IRQS anyhow, we only
> do it on PC because PC is insane...
> 
> If we fix st33 then I suggest just moving tpm_gen_interrupt into
> tpm_tis - nothing else should really be using it..

I'm happy to take fix for st33 but not the move because it does not
matter for the release.

/Jarkko

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
Jarkko Sakkinen July 19, 2016, 8:36 p.m. UTC | #3
On Tue, Jul 19, 2016 at 11:31:47PM +0300, Jarkko Sakkinen wrote:
> On Tue, Jul 19, 2016 at 02:27:41PM -0600, Jason Gunthorpe wrote:
> > On Tue, Jul 19, 2016 at 04:32:47PM +0300, Jarkko Sakkinen wrote:
> > > Return error code from tpm_gen_interrupt() and fail tpm_tis family of
> > > drivers on a system error. It doesn't make sense to continue if we
> > > cannot even reach the TPM.
> > > 
> > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > >  drivers/char/tpm/tpm-interface.c | 6 +++---
> > >  drivers/char/tpm/tpm.h           | 2 +-
> > >  drivers/char/tpm/tpm_tis_core.c  | 4 +++-
> > >  3 files changed, 7 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> > > index 88dafcd..35b2722 100644
> > > +++ b/drivers/char/tpm/tpm-interface.c
> > > @@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
> > >   * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
> > >   * a TPM error code.
> > >   */
> > > -void tpm_gen_interrupt(struct tpm_chip *chip)
> > > +int tpm_gen_interrupt(struct tpm_chip *chip)
> > 
> > drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.
> > 
> > I looked at st33zp24.c and it looks broken, I don't see any logic that
> > de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by
> > tpm_gen_interrupt, so presumably it should not be calling it at all.
> > 
> > IMHO, DT binding devices should never auto-probe IRQS anyhow, we only
> > do it on PC because PC is insane...
> > 
> > If we fix st33 then I suggest just moving tpm_gen_interrupt into
> > tpm_tis - nothing else should really be using it..
> 
> I'm happy to take fix for st33 but not the move because it does not
> matter for the release.

Ignore this comment, this series is not anyway going to 4.8 release.

If Christophe could submit a fix for st33, I could include it to this
series and make one more revision. Thank you for reviewing this!

/Jarkko

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
Jarkko Sakkinen July 19, 2016, 8:39 p.m. UTC | #4
On Tue, Jul 19, 2016 at 11:36:34PM +0300, Jarkko Sakkinen wrote:
> On Tue, Jul 19, 2016 at 11:31:47PM +0300, Jarkko Sakkinen wrote:
> > On Tue, Jul 19, 2016 at 02:27:41PM -0600, Jason Gunthorpe wrote:
> > > On Tue, Jul 19, 2016 at 04:32:47PM +0300, Jarkko Sakkinen wrote:
> > > > Return error code from tpm_gen_interrupt() and fail tpm_tis family of
> > > > drivers on a system error. It doesn't make sense to continue if we
> > > > cannot even reach the TPM.
> > > > 
> > > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > >  drivers/char/tpm/tpm-interface.c | 6 +++---
> > > >  drivers/char/tpm/tpm.h           | 2 +-
> > > >  drivers/char/tpm/tpm_tis_core.c  | 4 +++-
> > > >  3 files changed, 7 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> > > > index 88dafcd..35b2722 100644
> > > > +++ b/drivers/char/tpm/tpm-interface.c
> > > > @@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
> > > >   * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
> > > >   * a TPM error code.
> > > >   */
> > > > -void tpm_gen_interrupt(struct tpm_chip *chip)
> > > > +int tpm_gen_interrupt(struct tpm_chip *chip)
> > > 
> > > drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.
> > > 
> > > I looked at st33zp24.c and it looks broken, I don't see any logic that
> > > de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by
> > > tpm_gen_interrupt, so presumably it should not be calling it at all.
> > > 
> > > IMHO, DT binding devices should never auto-probe IRQS anyhow, we only
> > > do it on PC because PC is insane...
> > > 
> > > If we fix st33 then I suggest just moving tpm_gen_interrupt into
> > > tpm_tis - nothing else should really be using it..
> > 
> > I'm happy to take fix for st33 but not the move because it does not
> > matter for the release.
> 
> Ignore this comment, this series is not anyway going to 4.8 release.
> 
> If Christophe could submit a fix for st33, I could include it to this
> series and make one more revision. Thank you for reviewing this!

Or alternatively if you can provide the fix, Christophe could test it.

/Jarkko

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

Patch
diff mbox

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 88dafcd..35b2722 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -466,16 +466,16 @@  ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
  * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
  * a TPM error code.
  */
-void tpm_gen_interrupt(struct tpm_chip *chip)
+int tpm_gen_interrupt(struct tpm_chip *chip)
 {
 	const char *desc = "attempting to generate an interrupt";
 	u32 cap2;
 	cap_t cap;
 
 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
-		tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
+		return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
 	else
-		tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
+		return tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
 }
 EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
 
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index ec1f877..0cbb598 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -483,7 +483,7 @@  ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len,
 			 const char *desc);
 int tpm_get_timeouts(struct tpm_chip *chip);
-void tpm_gen_interrupt(struct tpm_chip *chip);
+int tpm_gen_interrupt(struct tpm_chip *chip);
 int tpm1_auto_startup(struct tpm_chip *chip);
 int tpm_do_selftest(struct tpm_chip *chip);
 unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index b67d225..45159e1 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -575,7 +575,9 @@  static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
 	/* Generate an interrupt by having the core call through to
 	 * tpm_tis_send
 	 */
-	tpm_gen_interrupt(chip);
+	rc = tpm_gen_interrupt(chip);
+	if (rc < 0)
+		return rc;
 
 	/* tpm_tis_send will either confirm the interrupt is working or it
 	 * will call disable_irq which undoes all of the above.