RE: [PATCH 2/2] iommu/vt-d: Share DMAR fault IRQ to prevent vector exhaustion

From: Tian, Kevin
Date: Tue Apr 09 2024 - 03:07:34 EST


> From: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
> Sent: Tuesday, April 9, 2024 1:39 AM
>
> Hi Jacob,
>
> On Mon, 8 Apr 2024 09:05:56 -0700, Jacob Pan
> <jacob.jun.pan@xxxxxxxxxxxxxxx> wrote:
>
> > Hi Kevin,
> >
> > On Mon, 8 Apr 2024 08:48:54 +0000, "Tian, Kevin" <kevin.tian@xxxxxxxxx>
> > wrote:
> >
> > > > From: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
> > > > Sent: Thursday, April 4, 2024 7:46 AM
> > > >
> > > > @@ -1182,7 +1182,6 @@ static void free_iommu(struct intel_iommu
> > > > *iommu)
> > > > iommu->pr_irq = 0;
> > > > }
> > > > free_irq(iommu->fault_irq, iommu);
> > > > - dmar_free_hwirq(iommu->fault_irq);
> > >
> > > You still want to free the vector for the iommu which first gets the
> > > vector allocated.
> > >
> > I think we always want to keep this vector since the system always needs
> > one vector to share. We will never offline all the IOMMUs, right?

Not about offline. Just about the common rule of cleaning up a resource
when all of its users are destroyed.

> > > > +
> > > > + /*
> > > > + * Only the owner IOMMU of the shared IRQ has its fault event
> > > > + * interrupt unmasked after request_irq(), the rest are
> > > > explicitly
> > > > + * unmasked.
> > > > + */
> > > > + if (!(iommu->flags & VTD_FLAG_FAULT_IRQ_OWNER))
> > > > + dmar_fault_irq_unmask(iommu);
> > > > +
> > >
> > > em there is a problem in dmar_msi_mask() and dmar_msi_mask()
> > > which only touches the owner IOMMU. With this shared vector
> > > approach we should mask/unmask all IOMMU's together.
> > I thought about this as well, in addition to fault_irq,
> > dmar_msi_mask/unmask() are used for other DMAR irqs, page request and
> > perfmon. So we need a special case for fault_irq there, it is not pretty.

yes, that is the part which I don't really like.

> >
> > I added a special case here in this patch, thinking we never mask the
> > fault_irq since we need to cover the lifetime of the system. I have looked
> > at:
> > 1.IOMMU suspend/resume, no mask/unmask
> Actually, we do call mask/unmask in suspend/unmask noirq phase.
> And DMAR-MSI chip has IRQCHIP_SKIP_SET_WAKE flag.
>
> So you are right, I am missing this case where non-owner IOMMU's fault_irqs
> are not masked/unmasked.
>

and it's not good to code a mask/unmask callback upon fixed assumptions
on when irq core may call mask/unmask as the latter part can change
w/o noting the broken assumption in such callback.