Provide core API for NMIs
v2 cover Provide core API for NMIs
Hi,
This patch series provides a way for irqchips to define some IRQs as NMIs.
For this to be possible, the irqchip must:
- be a root irqchip
- not require bus locking
- have the NMI support flag
Once these conditions are met, interrupt lines can be requested as NMIs. These lines must not be shared and the IRQ handling must not be threaded. Callbacks are added to the irqchip in order to set up (clean up) the necessary resources for NMIs before enabling (before releasing) the corresponding interrupt line.
I'll soon post a series making use of the API for Arm's GICv3.
Patches 1 & 2 provide functions necessary to request and manage NMIs. Patches 3 & 4 provide functions for NMI handling.
Changes since v1[1]:
- Rebased to v4.19-rc1
- Fix some coding style issues
Changes since RFC[2]:
- Rebased to v4.18-rc6
- Remove disable_nmi, one should call disable_nmi_nosync instead
- Remove code related to affinity balancing from NMI functions
- Require PERCPU configuration for NMIs
[1] https://lkml.org/lkml/2018/7/24/321
[2] https://lkml.org/lkml/2018/7/9/768
Cheers,
Julien
-->
Julien Thierry (4):
genirq: Provide basic NMI management for interrupt lines
genirq: Provide NMI management for percpu_devid interrupts
genirq: Provide NMI handlers
irqdesc: Add domain handler for NMIs
include/linux/interrupt.h | 18 +++ include/linux/irq.h | 10 ++ include/linux/irqdesc.h | 3 + kernel/irq/chip.c | 54 +++++++ kernel/irq/debugfs.c | 6 +- kernel/irq/internals.h | 2 + kernel/irq/irqdesc.c | 33 ++++ kernel/irq/manage.c | 377 +++++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 500 insertions(+), 3 deletions(-)
--
1.9.1
PATCH v2 1/4 genirq: Provide basic NMI management for interrupt lines
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.
--- include/linux/interrupt.h | 9 ++ include/linux/irq.h | 7 ++ kernel/irq/debugfs.c | 6 +- kernel/irq/internals.h | 2 + kernel/irq/manage.c | 228 +++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 249 insertions(+), 3 deletions(-)
include/linux/interrupt.h +9 -0
@@ -156,6 +156,10 @@ struct irqaction { unsigned long flags, const char *devname, void __percpu *percpu_dev_id); +extern int __must_check +request_nmi (unsigned int irq,irq_handler_t handler,unsigned long flags, +const char *name,void *dev); +static inline int __must_check request_percpu_irq (unsigned int irq,irq_handler_t handler,const char *devname,void __percpu *percpu_dev_id)
@@ -167,6 +171,8 @@ struct irqaction {extern const void *free_irq (unsigned int ,void *);extern void free_percpu_irq (unsigned int ,void __percpu *); +extern const void *free_nmi (unsigned int irq,void *dev_id); +struct device ; extern int __must_check
@@ -217,6 +223,9 @@ struct irqaction {extern bool irq_percpu_is_enabled (unsigned int irq);extern void irq_wake_thread (unsigned int irq,void *dev_id); +extern void disable_nmi_nosync (unsigned int irq); +extern void enable_nmi (unsigned int irq); +/* The following three functions are for the core kernel use only. */ extern void suspend_device_irqs (void );extern void resume_device_irqs (void );
include/linux/irq.h +7 -0
@@ -441,6 +441,8 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)* @irq_set_vcpu_affinity: optional to target a vCPU in a virtual machine * @ipi_send_single: send a single IPI to destination cpus * @ipi_send_mask: send an IPI to destination cpus in cpumask +* @irq_nmi_setup: function called from core code before enabling an NMI +* @irq_nmi_teardown: function called from core code after disabling an NMI * @flags: chip specific flags */ struct irq_chip {
@@ -489,6 +491,9 @@ struct irq_chip {void (*ipi_send_single)(struct irq_data *data,unsigned int cpu);void (*ipi_send_mask)(struct irq_data *data,const struct cpumask *dest); +int (*irq_nmi_setup)(struct irq_data *data); +void (*irq_nmi_teardown)(struct irq_data *data); +unsigned long flags; };
@@ -504,6 +509,7 @@ struct irq_chip {* IRQCHIP_ONESHOT_SAFE: One shot does not require mask/unmask * IRQCHIP_EOI_THREADED: Chip requires eoi() on unmask in threaded mode * IRQCHIP_SUPPORTS_LEVEL_MSI Chip can provide two doorbells for Level MSIs +* IRQCHIP_SUPPORTS_NMI: Chip can deliver NMIs, only for root irqchips */ enum {IRQCHIP_SET_TYPE_MASKED = (1 <<0 ),
@@ -514,6 +520,7 @@ enum {IRQCHIP_ONESHOT_SAFE = (1 <<5 ),IRQCHIP_EOI_THREADED = (1 <<6 ),IRQCHIP_SUPPORTS_LEVEL_MSI = (1 <<7 ), + IRQCHIP_SUPPORTS_NMI = (1 << 8), };#include <linux/irqdesc.h>
kernel/irq/debugfs.c +4 -2
@@ -56,6 +56,7 @@ static void irq_debug_show_masks(struct seq_file *m, struct irq_desc *desc) { }BIT_MASK_DESCR (IRQCHIP_ONESHOT_SAFE ),BIT_MASK_DESCR (IRQCHIP_EOI_THREADED ),BIT_MASK_DESCR (IRQCHIP_SUPPORTS_LEVEL_MSI ), + BIT_MASK_DESCR(IRQCHIP_SUPPORTS_NMI), }; static void
@@ -140,6 +141,7 @@ static void irq_debug_show_masks(struct seq_file *m, struct irq_desc *desc) { }BIT_MASK_DESCR (IRQS_WAITING ),BIT_MASK_DESCR (IRQS_PENDING ),BIT_MASK_DESCR (IRQS_SUSPENDED ), + BIT_MASK_DESCR(IRQS_NMI), };
@@ -203,8 +205,8 @@ static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,chip_bus_lock (desc);raw_spin_lock_irqsave (&desc->lock, flags); -if (irq_settings_is_level (desc)) { -/* Can't do level, sorry */ +if (irq_settings_is_level (desc) || desc->istate &IRQS_NMI ) { +/* Can't do level nor NMIs, sorry */ err = -EINVAL ; }else { desc->istate |=IRQS_PENDING ;
kernel/irq/internals.h +2 -0
@@ -49,6 +49,7 @@ enum {* IRQS_WAITING - irq is waiting * IRQS_PENDING - irq is pending and replayed later * IRQS_SUSPENDED - irq is suspended +* IRQS_NMI - irq line is used to deliver NMIs */ enum {IRQS_AUTODETECT =0x00000001 ,
@@ -60,6 +61,7 @@ enum {IRQS_PENDING =0x00000200 ,IRQS_SUSPENDED =0x00000800 ,IRQS_TIMINGS =0x00001000 , + IRQS_NMI = 0x00002000, };#include "debug.h"
kernel/irq/manage.c +227 -1
285 lines not on this page · raw message
Signature · 1 line
1.9.1
kbuild test robot
build botRe: [PATCH v2 1/4] genirq: Provide basic NMI management for interrupt lines
Thank you for the patch! Perhaps something to improve:
Hi Julien,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v4.19-rc1 next-20180828]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Julien-Thierry/genirq-Provide-basic-NMI-management-for-interrupt-lines/20180829-063713
reproduce: make htmldocs
All warnings (new ones prefixed by >>):
WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick (https://www.imagemagick.org)
>> kernel/irq/manage.c:2080: warning: Function parameter or member 'irqflags' not described in 'request_nmi'
kernel/irq/manage.c:2080: warning: Excess function parameter 'flags' description in 'request_nmi' kernel/irq/manage.c:2081: warning: Excess function parameter 'flags' description in 'request_nmi' include/linux/srcu.h:175: warning: Function parameter or member 'p' not described in 'srcu_dereference_notrace' include/linux/srcu.h:175: warning: Function parameter or member 'sp' not described in 'srcu_dereference_notrace' include/linux/gfp.h:1: warning: no structured comments found
include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ibss' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.connect' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.keys' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ie' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ie_len' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.bssid' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ssid' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.default_key' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.default_mgmt_key' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.prev_bssid_valid' not described in 'wireless_dev' include/net/mac80211.h:2328: warning: Function parameter or member 'radiotap_timestamp.units_pos' not described in 'ieee80211_hw' include/net/mac80211.h:2328: warning: Function parameter or member 'radiotap_timestamp.accuracy' not described in 'ieee80211_hw' include/net/mac80211.h:977: warning: Function parameter or member 'control.rates' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.rts_cts_rate_idx' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.use_rts' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.use_cts_prot' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.short_preamble' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.skip_table' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.jiffies' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.vif' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.hw_key' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.flags' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.enqueue_time' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'ack' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'ack.cookie' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.rates' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.ack_signal' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.ampdu_ack_len' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.ampdu_len' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.antenna' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.tx_time' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.is_valid_ack_signal' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.status_driver_data' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'driver_rates' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'pad' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'rate_driver_data' not described in 'ieee80211_tx_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'rx_stats_avg' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'rx_stats_avg.signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'rx_stats_avg.chain_signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.filtered' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.retry_failed' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.retry_count' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.lost_packets' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.last_tdls_pkt_time' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.msdu_retries' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.msdu_failed' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.last_ack' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.last_ack_signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.ack_signal_filled' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.avg_ack_signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.packets' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.bytes' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.last_rate' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.msdu' not described in 'sta_info' include/linux/mod_devicetable.h:763: warning: Function parameter or member 'driver_data' not described in 'typec_device_id' kernel/sched/fair.c:3371: warning: Function parameter or member 'flags' not described in 'attach_entity_load_avg' arch/x86/include/asm/atomic.h:84: warning: Excess function parameter 'i' description in 'arch_atomic_sub_and_test' arch/x86/include/asm/atomic.h:84: warning: Excess function parameter 'v' description in 'arch_atomic_sub_and_test' arch/x86/include/asm/atomic.h:96: warning: Excess function parameter 'v' description in 'arch_atomic_inc' arch/x86/include/asm/atomic.h:109: warning: Excess function parameter 'v' description in 'arch_atomic_dec' arch/x86/include/asm/atomic.h:124: warning: Excess function parameter 'v' description in 'arch_atomic_dec_and_test' arch/x86/include/asm/atomic.h:138: warning: Excess function parameter 'v' description in 'arch_atomic_inc_and_test' arch/x86/include/asm/atomic.h:153: warning: Excess function parameter 'i' description in 'arch_atomic_add_negative' arch/x86/include/asm/atomic.h:153: warning: Excess function parameter 'v' description in 'arch_atomic_add_negative' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_excl.cb' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_excl.poll' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_excl.active' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_shared.cb' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_shared.poll' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_shared.active' not described in 'dma_buf' include/linux/dma-fence-array.h:54: warning: Function parameter or member 'work' not described in 'dma_fence_array' include/linux/gpio/driver.h:142: warning: Function parameter or member 'request_key' not described in 'gpio_irq_chip' include/linux/iio/hw-consumer.h:1: warning: no structured comments found include/linux/input/sparse-keymap.h:46: warning: Function parameter or member 'sw' not described in 'key_entry' drivers/pci/pci.c:218: warning: Excess function parameter 'p' description in 'pci_dev_str_match_path' include/linux/regulator/driver.h:227: warning: Function parameter or member 'resume' not described in 'regulator_ops' drivers/regulator/core.c:4479: warning: Excess function parameter 'state' description in 'regulator_suspend' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw0' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw1' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw2' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw3' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.eadm' not described in 'irb' drivers/slimbus/stream.c:1: warning: no structured comments found
drivers/target/target_core_device.c:1: warning: no structured comments found
drivers/usb/dwc3/gadget.c:510: warning: Excess function parameter 'dwc' description in 'dwc3_gadget_start_config' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode'
vim +2080 kernel/irq/manage.c
2051
2052 /**
2053 * request_nmi - allocate an interrupt line for NMI delivery
2054 * @irq: Interrupt line to allocate
2055 * @handler: Function to be called when the IRQ occurs.
2056 * Threaded handler for threaded interrupts.
2057 * @flags: Interrupt type flags
2058 * @name: An ascii name for the claiming device
2059 * @dev_id: A cookie passed back to the handler function
2060 *
2061 * This call allocates interrupt resources and enables the
2062 * interrupt line and IRQ handling. It sets up the IRQ line
2063 * to be handled as an NMI.
2064 *
2065 * An interrupt line delivering NMIs cannot be shared and IRQ handling
2066 * cannot be threaded.
2067 *
2068 * Interrupt lines requested for NMI delivering must produce per cpu
2069 * interrupts and have auto enabling setting disabled.
2070 *
2071 * Dev_id must be globally unique. Normally the address of the
2072 * device data structure is used as the cookie. Since the handler
2073 * receives this value it makes sense to use it.
2074 *
2075 * If the interrupt line cannot be used to deliver NMIs, function
2076 * will fail and return a negative value.
2077 */
2078 int request_nmi(unsigned int irq, irq_handler_t handler,
2079 unsigned long irqflags, const char *name, void *dev_id)
> 2080 {
2081 struct irqaction *action;
2082 struct irq_desc *desc;
2083 unsigned long flags;
2084 int retval;
2085
2086 if (irq == IRQ_NOTCONNECTED)
2087 return -ENOTCONN;
2088
2089 /* NMI cannot be shared, used for Polling */
2090 if (irqflags & (IRQF_SHARED | IRQF_COND_SUSPEND | IRQF_IRQPOLL))
2091 return -EINVAL;
2092
2093 if (!(irqflags & IRQF_PERCPU))
2094 return -EINVAL;
2095
2096 if (!handler)
2097 return -EINVAL;
2098
2099 desc = irq_to_desc(irq);
2100
2101 if (!desc || irq_settings_can_autoenable(desc) ||
2102 !irq_settings_can_request(desc) ||
2103 WARN_ON(irq_settings_is_per_cpu_devid(desc)) ||
2104 !irq_supports_nmi(desc)) 2105 return -EINVAL;
2106
2107 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
2108 if (!action)
2109 return -ENOMEM;
2110
2111 action->handler = handler;
2112 action->flags = irqflags | IRQF_NO_THREAD | IRQF_NOBALANCING;
2113 action->name = name;
2114 action->dev_id = dev_id;
2115
2116 retval = irq_chip_pm_get(&desc->irq_data);
2117 if (retval < 0)
2118 goto err_out;
2119
2120 retval = __setup_irq(irq, desc, action);
2121 if (retval)
2122 goto err_irq_setup;
2123
2124 raw_spin_lock_irqsave(&desc->lock, flags);
2125
2126 /* Setup NMI state */
2127 desc->istate |= IRQS_NMI;
2128 retval = irq_nmi_setup(desc);
2129 if (retval) {
2130 __cleanup_nmi(irq, desc);
2131 raw_spin_unlock_irqrestore(&desc->lock, flags);
2132 return -EINVAL;
2133 }
2134
2135 raw_spin_unlock_irqrestore(&desc->lock, flags);
2136
2137 return 0;
2138
2139 err_irq_setup:
2140 irq_chip_pm_put(&desc->irq_data);
2141 err_out:
2142 kfree(action);
2143
2144 return retval;
2145 }
2146
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 2/4 genirq: Provide NMI management for percpu_devid interrupts
In reply to Julien ThierryAdd support for percpu_devid interrupts treated as NMIs.
Percpu_devid NMIs need to be setup/torn down on each CPU they target.
The same restrictions as for global NMIs still apply for percpu_devid NMIs.
--- include/linux/interrupt.h | 9 +++ kernel/irq/manage.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+)
include/linux/interrupt.h +9 -0
@@ -168,10 +168,15 @@ struct irqaction { devname, percpu_dev_id); } +extern int __must_check +request_percpu_nmi (unsigned int irq,irq_handler_t handler, +const char *devname,void __percpu *dev); +extern const void *free_irq (unsigned int ,void *);extern void free_percpu_irq (unsigned int ,void __percpu *);extern const void *free_nmi (unsigned int irq,void *dev_id); +extern void free_percpu_nmi (unsigned int irq,void __percpu *percpu_dev_id);struct device ;
@@ -224,7 +229,11 @@ struct irqaction {extern void irq_wake_thread (unsigned int irq,void *dev_id);extern void disable_nmi_nosync (unsigned int irq); +extern void disable_percpu_nmi (unsigned int irq);extern void enable_nmi (unsigned int irq); +extern void enable_percpu_nmi (unsigned int irq,unsigned int type); +extern int ready_percpu_nmi (unsigned int irq); +extern void teardown_percpu_nmi (unsigned int irq);/* The following three functions are for the core kernel use only. */ extern void suspend_device_irqs (void );
kernel/irq/manage.c +149 -0
179 lines not on this page · raw message
Signature · 1 line
1.9.1
kbuild test robot
build botRe: [PATCH v2 2/4] genirq: Provide NMI management for percpu_devid interrupts
Thank you for the patch! Perhaps something to improve:
Hi Julien,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v4.19-rc1 next-20180829]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Julien-Thierry/genirq-Provide-basic-NMI-management-for-interrupt-lines/20180829-063713
reproduce: make htmldocs
All warnings (new ones prefixed by >>):
WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick (https://www.imagemagick.org)
kernel/irq/manage.c:2080: warning: Function parameter or member 'irqflags' not described in 'request_nmi' kernel/irq/manage.c:2080: warning: Excess function parameter 'flags' description in 'request_nmi'
>> kernel/irq/manage.c:2442: warning: Function parameter or member 'name' not described in 'request_percpu_nmi'
kernel/irq/manage.c:2442: warning: Excess function parameter 'devname' description in 'request_percpu_nmi' kernel/irq/manage.c:2081: warning: Excess function parameter 'flags' description in 'request_nmi' kernel/irq/manage.c:2443: warning: Excess function parameter 'devname' description in 'request_percpu_nmi' include/linux/srcu.h:175: warning: Function parameter or member 'p' not described in 'srcu_dereference_notrace' include/linux/srcu.h:175: warning: Function parameter or member 'sp' not described in 'srcu_dereference_notrace' include/linux/gfp.h:1: warning: no structured comments found
include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ibss' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.connect' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.keys' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ie' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ie_len' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.bssid' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.ssid' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.default_key' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.default_mgmt_key' not described in 'wireless_dev' include/net/cfg80211.h:4381: warning: Function parameter or member 'wext.prev_bssid_valid' not described in 'wireless_dev' include/net/mac80211.h:2328: warning: Function parameter or member 'radiotap_timestamp.units_pos' not described in 'ieee80211_hw' include/net/mac80211.h:2328: warning: Function parameter or member 'radiotap_timestamp.accuracy' not described in 'ieee80211_hw' include/net/mac80211.h:977: warning: Function parameter or member 'control.rates' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.rts_cts_rate_idx' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.use_rts' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.use_cts_prot' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.short_preamble' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.skip_table' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.jiffies' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.vif' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.hw_key' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.flags' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'control.enqueue_time' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'ack' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'ack.cookie' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.rates' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.ack_signal' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.ampdu_ack_len' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.ampdu_len' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.antenna' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.tx_time' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.is_valid_ack_signal' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'status.status_driver_data' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'driver_rates' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'pad' not described in 'ieee80211_tx_info' include/net/mac80211.h:977: warning: Function parameter or member 'rate_driver_data' not described in 'ieee80211_tx_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'rx_stats_avg' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'rx_stats_avg.signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'rx_stats_avg.chain_signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.filtered' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.retry_failed' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.retry_count' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.lost_packets' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.last_tdls_pkt_time' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.msdu_retries' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.msdu_failed' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.last_ack' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.last_ack_signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.ack_signal_filled' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'status_stats.avg_ack_signal' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.packets' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.bytes' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.last_rate' not described in 'sta_info' net/mac80211/sta_info.h:588: warning: Function parameter or member 'tx_stats.msdu' not described in 'sta_info' include/linux/mod_devicetable.h:763: warning: Function parameter or member 'driver_data' not described in 'typec_device_id' kernel/sched/fair.c:3371: warning: Function parameter or member 'flags' not described in 'attach_entity_load_avg' arch/x86/include/asm/atomic.h:84: warning: Excess function parameter 'i' description in 'arch_atomic_sub_and_test' arch/x86/include/asm/atomic.h:84: warning: Excess function parameter 'v' description in 'arch_atomic_sub_and_test' arch/x86/include/asm/atomic.h:96: warning: Excess function parameter 'v' description in 'arch_atomic_inc' arch/x86/include/asm/atomic.h:109: warning: Excess function parameter 'v' description in 'arch_atomic_dec' arch/x86/include/asm/atomic.h:124: warning: Excess function parameter 'v' description in 'arch_atomic_dec_and_test' arch/x86/include/asm/atomic.h:138: warning: Excess function parameter 'v' description in 'arch_atomic_inc_and_test' arch/x86/include/asm/atomic.h:153: warning: Excess function parameter 'i' description in 'arch_atomic_add_negative' arch/x86/include/asm/atomic.h:153: warning: Excess function parameter 'v' description in 'arch_atomic_add_negative' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_excl.cb' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_excl.poll' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_excl.active' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_shared.cb' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_shared.poll' not described in 'dma_buf' include/linux/dma-buf.h:304: warning: Function parameter or member 'cb_shared.active' not described in 'dma_buf' include/linux/dma-fence-array.h:54: warning: Function parameter or member 'work' not described in 'dma_fence_array' include/linux/gpio/driver.h:142: warning: Function parameter or member 'request_key' not described in 'gpio_irq_chip' include/linux/iio/hw-consumer.h:1: warning: no structured comments found include/linux/input/sparse-keymap.h:46: warning: Function parameter or member 'sw' not described in 'key_entry' drivers/pci/pci.c:218: warning: Excess function parameter 'p' description in 'pci_dev_str_match_path' include/linux/regulator/driver.h:227: warning: Function parameter or member 'resume' not described in 'regulator_ops' drivers/regulator/core.c:4479: warning: Excess function parameter 'state' description in 'regulator_suspend' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw0' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw1' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw2' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw3' not described in 'irb' arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.eadm' not described in 'irb' drivers/slimbus/stream.c:1: warning: no structured comments found
drivers/target/target_core_device.c:1: warning: no structured comments found
drivers/usb/dwc3/gadget.c:510: warning: Excess function parameter 'dwc' description in 'dwc3_gadget_start_config' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode'
vim +2442 kernel/irq/manage.c
2417
2418 /**
2419 * request_percpu_nmi - allocate a percpu interrupt line for NMI delivery
2420 * @irq: Interrupt line to allocate
2421 * @handler: Function to be called when the IRQ occurs.
2422 * @devname: An ascii name for the claiming device
2423 * @dev_id: A percpu cookie passed back to the handler function
2424 *
2425 * This call allocates interrupt resources and enables the
2426 * interrupt on the local CPU. If the interrupt is supposed to be
2427 * enabled on other CPUs, it has to be done on each CPU using
2428 * enable_percpu_nmi().
2429 *
2430 * Dev_id must be globally unique. It is a per-cpu variable, and
2431 * the handler gets called with the interrupted CPU's instance of
2432 * that variable.
2433 *
2434 * Interrupt lines requested for NMI delivering should have auto enabling
2435 * setting disabled.
2436 *
2437 * If the interrupt line cannot be used to deliver NMIs, function
2438 * will fail returning a negative value.
2439 */
2440 int request_percpu_nmi(unsigned int irq, irq_handler_t handler,
2441 const char *name, void __percpu *dev_id)
> 2442 {
2443 struct irqaction *action;
2444 struct irq_desc *desc;
2445 unsigned long flags;
2446 int retval;
2447
2448 if (!handler)
2449 return -EINVAL;
2450
2451 desc = irq_to_desc(irq);
2452
2453 if (!desc || !irq_settings_can_request(desc) ||
2454 !irq_settings_is_per_cpu_devid(desc) ||
2455 irq_settings_can_autoenable(desc) ||
2456 !irq_supports_nmi(desc)) 2457 return -EINVAL;
2458
2459 /* The line cannot already be NMI */
2460 if (desc->istate & IRQS_NMI)
2461 return -EINVAL;
2462
2463 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
2464 if (!action)
2465 return -ENOMEM;
2466
2467 action->handler = handler;
2468 action->flags = IRQF_PERCPU | IRQF_NO_SUSPEND | IRQF_NO_THREAD
2469 | IRQF_NOBALANCING;
2470 action->name = name;
2471 action->percpu_dev_id = dev_id;
2472
2473 retval = irq_chip_pm_get(&desc->irq_data);
2474 if (retval < 0)
2475 goto err_out;
2476
2477 retval = __setup_irq(irq, desc, action);
2478 if (retval)
2479 goto err_irq_setup;
2480
2481 raw_spin_lock_irqsave(&desc->lock, flags);
2482 desc->istate |= IRQS_NMI;
2483 raw_spin_unlock_irqrestore(&desc->lock, flags);
2484
2485 return 0;
2486
2487 err_irq_setup:
2488 irq_chip_pm_put(&desc->irq_data);
2489 err_out:
2490 kfree(action);
2491
2492 return retval;
2493 }
2494
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 3/4 genirq: Provide NMI handlers
In reply to Julien ThierryProvide flow handlers that are NMI safe for interrupts and percpu_devid interrupts.
--- include/linux/irq.h | 3 +++ kernel/irq/chip.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
include/linux/irq.h +3 -0
@@ -600,6 +600,9 @@ static inline int irq_set_parent(int irq, int parent_irq)extern void handle_bad_irq (struct irq_desc *desc);extern void handle_nested_irq (unsigned int irq); +extern void handle_fasteoi_nmi (struct irq_desc *desc); +extern void handle_percpu_devid_fasteoi_nmi (struct irq_desc *desc); +extern int irq_chip_compose_msi_msg (struct irq_data *data,struct msi_msg *msg);extern int irq_chip_pm_get (struct irq_data *data);extern int irq_chip_pm_put (struct irq_data *data);
kernel/irq/chip.c +54 -0
66 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 4/4 irqdesc: Add domain handler for NMIs
In reply to Julien ThierryNMI handling code should be executed between calls to nmi_enter and nmi_exit.
Add a separate domain handler to properly setup NMI context when handling an interrupt requested as NMI.
--- include/linux/irqdesc.h | 3 +++ kernel/irq/irqdesc.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
include/linux/irqdesc.h +3 -0
@@ -171,6 +171,9 @@ static inline int handle_domain_irq(struct irq_domain *domain, {return __handle_domain_irq (domain, hwirq, true, regs); } + +int handle_domain_nmi (struct irq_domain *domain,unsigned int hwirq, +struct pt_regs *regs);#endif /* Test to see if a driver has successfully requested an irq */
kernel/irq/irqdesc.c +33 -0
@@ -665,6 +665,39 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,set_irq_regs (old_regs); return ret; } + +/** +* handle_domain_nmi - Invoke the handler for a HW irq belonging to a domain +* @domain: The domain where to perform the lookup +* @hwirq: The HW irq number to convert to a logical one +* @regs: Register file coming from the low-level handling code +* +* Returns: 0 on success, or -EINVAL if conversion has failed +*/ +int handle_domain_nmi (struct irq_domain *domain,unsigned int hwirq, +struct pt_regs *regs) +{ +struct pt_regs *old_regs =set_irq_regs (regs); +unsigned int irq; +int ret =0 ; + +nmi_enter (); + + irq =irq_find_mapping (domain, hwirq); + +/* +* ack_bad_irq is not NMI-safe, just report +* an invalid interrupt. +*/ +if (likely (irq)) +generic_handle_irq (irq); +else + ret = -EINVAL ; + +nmi_exit (); +set_irq_regs (old_regs); +return ret; +}#endif /* Dynamic interrupt handling */
Signature · 1 line
1.9.1
kbuild test robot
build botRe: [PATCH v2 4/4] irqdesc: Add domain handler for NMIs
Thank you for the patch! Yet something to improve:
Hi Julien,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.19-rc1 next-20180828]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Julien-Thierry/genirq-Provide-basic-NMI-management-for-interrupt-lines/20180829-063713
config: arm-nuc960_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=arm
All errors (new ones prefixed by >>):
kernel/irq/irqdesc.c: In function 'handle_domain_nmi':
>> kernel/irq/irqdesc.c:686:8: error: implicit declaration of function 'irq_find_mapping'; did you mean 'irq_dispose_mapping'? [-Werror=implicit-function-declaration]
irq = irq_find_mapping(domain, hwirq);
^~~~~~~~~~~~~~~~
irq_dispose_mappingcc1: some warnings being treated as errors
vim +686 kernel/irq/irqdesc.c
668
669 /**
670 * handle_domain_nmi - Invoke the handler for a HW irq belonging to a domain
671 * @domain: The domain where to perform the lookup
672 * @hwirq: The HW irq number to convert to a logical one
673 * @regs: Register file coming from the low-level handling code
674 *
675 * Returns: 0 on success, or -EINVAL if conversion has failed
676 */
677 int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq,
678 struct pt_regs *regs)
679 {
680 struct pt_regs *old_regs = set_irq_regs(regs);
681 unsigned int irq;
682 int ret = 0;
683
684 nmi_enter();
685
> 686 irq = irq_find_mapping(domain, hwirq);
687
688 /*
689 * ack_bad_irq is not NMI-safe, just report
690 * an invalid interrupt.
691 */
692 if (likely(irq))
693 generic_handle_irq(irq);
694 else
695 ret = -EINVAL;
696
697 nmi_exit();
698 set_irq_regs(old_regs);
699 return ret;
700 }
701 #endif
702
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 2 lines · Julien Thierry
Hi,
[...]
Quoted 2 lines
I'll soon post a series making use of the API for Arm's GICv3.
Here is the series, NMI related patches are the last 4 in the series:
https://lkml.org/lkml/2018/8/28/693
Signature · 1 line
Julien Thierry