The flag X86_IRQ_ALLOC_AS_NMI indicates to the interrupt controller that
it should configure the delivery mode of an IRQ as NMI. Implement such
request. This causes irq_domain children in the hierarchy to configure
their irq_chips accordingly. When no specific delivery mode is requested,
continue using the delivery mode of the APIC driver in use.

Cc: Andi Kleen <a...@linux.intel.com>
Cc: "Ravi V. Shankar" <ravi.v.shan...@intel.com>
Cc: Stephane Eranian <eran...@google.com>
Cc: io...@lists.linux-foundation.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: x...@kernel.org
Suggested-by: Thomas Gleixner <t...@linutronix.de>
Reviewed-by: Tony Luck <tony.l...@intel.com>
Signed-off-by: Ricardo Neri <ricardo.neri-calde...@linux.intel.com>
---
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
---
 arch/x86/kernel/apic/vector.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 11f881f45cec..df4d7b9f6e27 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -570,6 +570,10 @@ static int x86_vector_alloc_irqs(struct irq_domain 
*domain, unsigned int virq,
        if ((info->flags & X86_IRQ_ALLOC_CONTIGUOUS_VECTORS) && nr_irqs > 1)
                return -ENOSYS;
 
+       /* Only one IRQ per NMI */
+       if ((info->flags & X86_IRQ_ALLOC_AS_NMI) && nr_irqs != 1)
+               return -EINVAL;
+
        /*
         * Catch any attempt to touch the cascade interrupt on a PIC
         * equipped system.
@@ -610,7 +614,15 @@ static int x86_vector_alloc_irqs(struct irq_domain 
*domain, unsigned int virq,
                 * default delivery mode of the APIC. Children irq domains
                 * may take the delivery mode from the individual irq
                 * configuration rather than from the APIC driver.
+                *
+                * Vectors are meaningless if the delivery mode is NMI. Since
+                * nr_irqs is 1, we can return.
                 */
+               if (info->flags & X86_IRQ_ALLOC_AS_NMI) {
+                       apicd->hw_irq_cfg.delivery_mode = 
APIC_DELIVERY_MODE_NMI;
+                       return 0;
+               }
+
                apicd->hw_irq_cfg.delivery_mode = apic->delivery_mode;
 
                /*
-- 
2.17.1

Reply via email to