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