Re: [RFC PATCH v2] tpm_tis: verify interrupt during init
From: Jason Gunthorpe
Date: Wed Aug 27 2014 - 13:32:00 EST
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/