blob: 5e0b031d1a7dd0372a46438b2c78ea12b9524419 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_HW_IRQ_H
2#define _ASM_X86_HW_IRQ_H
Thomas Gleixner2e088432008-05-02 19:00:30 +02003
4/*
5 * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
6 *
7 * moved some of the old arch/i386/kernel/irq.h to here. VY
8 *
9 * IRQ/IPI changes taken from work by Thomas Radke
10 * <tomsoft@informatik.tu-chemnitz.de>
11 *
12 * hacked by Andi Kleen for x86-64.
13 * unified by tglx
14 */
15
Thomas Gleixner9b7dc562008-05-02 20:10:09 +020016#include <asm/irq_vectors.h>
Thomas Gleixner2e088432008-05-02 19:00:30 +020017
18#ifndef __ASSEMBLY__
19
20#include <linux/percpu.h>
21#include <linux/profile.h>
22#include <linux/smp.h>
23
Arun Sharma600634972011-07-26 16:09:06 -070024#include <linux/atomic.h>
Thomas Gleixner2e088432008-05-02 19:00:30 +020025#include <asm/irq.h>
26#include <asm/sections.h>
27
Thomas Gleixner2e088432008-05-02 19:00:30 +020028/* Interrupt handlers registered during init_IRQ */
Andi Kleen1d9090e2013-08-05 15:02:37 -070029extern asmlinkage void apic_timer_interrupt(void);
30extern asmlinkage void x86_platform_ipi(void);
31extern asmlinkage void kvm_posted_intr_ipi(void);
32extern asmlinkage void error_interrupt(void);
33extern asmlinkage void irq_work_interrupt(void);
Ingo Molnar241771e2008-12-03 10:39:53 +010034
Andi Kleen1d9090e2013-08-05 15:02:37 -070035extern asmlinkage void spurious_interrupt(void);
36extern asmlinkage void thermal_interrupt(void);
37extern asmlinkage void reschedule_interrupt(void);
Thomas Gleixner2e088432008-05-02 19:00:30 +020038
Andi Kleen1d9090e2013-08-05 15:02:37 -070039extern asmlinkage void invalidate_interrupt(void);
40extern asmlinkage void invalidate_interrupt0(void);
41extern asmlinkage void invalidate_interrupt1(void);
42extern asmlinkage void invalidate_interrupt2(void);
43extern asmlinkage void invalidate_interrupt3(void);
44extern asmlinkage void invalidate_interrupt4(void);
45extern asmlinkage void invalidate_interrupt5(void);
46extern asmlinkage void invalidate_interrupt6(void);
47extern asmlinkage void invalidate_interrupt7(void);
48extern asmlinkage void invalidate_interrupt8(void);
49extern asmlinkage void invalidate_interrupt9(void);
50extern asmlinkage void invalidate_interrupt10(void);
51extern asmlinkage void invalidate_interrupt11(void);
52extern asmlinkage void invalidate_interrupt12(void);
53extern asmlinkage void invalidate_interrupt13(void);
54extern asmlinkage void invalidate_interrupt14(void);
55extern asmlinkage void invalidate_interrupt15(void);
56extern asmlinkage void invalidate_interrupt16(void);
57extern asmlinkage void invalidate_interrupt17(void);
58extern asmlinkage void invalidate_interrupt18(void);
59extern asmlinkage void invalidate_interrupt19(void);
60extern asmlinkage void invalidate_interrupt20(void);
61extern asmlinkage void invalidate_interrupt21(void);
62extern asmlinkage void invalidate_interrupt22(void);
63extern asmlinkage void invalidate_interrupt23(void);
64extern asmlinkage void invalidate_interrupt24(void);
65extern asmlinkage void invalidate_interrupt25(void);
66extern asmlinkage void invalidate_interrupt26(void);
67extern asmlinkage void invalidate_interrupt27(void);
68extern asmlinkage void invalidate_interrupt28(void);
69extern asmlinkage void invalidate_interrupt29(void);
70extern asmlinkage void invalidate_interrupt30(void);
71extern asmlinkage void invalidate_interrupt31(void);
Thomas Gleixner2e088432008-05-02 19:00:30 +020072
Andi Kleen1d9090e2013-08-05 15:02:37 -070073extern asmlinkage void irq_move_cleanup_interrupt(void);
74extern asmlinkage void reboot_interrupt(void);
75extern asmlinkage void threshold_interrupt(void);
Thomas Gleixner2e088432008-05-02 19:00:30 +020076
Andi Kleen1d9090e2013-08-05 15:02:37 -070077extern asmlinkage void call_function_interrupt(void);
78extern asmlinkage void call_function_single_interrupt(void);
Thomas Gleixner2e088432008-05-02 19:00:30 +020079
Seiji Aguchicf910e82013-06-20 11:46:53 -040080#ifdef CONFIG_TRACING
81/* Interrupt handlers registered during init_IRQ */
82extern void trace_apic_timer_interrupt(void);
83extern void trace_x86_platform_ipi(void);
84extern void trace_error_interrupt(void);
85extern void trace_irq_work_interrupt(void);
86extern void trace_spurious_interrupt(void);
87extern void trace_thermal_interrupt(void);
88extern void trace_reschedule_interrupt(void);
89extern void trace_threshold_interrupt(void);
90extern void trace_call_function_interrupt(void);
91extern void trace_call_function_single_interrupt(void);
92#define trace_irq_move_cleanup_interrupt irq_move_cleanup_interrupt
93#define trace_reboot_interrupt reboot_interrupt
94#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
95#endif /* CONFIG_TRACING */
96
Jiang Liu26011ee2014-10-27 16:11:56 +080097#ifdef CONFIG_IRQ_REMAP
98/* Intel specific interrupt remapping information */
99struct irq_2_iommu {
100 struct intel_iommu *iommu;
101 u16 irte_index;
102 u16 sub_handle;
103 u8 irte_mask;
104};
105
106/* AMD specific interrupt remapping information */
107struct irq_2_irte {
108 u16 devid; /* Device ID for IRTE table */
109 u16 index; /* Index into IRTE table*/
110};
111#endif /* CONFIG_IRQ_REMAP */
112
Jiang Liu52f518a2015-04-13 14:11:35 +0800113struct irq_domain;
114
Jiang Liu26011ee2014-10-27 16:11:56 +0800115#ifdef CONFIG_X86_LOCAL_APIC
Jiang Liu74afab72014-10-27 16:12:00 +0800116struct irq_data;
Jiang Liu947045a2015-04-13 14:11:30 +0800117struct pci_dev;
118struct msi_desc;
119
120enum irq_alloc_type {
121 X86_IRQ_ALLOC_TYPE_IOAPIC = 1,
122 X86_IRQ_ALLOC_TYPE_HPET,
123 X86_IRQ_ALLOC_TYPE_MSI,
124 X86_IRQ_ALLOC_TYPE_MSIX,
Jiang Liu0921f1d2015-04-13 14:11:42 +0800125 X86_IRQ_ALLOC_TYPE_DMAR,
Jiang Liu947045a2015-04-13 14:11:30 +0800126};
Jiang Liub5dc8e62015-04-13 14:11:24 +0800127
128struct irq_alloc_info {
Jiang Liu947045a2015-04-13 14:11:30 +0800129 enum irq_alloc_type type;
Jiang Liub5dc8e62015-04-13 14:11:24 +0800130 u32 flags;
131 const struct cpumask *mask; /* CPU mask for vector allocation */
Jiang Liu947045a2015-04-13 14:11:30 +0800132 union {
133 int unused;
134#ifdef CONFIG_HPET_TIMER
135 struct {
136 int hpet_id;
137 int hpet_index;
138 void *hpet_data;
139 };
140#endif
141#ifdef CONFIG_PCI_MSI
142 struct {
143 struct pci_dev *msi_dev;
144 irq_hw_number_t msi_hwirq;
145 };
146#endif
147#ifdef CONFIG_X86_IO_APIC
148 struct {
149 int ioapic_id;
150 int ioapic_pin;
151 int ioapic_node;
152 u32 ioapic_trigger : 1;
153 u32 ioapic_polarity : 1;
154 u32 ioapic_valid : 1;
155 struct IO_APIC_route_entry *ioapic_entry;
156 };
157#endif
Jiang Liu0921f1d2015-04-13 14:11:42 +0800158#ifdef CONFIG_DMAR_TABLE
159 struct {
160 int dmar_id;
161 void *dmar_data;
162 };
163#endif
Jiang Liu49e07d82015-04-13 14:11:43 +0800164#ifdef CONFIG_HT_IRQ
165 struct {
166 int ht_pos;
167 int ht_idx;
168 struct pci_dev *ht_dev;
169 void *ht_update;
170 };
171#endif
Jiang Liu947045a2015-04-13 14:11:30 +0800172 };
Jiang Liub5dc8e62015-04-13 14:11:24 +0800173};
174
175enum {
176 /* Allocate contiguous CPU vectors */
177 X86_IRQ_ALLOC_CONTIGUOUS_VECTORS = 0x1,
178};
Jiang Liu74afab72014-10-27 16:12:00 +0800179
Jiang Liu26011ee2014-10-27 16:11:56 +0800180struct irq_cfg {
181 cpumask_var_t domain;
182 cpumask_var_t old_domain;
Jiang Liu5f0052f2015-04-13 14:11:23 +0800183 unsigned int dest_apicid;
Jiang Liu26011ee2014-10-27 16:11:56 +0800184 u8 vector;
185 u8 move_in_progress : 1;
186#ifdef CONFIG_IRQ_REMAP
187 u8 remapped : 1;
188 union {
189 struct irq_2_iommu irq_2_iommu;
190 struct irq_2_irte irq_2_irte;
191 };
192#endif
193 union {
194#ifdef CONFIG_X86_IO_APIC
195 struct {
196 struct list_head irq_2_pin;
197 };
198#endif
199 };
200};
201
Jiang Liub5dc8e62015-04-13 14:11:24 +0800202extern struct irq_domain *x86_vector_domain;
203
204extern void init_irq_alloc_info(struct irq_alloc_info *info,
205 const struct cpumask *mask);
206extern void copy_irq_alloc_info(struct irq_alloc_info *dst,
207 struct irq_alloc_info *src);
Jiang Liu55a0e2b2014-10-27 16:11:59 +0800208extern struct irq_cfg *irq_cfg(unsigned int irq);
209extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);
Jiang Liu74afab72014-10-27 16:12:00 +0800210extern struct irq_cfg *alloc_irq_and_cfg_at(unsigned int at, int node);
211extern void lock_vector_lock(void);
212extern void unlock_vector_lock(void);
Jiang Liu26011ee2014-10-27 16:11:56 +0800213extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *);
Jiang Liu74afab72014-10-27 16:12:00 +0800214extern void clear_irq_vector(int irq, struct irq_cfg *cfg);
215extern void setup_vector_irq(int cpu);
Jiang Liu26011ee2014-10-27 16:11:56 +0800216#ifdef CONFIG_SMP
217extern void send_cleanup_vector(struct irq_cfg *);
Thomas Gleixnerf0e5bf72014-11-05 10:12:27 +0100218extern void irq_complete_move(struct irq_cfg *cfg);
Jiang Liu26011ee2014-10-27 16:11:56 +0800219#else
220static inline void send_cleanup_vector(struct irq_cfg *c) { }
Thomas Gleixnerf0e5bf72014-11-05 10:12:27 +0100221static inline void irq_complete_move(struct irq_cfg *c) { }
Jiang Liu26011ee2014-10-27 16:11:56 +0800222#endif
223
Jiang Liu74afab72014-10-27 16:12:00 +0800224extern int apic_retrigger_irq(struct irq_data *data);
225extern void apic_ack_edge(struct irq_data *data);
226extern int apic_set_affinity(struct irq_data *data, const struct cpumask *mask,
227 unsigned int *dest_id);
228#else /* CONFIG_X86_LOCAL_APIC */
Jiang Liu26011ee2014-10-27 16:11:56 +0800229static inline void lock_vector_lock(void) {}
230static inline void unlock_vector_lock(void) {}
Jiang Liu74afab72014-10-27 16:12:00 +0800231#endif /* CONFIG_X86_LOCAL_APIC */
Jiang Liu26011ee2014-10-27 16:11:56 +0800232
Jiang Liu52f518a2015-04-13 14:11:35 +0800233#ifdef CONFIG_PCI_MSI
234extern void arch_init_msi_domain(struct irq_domain *domain);
235#else
236static inline void arch_init_msi_domain(struct irq_domain *domain) { }
237#endif
Jiang Liu49e07d82015-04-13 14:11:43 +0800238#ifdef CONFIG_HT_IRQ
239extern void arch_init_htirq_domain(struct irq_domain *domain);
240#else
241static inline void arch_init_htirq_domain(struct irq_domain *domain) { }
242#endif
Jiang Liu52f518a2015-04-13 14:11:35 +0800243
Thomas Gleixner2e088432008-05-02 19:00:30 +0200244/* Statistics */
245extern atomic_t irq_err_count;
246extern atomic_t irq_mis_count;
247
Thomas Gleixner1a331952008-05-03 00:30:50 +0200248/* EISA */
249extern void eisa_set_level_irq(unsigned int irq);
250
Jaswinder Singh2b97df02008-07-23 17:13:14 +0530251/* SMP */
Andi Kleen1d9090e2013-08-05 15:02:37 -0700252extern __visible void smp_apic_timer_interrupt(struct pt_regs *);
253extern __visible void smp_spurious_interrupt(struct pt_regs *);
254extern __visible void smp_x86_platform_ipi(struct pt_regs *);
255extern __visible void smp_error_interrupt(struct pt_regs *);
Jaswinder Singh Rajput2c1b2842009-04-11 00:03:10 +0530256#ifdef CONFIG_X86_IO_APIC
257extern asmlinkage void smp_irq_move_cleanup_interrupt(void);
258#endif
Ingo Molnar3e5095d2009-01-27 17:07:08 +0100259#ifdef CONFIG_SMP
Andi Kleen1d9090e2013-08-05 15:02:37 -0700260extern __visible void smp_reschedule_interrupt(struct pt_regs *);
261extern __visible void smp_call_function_interrupt(struct pt_regs *);
262extern __visible void smp_call_function_single_interrupt(struct pt_regs *);
263extern __visible void smp_invalidate_interrupt(struct pt_regs *);
Jaswinder Singhe7f08df2008-07-25 10:42:26 +0530264#endif
Jaswinder Singh2b97df02008-07-23 17:13:14 +0530265
Denys Vlasenko3304c9c2015-04-03 21:49:13 +0200266extern char irq_entries_start[];
Seiji Aguchi25c74b12013-10-30 16:37:00 -0400267#ifdef CONFIG_TRACING
Denys Vlasenko3304c9c2015-04-03 21:49:13 +0200268#define trace_irq_entries_start irq_entries_start
Seiji Aguchi25c74b12013-10-30 16:37:00 -0400269#endif
Eric W. Biedermand388e5f2008-08-09 15:09:02 -0700270
Prarit Bhargava79a51b22014-04-02 08:13:47 -0400271#define VECTOR_UNDEFINED (-1)
272#define VECTOR_RETRIGGERED (-2)
Prarit Bhargava93450052014-01-05 11:10:52 -0500273
Yinghai Lu497c9a12008-08-19 20:50:28 -0700274typedef int vector_irq_t[NR_VECTORS];
275DECLARE_PER_CPU(vector_irq_t, vector_irq);
Thomas Gleixner2e088432008-05-02 19:00:30 +0200276
Thomas Gleixner22dc12d2008-05-02 22:10:39 +0200277#endif /* !ASSEMBLY_ */
278
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700279#endif /* _ASM_X86_HW_IRQ_H */