All of lore.kernel.org
 help / color / mirror / Atom feed
* More interrupt problems with TIS TPM
@ 2020-09-29  0:52 James Bottomley
  2020-09-30  2:14 ` Jarkko Sakkinen
  0 siblings, 1 reply; 2+ messages in thread
From: James Bottomley @ 2020-09-29  0:52 UTC (permalink / raw)
  To: linux-integrity
  Cc: Jerry Snitselaar, Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe

I've got hold of an infineon TIS TPM which actually has a working
interrupt.  I find even with the other fix I still need the patch below
to get the interrupt to fire because without it nothing ever sets
TPM_CHIP_FLAG_IRQ which means the interrupt test code is never
executed.

Finally with all this probing fixed, I'm seeing interrupt storms.  The
way this TPM seems to work is that if you allow it to send command
ready interrupts, it will send them any time it can accept a command. 
The problem is if you clear the interrupt and it can accept a command,
it will send another command ready interrupt ... hence the storm since
the TPM is pretty much always in the command ready state.  The only way
to mitigate this seems to be *only* to enable the command ready
interrupt when you're preparing to wait for the TPM to become ready. 
i.e. these interrupts have to be treated as one shot enable, so the
interrupt routine has to mask the command ready interrupt before doing
a TPM_EOI in our way of doing things.  There seems to be support for
this in the TIS spec around line 1135 where it advises us to keep all
interrupts masked until polling says we have to wait for a particular
state.

James

---

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 6b884badabe7..1578d158416c 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -804,6 +810,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
 		return rc;
 
 	priv->irq_tested = false;
+	chip->flags |= TPM_CHIP_FLAG_IRQ;
 
 	/* Generate an interrupt by having the core call through to
 	 * tpm_tis_send



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

* Re: More interrupt problems with TIS TPM
  2020-09-29  0:52 More interrupt problems with TIS TPM James Bottomley
@ 2020-09-30  2:14 ` Jarkko Sakkinen
  0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2020-09-30  2:14 UTC (permalink / raw)
  To: James Bottomley
  Cc: linux-integrity, Jerry Snitselaar, Peter Huewe, Jason Gunthorpe

On Mon, Sep 28, 2020 at 05:52:43PM -0700, James Bottomley wrote:
> I've got hold of an infineon TIS TPM which actually has a working
> interrupt.  I find even with the other fix I still need the patch below
> to get the interrupt to fire because without it nothing ever sets
> TPM_CHIP_FLAG_IRQ which means the interrupt test code is never
> executed.
> 
> Finally with all this probing fixed, I'm seeing interrupt storms.  The
> way this TPM seems to work is that if you allow it to send command
> ready interrupts, it will send them any time it can accept a command. 
> The problem is if you clear the interrupt and it can accept a command,
> it will send another command ready interrupt ... hence the storm since
> the TPM is pretty much always in the command ready state.  The only way
> to mitigate this seems to be *only* to enable the command ready
> interrupt when you're preparing to wait for the TPM to become ready. 
> i.e. these interrupts have to be treated as one shot enable, so the
> interrupt routine has to mask the command ready interrupt before doing
> a TPM_EOI in our way of doing things.  There seems to be support for
> this in the TIS spec around line 1135 where it advises us to keep all
> interrupts masked until polling says we have to wait for a particular
> state.
> 
> James

OK, this makes a lot of sense. I'll go through the patch set that you
posted. Thank you.

> 
> ---
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index 6b884badabe7..1578d158416c 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -804,6 +810,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
>  		return rc;
>  
>  	priv->irq_tested = false;
> +	chip->flags |= TPM_CHIP_FLAG_IRQ;
>  
>  	/* Generate an interrupt by having the core call through to
>  	 * tpm_tis_send
> 
> 

/Jarkko

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

end of thread, other threads:[~2020-09-30  2:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29  0:52 More interrupt problems with TIS TPM James Bottomley
2020-09-30  2:14 ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.