lkml.org 
[lkml]   [2014]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC PATCH v2] tpm_tis: verify interrupt during init
On Wed, Aug 27, 2014 at 04:31:56AM +0000, Scot Doyle wrote:
> > I think you'll have to directly test in the tis driver if the
> > interrupt is working.
> >
> > The ordering in the TIS driver is wrong, interrupts should be turned
> > on before any TPM commands are issued. This is what other drivers are
> > doing.
> >
> > If you fix this, tis can then just count interrupts recieved and check
> > if that is 0 to detect failure and then turn them off.
>
> How about something like this?
>
> It doesn't enable stock SeaBIOS machines to suspend/resume before the 30
> second interrupt timeout, unless using interrupts=0 or force=1.

? Can you explain that a bit more? interrupts should be detected off
by suspend/resume time, surely?

> +static bool interrupted = false;
> +

This needs to be stored in the private data.

> static irqreturn_t tis_int_handler(int dummy, void *dev_id)
> {
> struct tpm_chip *chip = dev_id;
> @@ -511,6 +513,8 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
> for (i = 0; i < 5; i++)
> if (check_locality(chip, i) >= 0)
> break;
> + if (interrupt & TPM_INTF_CMD_READY_INT)
> + interrupted = true;

Hmm, I'd think any interrupt will do for this purpose, drop the if?

> - if (tpm_do_selftest(chip)) {
> - dev_err(dev, "TPM self test failed\n");
> - rc = -ENODEV;
> - goto out_err;
> - }

Move gettimeout too

> - if (chip->vendor.irq) {
> + if (interrupts && chip->vendor.irq) {

Unrelated? Looks unnecessary:

if (!interrupts) {
irq = 0;
chip->vendor.irq = irq;

if (chip->vendor.irq) {
> + /* Test interrupt and/or prepare for later save state */
> + interrupted = false;
> + if (tpm_do_selftest(chip)) {

As you pointed out before, the commands don't actually fail if
interrupts are not enabled, they just take a longer time to complete.

So this should just be:

if (!tpm_get_timeouts(chip))
goto ..failed..;
if (!dev->interrupts) {
/* Turn off interrupt */
iowrite32(intmask,
chip->vendor.iobase +
TPM_INT_ENABLE(chip->vendor.locality));
free_irq(chip->vendor.irq, chip);
chip->vendor.irq = 0;
dev_err(dev, FIRMWARE_BUG "TPM interrupt is not working, polling instead\n");
// No retry needed, the command completed already.
}
Jason


\
 
 \ /
  Last update: 2014-08-27 19:41    [W:0.158 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site