Add functionality to allocate interrupt lines that will deliver IRQs as Non-Maskable Interrupts. These allocations are only successful if the irqchip provides the necessary support and allows NMI delivery for the interrupt line. Interrupt lines allocated for NMI delivery must be enabled/disabled through enable_nmi/disable_nmi_nosync to keep their state consistent. To treat a PERCPU IRQ as NMI, the interrupt must not be shared nor threaded, the irqchip directly managing the IRQ must be the root irqchip and the irqchip cannot be behind a slow bus.
Showing the changes to include/linux (2 of 5 files). Show all
Unified · Split
| @@ -156,6 +156,10 @@ __request_percpu_irq(unsigned int irq, irq_handler_t handler, · 155 unmodified lines | ||
| 156 | 156 | unsigned long flags, const char *devname, |
| 157 | 157 | void __percpu *percpu_dev_id); |
| 158 | 158 | |
| 159 | +extern int __must_check | |
| 160 | +request_nmi(unsigned int irq, irq_handler_t handler, unsigned long flags, | |
| 161 | + const char *name, void *dev); | |
| 162 | + | |
| 159 | 163 | static inline int __must_check |
| 160 | 164 | request_percpu_irq(unsigned int irq, irq_handler_t handler, |
| 161 | 165 | const char *devname, void __percpu *percpu_dev_id) |
| @@ -167,6 +171,8 @@ request_percpu_irq(unsigned int irq, irq_handler_t handler, · 5 unmodified lines | ||
| 167 | 171 | extern const void *free_irq(unsigned int, void *); |
| 168 | 172 | extern void free_percpu_irq(unsigned int, void __percpu *); |
| 169 | 173 | |
| 174 | +extern const void *free_nmi(unsigned int irq, void *dev_id); | |
| 175 | + | |
| 170 | 176 | struct device; |
| 171 | 177 | |
| 172 | 178 | extern int __must_check |
| @@ -217,6 +223,9 @@ extern void enable_percpu_irq(unsigned int irq, unsigned int type); · 44 unmodified lines | ||
| 217 | 223 | extern bool irq_percpu_is_enabled(unsigned int irq); |
| 218 | 224 | extern void irq_wake_thread(unsigned int irq, void *dev_id); |
| 219 | 225 | |
| 226 | +extern void disable_nmi_nosync(unsigned int irq); | |
| 227 | +extern void enable_nmi(unsigned int irq); | |
| 228 | + | |
| 220 | 229 | /* The following three functions are for the core kernel use only. */ |
| 221 | 230 | extern void suspend_device_irqs(void); |
| 222 | 231 | extern void resume_device_irqs(void); |
| @@ -442,6 +442,8 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) · 441 unmodified lines | ||
| 442 | 442 | * @irq_set_vcpu_affinity: optional to target a vCPU in a virtual machine |
| 443 | 443 | * @ipi_send_single: send a single IPI to destination cpus |
| 444 | 444 | * @ipi_send_mask: send an IPI to destination cpus in cpumask |
| 445 | + * @irq_nmi_setup: function called from core code before enabling an NMI | |
| 446 | + * @irq_nmi_teardown: function called from core code after disabling an NMI | |
| 445 | 447 | * @flags: chip specific flags |
| 446 | 448 | */ |
| 447 | 449 | struct irq_chip { |
| @@ -490,6 +492,9 @@ struct irq_chip { · 42 unmodified lines | ||
| 490 | 492 | void (*ipi_send_single)(struct irq_data *data, unsigned int cpu); |
| 491 | 493 | void (*ipi_send_mask)(struct irq_data *data, const struct cpumask *dest); |
| 492 | 494 | |
| 495 | + int (*irq_nmi_setup)(struct irq_data *data); | |
| 496 | + void (*irq_nmi_teardown)(struct irq_data *data); | |
| 497 | + | |
| 493 | 498 | unsigned long flags; |
| 494 | 499 | }; |
| 495 | 500 | |
| @@ -505,6 +510,7 @@ struct irq_chip { · 9 unmodified lines | ||
| 505 | 510 | * IRQCHIP_ONESHOT_SAFE: One shot does not require mask/unmask |
| 506 | 511 | * IRQCHIP_EOI_THREADED: Chip requires eoi() on unmask in threaded mode |
| 507 | 512 | * IRQCHIP_SUPPORTS_LEVEL_MSI Chip can provide two doorbells for Level MSIs |
| 513 | + * IRQCHIP_SUPPORTS_NMI: Chip can deliver NMIs, only for root irqchips | |
| 508 | 514 | */ |
| 509 | 515 | enum { |
| 510 | 516 | IRQCHIP_SET_TYPE_MASKED = (1 << 0), |
| @@ -515,6 +521,7 @@ enum { · 4 unmodified lines | ||
| 515 | 521 | IRQCHIP_ONESHOT_SAFE = (1 << 5), |
| 516 | 522 | IRQCHIP_EOI_THREADED = (1 << 6), |
| 517 | 523 | IRQCHIP_SUPPORTS_LEVEL_MSI = (1 << 7), |
| 524 | + IRQCHIP_SUPPORTS_NMI = (1 << 8), | |
| 518 | 525 | }; |
| 519 | 526 | |
| 520 | 527 | #include <linux/irqdesc.h> |