2022-05-07 10:44:06

by Ricardo Neri

[permalink] [raw]
Subject: [PATCH v6 10/29] iommu/vt-d: Implement minor tweaks for NMI irqs

The Intel IOMMU interrupt remapping driver already programs correctly the
delivery mode of individual irqs as per their irq_data. Improve handling
of NMIs. Allow only one irq per NMI. Also, it is not necessary to cleanup
irq vectors after updating affinity. NMIs do not have associated vectors.

Cc: Andi Kleen <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: "Ravi V. Shankar" <[email protected]>
Cc: Lu Baolu <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Reviewed-by: Lu Baolu <[email protected]>
Signed-off-by: Ricardo Neri <[email protected]>
---
Changes since v5:
* Introduced this patch.

Changes since v4:
* N/A

Changes since v3:
* N/A

Changes since v2:
* N/A

Changes since v1:
* N/A
---
drivers/iommu/intel/irq_remapping.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
index fb2d71bea98d..791a9331e257 100644
--- a/drivers/iommu/intel/irq_remapping.c
+++ b/drivers/iommu/intel/irq_remapping.c
@@ -1198,8 +1198,12 @@ intel_ir_set_affinity(struct irq_data *data, const struct cpumask *mask,
* After this point, all the interrupts will start arriving
* at the new destination. So, time to cleanup the previous
* vector allocation.
+ *
+ * Do it only for non-NMI irqs. NMIs don't have associated
+ * vectors.
*/
- send_cleanup_vector(cfg);
+ if (cfg->delivery_mode != APIC_DELIVERY_MODE_NMI)
+ send_cleanup_vector(cfg);

return IRQ_SET_MASK_OK_DONE;
}
@@ -1352,6 +1356,9 @@ static int intel_irq_remapping_alloc(struct irq_domain *domain,
if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI)
info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS;

+ if ((info->flags & X86_IRQ_ALLOC_AS_NMI) && nr_irqs != 1)
+ return -EINVAL;
+
ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg);
if (ret < 0)
return ret;
--
2.17.1



2022-05-07 15:03:48

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH v6 10/29] iommu/vt-d: Implement minor tweaks for NMI irqs

On Thu, May 05 2022 at 16:59, Ricardo Neri wrote:
> The Intel IOMMU interrupt remapping driver already programs correctly the
> delivery mode of individual irqs as per their irq_data. Improve handling
> of NMIs. Allow only one irq per NMI. Also, it is not necessary to cleanup
> irq vectors after updating affinity.

Structuring a changelog in paragraphs might make it readable. New lines
exist for a reason.

> NMIs do not have associated vectors.

Again. NMI has an vector associated, but it is not subject to dynamic
vector management.

> diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
> index fb2d71bea98d..791a9331e257 100644
> --- a/drivers/iommu/intel/irq_remapping.c
> +++ b/drivers/iommu/intel/irq_remapping.c
> @@ -1198,8 +1198,12 @@ intel_ir_set_affinity(struct irq_data *data, const struct cpumask *mask,
> * After this point, all the interrupts will start arriving
> * at the new destination. So, time to cleanup the previous
> * vector allocation.
> + *
> + * Do it only for non-NMI irqs. NMIs don't have associated
> + * vectors.

See above.

> */
> - send_cleanup_vector(cfg);
> + if (cfg->delivery_mode != APIC_DELIVERY_MODE_NMI)
> + send_cleanup_vector(cfg);

So this needs to be replicated for all invocations of
send_cleanup_vector(), right? Why can't you put it into that function?

> return IRQ_SET_MASK_OK_DONE;
> }
> @@ -1352,6 +1356,9 @@ static int intel_irq_remapping_alloc(struct irq_domain *domain,
> if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI)
> info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS;
>
> + if ((info->flags & X86_IRQ_ALLOC_AS_NMI) && nr_irqs != 1)
> + return -EINVAL;

This cannot be reached when the vector allocation domain already
rejected it, but copy & pasta is wonderful and increases the line count.

Thanks,

tglx



2022-05-14 00:31:11

by Ricardo Neri

[permalink] [raw]
Subject: Re: [PATCH v6 10/29] iommu/vt-d: Implement minor tweaks for NMI irqs

On Fri, May 06, 2022 at 11:23:23PM +0200, Thomas Gleixner wrote:
> On Thu, May 05 2022 at 16:59, Ricardo Neri wrote:
> > The Intel IOMMU interrupt remapping driver already programs correctly the
> > delivery mode of individual irqs as per their irq_data. Improve handling
> > of NMIs. Allow only one irq per NMI. Also, it is not necessary to cleanup
> > irq vectors after updating affinity.
>
> Structuring a changelog in paragraphs might make it readable. New lines
> exist for a reason.

Sure, I can structure this in paragraphps.
>
> > NMIs do not have associated vectors.
>
> Again. NMI has an vector associated, but it is not subject to dynamic
> vector management.

Indeed, it is clear to me now.

>
> > diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
> > index fb2d71bea98d..791a9331e257 100644
> > --- a/drivers/iommu/intel/irq_remapping.c
> > +++ b/drivers/iommu/intel/irq_remapping.c
> > @@ -1198,8 +1198,12 @@ intel_ir_set_affinity(struct irq_data *data, const struct cpumask *mask,
> > * After this point, all the interrupts will start arriving
> > * at the new destination. So, time to cleanup the previous
> > * vector allocation.
> > + *
> > + * Do it only for non-NMI irqs. NMIs don't have associated
> > + * vectors.
>
> See above.

Sure.

>
> > */
> > - send_cleanup_vector(cfg);
> > + if (cfg->delivery_mode != APIC_DELIVERY_MODE_NMI)
> > + send_cleanup_vector(cfg);
>
> So this needs to be replicated for all invocations of
> send_cleanup_vector(), right? Why can't you put it into that function?

Certainly, it can be done inside the function.

>
> > return IRQ_SET_MASK_OK_DONE;
> > }
> > @@ -1352,6 +1356,9 @@ static int intel_irq_remapping_alloc(struct irq_domain *domain,
> > if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI)
> > info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS;
> >
> > + if ((info->flags & X86_IRQ_ALLOC_AS_NMI) && nr_irqs != 1)
> > + return -EINVAL;
>
> This cannot be reached when the vector allocation domain already
> rejected it, but copy & pasta is wonderful and increases the line count.

Yes, this is not needed.

Thanks and BR,
Ricardo
>
> Thanks,
>
> tglx
>
>