Re: [PATCH 1/2] tpm, tpm_tis: Handle interrupt storm

From: Lukas Wunner
Date: Wed May 24 2023 - 03:29:42 EST


On Wed, May 24, 2023 at 06:58:08AM +0300, Jarkko Sakkinen wrote:
> On Mon May 22, 2023 at 5:31 PM EEST, Lino Sanfilippo wrote:
> > + /*
> > + * The worker to free the TPM interrupt (free_irq_work) may already
> > + * be scheduled, so make sure it is not scheduled again.
> > + */
> > + if (!(chip->flags & TPM_CHIP_FLAG_IRQ))
> > + return;
> > +
> > + if (time_after(jiffies, priv->last_unhandled_irq + HZ/10))
> > + priv->unhandled_irqs = 1;
> > + else
> > + priv->unhandled_irqs++;
> > +
> > + priv->last_unhandled_irq = jiffies;
> > +
> > + if (priv->unhandled_irqs > MAX_UNHANDLED_IRQS)
> > + tpm_tis_handle_irq_storm(chip);
>
> Why wouldn't we switch to polling mode even when there is a single
> unhandled IRQ?

An unhandled IRQ can be legitimate if the interrupt is shared
with other devices and the IRQ was raised by one of them.

So you only want to switch to polling if there's a significant
amount of unhandled IRQs in a short period of time.

Thanks,

Lukas