xref: /openbmc/linux/arch/x86/include/asm/hw_irq.h (revision 582f9191)
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 kvm_posted_intr_ipi(void);
33 extern asmlinkage void kvm_posted_intr_wakeup_ipi(void);
34 extern asmlinkage void kvm_posted_intr_nested_ipi(void);
35 extern asmlinkage void irq_work_interrupt(void);
36 extern asmlinkage void uv_bau_message_intr1(void);
37 
38 extern asmlinkage void thermal_interrupt(void);
39 extern asmlinkage void reschedule_interrupt(void);
40 
41 extern asmlinkage void threshold_interrupt(void);
42 extern asmlinkage void deferred_error_interrupt(void);
43 
44 #ifdef	CONFIG_X86_LOCAL_APIC
45 struct irq_data;
46 struct pci_dev;
47 struct msi_desc;
48 
49 enum irq_alloc_type {
50 	X86_IRQ_ALLOC_TYPE_IOAPIC = 1,
51 	X86_IRQ_ALLOC_TYPE_HPET,
52 	X86_IRQ_ALLOC_TYPE_MSI,
53 	X86_IRQ_ALLOC_TYPE_MSIX,
54 	X86_IRQ_ALLOC_TYPE_DMAR,
55 	X86_IRQ_ALLOC_TYPE_UV,
56 };
57 
58 struct irq_alloc_info {
59 	enum irq_alloc_type	type;
60 	u32			flags;
61 	const struct cpumask	*mask;	/* CPU mask for vector allocation */
62 	union {
63 		int		unused;
64 #ifdef	CONFIG_HPET_TIMER
65 		struct {
66 			int		hpet_id;
67 			int		hpet_index;
68 			void		*hpet_data;
69 		};
70 #endif
71 #ifdef	CONFIG_PCI_MSI
72 		struct {
73 			struct pci_dev	*msi_dev;
74 			irq_hw_number_t	msi_hwirq;
75 		};
76 #endif
77 #ifdef	CONFIG_X86_IO_APIC
78 		struct {
79 			int		ioapic_id;
80 			int		ioapic_pin;
81 			int		ioapic_node;
82 			u32		ioapic_trigger : 1;
83 			u32		ioapic_polarity : 1;
84 			u32		ioapic_valid : 1;
85 			struct IO_APIC_route_entry *ioapic_entry;
86 		};
87 #endif
88 #ifdef	CONFIG_DMAR_TABLE
89 		struct {
90 			int		dmar_id;
91 			void		*dmar_data;
92 		};
93 #endif
94 #ifdef	CONFIG_X86_UV
95 		struct {
96 			int		uv_limit;
97 			int		uv_blade;
98 			unsigned long	uv_offset;
99 			char		*uv_name;
100 		};
101 #endif
102 #if IS_ENABLED(CONFIG_VMD)
103 		struct {
104 			struct msi_desc *desc;
105 		};
106 #endif
107 	};
108 };
109 
110 struct irq_cfg {
111 	unsigned int		dest_apicid;
112 	unsigned int		vector;
113 };
114 
115 extern struct irq_cfg *irq_cfg(unsigned int irq);
116 extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);
117 extern void lock_vector_lock(void);
118 extern void unlock_vector_lock(void);
119 #ifdef CONFIG_SMP
120 extern void send_cleanup_vector(struct irq_cfg *);
121 extern void irq_complete_move(struct irq_cfg *cfg);
122 #else
123 static inline void send_cleanup_vector(struct irq_cfg *c) { }
124 static inline void irq_complete_move(struct irq_cfg *c) { }
125 #endif
126 
127 extern void apic_ack_edge(struct irq_data *data);
128 #else	/*  CONFIG_X86_LOCAL_APIC */
129 static inline void lock_vector_lock(void) {}
130 static inline void unlock_vector_lock(void) {}
131 #endif	/* CONFIG_X86_LOCAL_APIC */
132 
133 /* Statistics */
134 extern atomic_t irq_err_count;
135 extern atomic_t irq_mis_count;
136 
137 extern void elcr_set_level_irq(unsigned int irq);
138 
139 extern char irq_entries_start[];
140 #ifdef CONFIG_TRACING
141 #define trace_irq_entries_start irq_entries_start
142 #endif
143 
144 extern char spurious_entries_start[];
145 
146 #define VECTOR_UNUSED		NULL
147 #define VECTOR_SHUTDOWN		((void *)-1L)
148 #define VECTOR_RETRIGGERED	((void *)-2L)
149 
150 typedef struct irq_desc* vector_irq_t[NR_VECTORS];
151 DECLARE_PER_CPU(vector_irq_t, vector_irq);
152 
153 #endif /* !ASSEMBLY_ */
154 
155 #endif /* _ASM_X86_HW_IRQ_H */
156