xref: /openbmc/linux/arch/x86/include/asm/hw_irq.h (revision 633260fa)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_HW_IRQ_H
3 #define _ASM_X86_HW_IRQ_H
4 
5 /*
6  * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
7  *
8  * moved some of the old arch/i386/kernel/irq.h to here. VY
9  *
10  * IRQ/IPI changes taken from work by Thomas Radke
11  * <tomsoft@informatik.tu-chemnitz.de>
12  *
13  * hacked by Andi Kleen for x86-64.
14  * unified by tglx
15  */
16 
17 #include <asm/irq_vectors.h>
18 
19 #define IRQ_MATRIX_BITS		NR_VECTORS
20 
21 #ifndef __ASSEMBLY__
22 
23 #include <linux/percpu.h>
24 #include <linux/profile.h>
25 #include <linux/smp.h>
26 
27 #include <linux/atomic.h>
28 #include <asm/irq.h>
29 #include <asm/sections.h>
30 
31 /* Interrupt handlers registered during init_IRQ */
32 extern asmlinkage void apic_timer_interrupt(void);
33 extern asmlinkage void x86_platform_ipi(void);
34 extern asmlinkage void kvm_posted_intr_ipi(void);
35 extern asmlinkage void kvm_posted_intr_wakeup_ipi(void);
36 extern asmlinkage void kvm_posted_intr_nested_ipi(void);
37 extern asmlinkage void error_interrupt(void);
38 extern asmlinkage void irq_work_interrupt(void);
39 extern asmlinkage void uv_bau_message_intr1(void);
40 
41 extern asmlinkage void spurious_interrupt(void);
42 extern asmlinkage void spurious_apic_interrupt(void);
43 extern asmlinkage void thermal_interrupt(void);
44 extern asmlinkage void reschedule_interrupt(void);
45 
46 extern asmlinkage void irq_move_cleanup_interrupt(void);
47 extern asmlinkage void reboot_interrupt(void);
48 extern asmlinkage void threshold_interrupt(void);
49 extern asmlinkage void deferred_error_interrupt(void);
50 
51 extern asmlinkage void call_function_interrupt(void);
52 extern asmlinkage void call_function_single_interrupt(void);
53 
54 #ifdef	CONFIG_X86_LOCAL_APIC
55 struct irq_data;
56 struct pci_dev;
57 struct msi_desc;
58 
59 enum irq_alloc_type {
60 	X86_IRQ_ALLOC_TYPE_IOAPIC = 1,
61 	X86_IRQ_ALLOC_TYPE_HPET,
62 	X86_IRQ_ALLOC_TYPE_MSI,
63 	X86_IRQ_ALLOC_TYPE_MSIX,
64 	X86_IRQ_ALLOC_TYPE_DMAR,
65 	X86_IRQ_ALLOC_TYPE_UV,
66 };
67 
68 struct irq_alloc_info {
69 	enum irq_alloc_type	type;
70 	u32			flags;
71 	const struct cpumask	*mask;	/* CPU mask for vector allocation */
72 	union {
73 		int		unused;
74 #ifdef	CONFIG_HPET_TIMER
75 		struct {
76 			int		hpet_id;
77 			int		hpet_index;
78 			void		*hpet_data;
79 		};
80 #endif
81 #ifdef	CONFIG_PCI_MSI
82 		struct {
83 			struct pci_dev	*msi_dev;
84 			irq_hw_number_t	msi_hwirq;
85 		};
86 #endif
87 #ifdef	CONFIG_X86_IO_APIC
88 		struct {
89 			int		ioapic_id;
90 			int		ioapic_pin;
91 			int		ioapic_node;
92 			u32		ioapic_trigger : 1;
93 			u32		ioapic_polarity : 1;
94 			u32		ioapic_valid : 1;
95 			struct IO_APIC_route_entry *ioapic_entry;
96 		};
97 #endif
98 #ifdef	CONFIG_DMAR_TABLE
99 		struct {
100 			int		dmar_id;
101 			void		*dmar_data;
102 		};
103 #endif
104 #ifdef	CONFIG_X86_UV
105 		struct {
106 			int		uv_limit;
107 			int		uv_blade;
108 			unsigned long	uv_offset;
109 			char		*uv_name;
110 		};
111 #endif
112 #if IS_ENABLED(CONFIG_VMD)
113 		struct {
114 			struct msi_desc *desc;
115 		};
116 #endif
117 	};
118 };
119 
120 struct irq_cfg {
121 	unsigned int		dest_apicid;
122 	unsigned int		vector;
123 };
124 
125 extern struct irq_cfg *irq_cfg(unsigned int irq);
126 extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);
127 extern void lock_vector_lock(void);
128 extern void unlock_vector_lock(void);
129 #ifdef CONFIG_SMP
130 extern void send_cleanup_vector(struct irq_cfg *);
131 extern void irq_complete_move(struct irq_cfg *cfg);
132 #else
133 static inline void send_cleanup_vector(struct irq_cfg *c) { }
134 static inline void irq_complete_move(struct irq_cfg *c) { }
135 #endif
136 
137 extern void apic_ack_edge(struct irq_data *data);
138 #else	/*  CONFIG_X86_LOCAL_APIC */
139 static inline void lock_vector_lock(void) {}
140 static inline void unlock_vector_lock(void) {}
141 #endif	/* CONFIG_X86_LOCAL_APIC */
142 
143 /* Statistics */
144 extern atomic_t irq_err_count;
145 extern atomic_t irq_mis_count;
146 
147 extern void elcr_set_level_irq(unsigned int irq);
148 
149 extern char irq_entries_start[];
150 #ifdef CONFIG_TRACING
151 #define trace_irq_entries_start irq_entries_start
152 #endif
153 
154 extern char spurious_entries_start[];
155 
156 #define VECTOR_UNUSED		NULL
157 #define VECTOR_SHUTDOWN		((void *)-1L)
158 #define VECTOR_RETRIGGERED	((void *)-2L)
159 
160 typedef struct irq_desc* vector_irq_t[NR_VECTORS];
161 DECLARE_PER_CPU(vector_irq_t, vector_irq);
162 
163 #endif /* !ASSEMBLY_ */
164 
165 #endif /* _ASM_X86_HW_IRQ_H */
166