diff mbox series

[v5,10/10] tpm, tpm_tis: Enable interrupt test

Message ID 20220610110846.8307-11-LinoSanfilippo@gmx.de (mailing list archive)
State New, archived
Headers show
Series TPM IRQ fixes | expand

Commit Message

Lino Sanfilippo June 10, 2022, 11:08 a.m. UTC
From: Lino Sanfilippo <l.sanfilippo@kunbus.com>

The test for interrupts in tpm_tis_send() is skipped if the flag
TPM_CHIP_FLAG_IRQ is not set. Since the current code never sets the flag
initially the test is never executed.

Fix this by setting the flag in tpm_tis_gen_interrupt() right after
interrupts have been enabled.

Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
---
 drivers/char/tpm/tpm_tis_core.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jarkko Sakkinen June 15, 2022, 6:26 p.m. UTC | #1
On Fri, Jun 10, 2022 at 01:08:46PM +0200, LinoSanfilippo@gmx.de wrote:
> From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> 
> The test for interrupts in tpm_tis_send() is skipped if the flag
> TPM_CHIP_FLAG_IRQ is not set. Since the current code never sets the flag
> initially the test is never executed.
> 
> Fix this by setting the flag in tpm_tis_gen_interrupt() right after
> interrupts have been enabled.
> 
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> ---
>  drivers/char/tpm/tpm_tis_core.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index e5edf745fb23..be229c173f10 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -774,11 +774,16 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
>  	if (ret < 0)
>  		return ret;
>  
> +	chip->flags |= TPM_CHIP_FLAG_IRQ;
> +
>  	if (chip->flags & TPM_CHIP_FLAG_TPM2)
>  		ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
>  	else
>  		ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
>  
> +	if (ret)
> +		chip->flags &= ~TPM_CHIP_FLAG_IRQ;
> +
>  	release_locality(chip, 0);
>  
>  	return ret;
> -- 
> 2.36.1
> 

James, do you have a chance to test this on your side? Thanks.

BR, Jarkko
Michael Niewöhner June 15, 2022, 9:54 p.m. UTC | #2
On Wed, 2022-06-15 at 21:26 +0300, Jarkko Sakkinen wrote:
> On Fri, Jun 10, 2022 at 01:08:46PM +0200, LinoSanfilippo@gmx.de wrote:
> > From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> > 
> > The test for interrupts in tpm_tis_send() is skipped if the flag
> > TPM_CHIP_FLAG_IRQ is not set. Since the current code never sets the flag
> > initially the test is never executed.
> > 
> > Fix this by setting the flag in tpm_tis_gen_interrupt() right after
> > interrupts have been enabled.
> > 
> > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> > ---
> >  drivers/char/tpm/tpm_tis_core.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/char/tpm/tpm_tis_core.c
> > b/drivers/char/tpm/tpm_tis_core.c
> > index e5edf745fb23..be229c173f10 100644
> > --- a/drivers/char/tpm/tpm_tis_core.c
> > +++ b/drivers/char/tpm/tpm_tis_core.c
> > @@ -774,11 +774,16 @@ static int tpm_tis_gen_interrupt(struct tpm_chip
> > *chip)
> >         if (ret < 0)
> >                 return ret;
> >  
> > +       chip->flags |= TPM_CHIP_FLAG_IRQ;
> > +
> >         if (chip->flags & TPM_CHIP_FLAG_TPM2)
> >                 ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
> >         else
> >                 ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap,
> > desc, 0);
> >  
> > +       if (ret)
> > +               chip->flags &= ~TPM_CHIP_FLAG_IRQ;
> > +
> >         release_locality(chip, 0);
> >  
> >         return ret;
> > -- 
> > 2.36.1
> > 
> 
> James, do you have a chance to test this on your side? Thanks.
> 
> BR, Jarkko

Hi guys,

for me this series causes boot problems - somehow feels like an interrupt
storm...
Not sure yet, which commit is causing that. I'll do more testing tomorrow.
@Tim could you test on any of your devices, please?

BR
Michael
Lino Sanfilippo June 15, 2022, 11:30 p.m. UTC | #3
Hi Michael,

On 15.06.22 at 23:54, Michael Niewöhner wrote:

>
> Hi guys,
>
> for me this series causes boot problems - somehow feels like an interrupt
> storm...


Thanks for this info. Which hardware do you use?

> Not sure yet, which commit is causing that
> @Tim could you test on any of your devices, please?
>
> BR
> Michael
>

Regards,
Lino
Michael Niewöhner June 16, 2022, 1:03 p.m. UTC | #4
Hi Lino,

On Thu, 2022-06-16 at 01:30 +0200, Lino Sanfilippo wrote:
> 
> Hi Michael,
> 
> On 15.06.22 at 23:54, Michael Niewöhner wrote:
> 
> > 
> > Hi guys,
> > 
> > for me this series causes boot problems - somehow feels like an interrupt
> > storm...
> 
> 
> Thanks for this info. Which hardware do you use?
> 
> > Not sure yet, which commit is causing that
> > @Tim could you test on any of your devices, please?
> > 
> > BR
> > Michael
> > 
> 
> Regards,
> Lino

looks like something was wrong with the devices firmware... I flashed a fresh
image and everything is totally fine now - TPM gets detected without the
"interrupts not working" error! :-)

Test device: Clevo L140MU, FW v1.07.12, TPM 2.0 Infineon SLB9670 (SPI)

BR
Michael
Michael Niewöhner June 16, 2022, 1:04 p.m. UTC | #5
On Wed, 2022-06-15 at 21:26 +0300, Jarkko Sakkinen wrote:
> On Fri, Jun 10, 2022 at 01:08:46PM +0200, LinoSanfilippo@gmx.de wrote:
> > From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> > 
> > The test for interrupts in tpm_tis_send() is skipped if the flag
> > TPM_CHIP_FLAG_IRQ is not set. Since the current code never sets the flag
> > initially the test is never executed.
> > 
> > Fix this by setting the flag in tpm_tis_gen_interrupt() right after
> > interrupts have been enabled.
> > 
> > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> > ---
> >  drivers/char/tpm/tpm_tis_core.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/char/tpm/tpm_tis_core.c
> > b/drivers/char/tpm/tpm_tis_core.c
> > index e5edf745fb23..be229c173f10 100644
> > --- a/drivers/char/tpm/tpm_tis_core.c
> > +++ b/drivers/char/tpm/tpm_tis_core.c
> > @@ -774,11 +774,16 @@ static int tpm_tis_gen_interrupt(struct tpm_chip
> > *chip)
> >         if (ret < 0)
> >                 return ret;
> >  
> > +       chip->flags |= TPM_CHIP_FLAG_IRQ;
> > +
> >         if (chip->flags & TPM_CHIP_FLAG_TPM2)
> >                 ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
> >         else
> >                 ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap,
> > desc, 0);
> >  
> > +       if (ret)
> > +               chip->flags &= ~TPM_CHIP_FLAG_IRQ;
> > +
> >         release_locality(chip, 0);
> >  
> >         return ret;
> > -- 
> > 2.36.1
> > 
> 
> James, do you have a chance to test this on your side? Thanks.
> 
> BR, Jarkko

Tested-by: Michael Niewöhner <linux@mniewoehner.de>
Lino Sanfilippo June 16, 2022, 1:13 p.m. UTC | #6
Hi Michael,

On 16.06.22 at 15:03, Michael Niewöhner wrote:
> Hi Lino,
>
> On Thu, 2022-06-16 at 01:30 +0200, Lino Sanfilippo wrote:
>>
>> Hi Michael,
>>
>> On 15.06.22 at 23:54, Michael Niewöhner wrote:
>>
>>>
>>> Hi guys,
>>>
>>> for me this series causes boot problems - somehow feels like an interrupt
>>> storm...
>>
>>
>> Thanks for this info. Which hardware do you use?
>>
>>> Not sure yet, which commit is causing that
>>> @Tim could you test on any of your devices, please?
>>>
>>> BR
>>> Michael
>>>
>>
>> Regards,
>> Lino
>
> looks like something was wrong with the devices firmware... I flashed a fresh
> image and everything is totally fine now - TPM gets detected without the
> "interrupts not working" error! :-)
>
> Test device: Clevo L140MU, FW v1.07.12, TPM 2.0 Infineon SLB9670 (SPI)
>


Good to hear that everything is fine now, thanks a lot for testing!

Best regards,
Lino
Jarkko Sakkinen June 26, 2022, 5:19 a.m. UTC | #7
On Thu, Jun 16, 2022 at 03:04:30PM +0200, Michael Niewöhner wrote:
> On Wed, 2022-06-15 at 21:26 +0300, Jarkko Sakkinen wrote:
> > On Fri, Jun 10, 2022 at 01:08:46PM +0200, LinoSanfilippo@gmx.de wrote:
> > > From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> > > 
> > > The test for interrupts in tpm_tis_send() is skipped if the flag
> > > TPM_CHIP_FLAG_IRQ is not set. Since the current code never sets the flag
> > > initially the test is never executed.
> > > 
> > > Fix this by setting the flag in tpm_tis_gen_interrupt() right after
> > > interrupts have been enabled.
> > > 
> > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> > > ---
> > >  drivers/char/tpm/tpm_tis_core.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/drivers/char/tpm/tpm_tis_core.c
> > > b/drivers/char/tpm/tpm_tis_core.c
> > > index e5edf745fb23..be229c173f10 100644
> > > --- a/drivers/char/tpm/tpm_tis_core.c
> > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > @@ -774,11 +774,16 @@ static int tpm_tis_gen_interrupt(struct tpm_chip
> > > *chip)
> > >         if (ret < 0)
> > >                 return ret;
> > >  
> > > +       chip->flags |= TPM_CHIP_FLAG_IRQ;
> > > +
> > >         if (chip->flags & TPM_CHIP_FLAG_TPM2)
> > >                 ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
> > >         else
> > >                 ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap,
> > > desc, 0);
> > >  
> > > +       if (ret)
> > > +               chip->flags &= ~TPM_CHIP_FLAG_IRQ;
> > > +
> > >         release_locality(chip, 0);
> > >  
> > >         return ret;
> > > -- 
> > > 2.36.1
> > > 
> > 
> > James, do you have a chance to test this on your side? Thanks.
> > 
> > BR, Jarkko
> 
> Tested-by: Michael Niewöhner <linux@mniewoehner.de>

Thank you.

BR, Jarkko
diff mbox series

Patch

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index e5edf745fb23..be229c173f10 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -774,11 +774,16 @@  static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
 	if (ret < 0)
 		return ret;
 
+	chip->flags |= TPM_CHIP_FLAG_IRQ;
+
 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
 		ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
 	else
 		ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
 
+	if (ret)
+		chip->flags &= ~TPM_CHIP_FLAG_IRQ;
+
 	release_locality(chip, 0);
 
 	return ret;