blob: 75a97a5bbfa82319b137e87d6ce91dd59321e9e8 [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
113#ifdef CONFIG_X86_LOCAL_APIC
Jiang Liu74afab72014-10-27 16:12:00 +0800114struct irq_data;
Jiang Liub5dc8e62015-04-13 14:11:24 +0800115struct irq_domain;
Jiang Liu947045a2015-04-13 14:11:30 +0800116struct pci_dev;
117struct msi_desc;
118
119enum irq_alloc_type {
120 X86_IRQ_ALLOC_TYPE_IOAPIC = 1,
121 X86_IRQ_ALLOC_TYPE_HPET,
122 X86_IRQ_ALLOC_TYPE_MSI,
123 X86_IRQ_ALLOC_TYPE_MSIX,
124};
Jiang Liub5dc8e62015-04-13 14:11:24 +0800125
126struct irq_alloc_info {
Jiang Liu947045a2015-04-13 14:11:30 +0800127 enum irq_alloc_type type;
Jiang Liub5dc8e62015-04-13 14:11:24 +0800128 u32 flags;
129 const struct cpumask *mask; /* CPU mask for vector allocation */
Jiang Liu947045a2015-04-13 14:11:30 +0800130 union {
131 int unused;
132#ifdef CONFIG_HPET_TIMER
133 struct {
134 int hpet_id;
135 int hpet_index;
136 void *hpet_data;
137 };
138#endif
139#ifdef CONFIG_PCI_MSI
140 struct {
141 struct pci_dev *msi_dev;
142 irq_hw_number_t msi_hwirq;
143 };
144#endif
145#ifdef CONFIG_X86_IO_APIC
146 struct {
147 int ioapic_id;
148 int ioapic_pin;
149 int ioapic_node;
150 u32 ioapic_trigger : 1;
151 u32 ioapic_polarity : 1;
152 u32 ioapic_valid : 1;
153 struct IO_APIC_route_entry *ioapic_entry;
154 };
155#endif
156 };
Jiang Liub5dc8e62015-04-13 14:11:24 +0800157};
158
159enum {
160 /* Allocate contiguous CPU vectors */
161 X86_IRQ_ALLOC_CONTIGUOUS_VECTORS = 0x1,
162};
Jiang Liu74afab72014-10-27 16:12:00 +0800163
Jiang Liu26011ee2014-10-27 16:11:56 +0800164struct irq_cfg {
165 cpumask_var_t domain;
166 cpumask_var_t old_domain;
Jiang Liu5f0052f2015-04-13 14:11:23 +0800167 unsigned int dest_apicid;
Jiang Liu26011ee2014-10-27 16:11:56 +0800168 u8 vector;
169 u8 move_in_progress : 1;
170#ifdef CONFIG_IRQ_REMAP
171 u8 remapped : 1;
172 union {
173 struct irq_2_iommu irq_2_iommu;
174 struct irq_2_irte irq_2_irte;
175 };
176#endif
177 union {
178#ifdef CONFIG_X86_IO_APIC
179 struct {
180 struct list_head irq_2_pin;
181 };
182#endif
183 };
184};
185
Jiang Liub5dc8e62015-04-13 14:11:24 +0800186extern struct irq_domain *x86_vector_domain;
187
188extern void init_irq_alloc_info(struct irq_alloc_info *info,
189 const struct cpumask *mask);
190extern void copy_irq_alloc_info(struct irq_alloc_info *dst,
191 struct irq_alloc_info *src);
Jiang Liu55a0e2b2014-10-27 16:11:59 +0800192extern struct irq_cfg *irq_cfg(unsigned int irq);
193extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);
Jiang Liu74afab72014-10-27 16:12:00 +0800194extern struct irq_cfg *alloc_irq_and_cfg_at(unsigned int at, int node);
195extern void lock_vector_lock(void);
196extern void unlock_vector_lock(void);
Jiang Liu26011ee2014-10-27 16:11:56 +0800197extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *);
Jiang Liu74afab72014-10-27 16:12:00 +0800198extern void clear_irq_vector(int irq, struct irq_cfg *cfg);
199extern void setup_vector_irq(int cpu);
Jiang Liu26011ee2014-10-27 16:11:56 +0800200#ifdef CONFIG_SMP
201extern void send_cleanup_vector(struct irq_cfg *);
Thomas Gleixnerf0e5bf72014-11-05 10:12:27 +0100202extern void irq_complete_move(struct irq_cfg *cfg);
Jiang Liu26011ee2014-10-27 16:11:56 +0800203#else
204static inline void send_cleanup_vector(struct irq_cfg *c) { }
Thomas Gleixnerf0e5bf72014-11-05 10:12:27 +0100205static inline void irq_complete_move(struct irq_cfg *c) { }
Jiang Liu26011ee2014-10-27 16:11:56 +0800206#endif
207
Jiang Liu74afab72014-10-27 16:12:00 +0800208extern int apic_retrigger_irq(struct irq_data *data);
209extern void apic_ack_edge(struct irq_data *data);
210extern int apic_set_affinity(struct irq_data *data, const struct cpumask *mask,
211 unsigned int *dest_id);
212#else /* CONFIG_X86_LOCAL_APIC */
Jiang Liu26011ee2014-10-27 16:11:56 +0800213static inline void lock_vector_lock(void) {}
214static inline void unlock_vector_lock(void) {}
Jiang Liu74afab72014-10-27 16:12:00 +0800215#endif /* CONFIG_X86_LOCAL_APIC */
Jiang Liu26011ee2014-10-27 16:11:56 +0800216
Thomas Gleixner2e088432008-05-02 19:00:30 +0200217/* Statistics */
218extern atomic_t irq_err_count;
219extern atomic_t irq_mis_count;
220
Thomas Gleixner1a331952008-05-03 00:30:50 +0200221/* EISA */
222extern void eisa_set_level_irq(unsigned int irq);
223
Jaswinder Singh2b97df02008-07-23 17:13:14 +0530224/* SMP */
Andi Kleen1d9090e2013-08-05 15:02:37 -0700225extern __visible void smp_apic_timer_interrupt(struct pt_regs *);
226extern __visible void smp_spurious_interrupt(struct pt_regs *);
227extern __visible void smp_x86_platform_ipi(struct pt_regs *);
228extern __visible void smp_error_interrupt(struct pt_regs *);
Jaswinder Singh Rajput2c1b2842009-04-11 00:03:10 +0530229#ifdef CONFIG_X86_IO_APIC
230extern asmlinkage void smp_irq_move_cleanup_interrupt(void);
231#endif
Ingo Molnar3e5095d2009-01-27 17:07:08 +0100232#ifdef CONFIG_SMP
Andi Kleen1d9090e2013-08-05 15:02:37 -0700233extern __visible void smp_reschedule_interrupt(struct pt_regs *);
234extern __visible void smp_call_function_interrupt(struct pt_regs *);
235extern __visible void smp_call_function_single_interrupt(struct pt_regs *);
236extern __visible void smp_invalidate_interrupt(struct pt_regs *);
Jaswinder Singhe7f08df2008-07-25 10:42:26 +0530237#endif
Jaswinder Singh2b97df02008-07-23 17:13:14 +0530238
Denys Vlasenko3304c9c2015-04-03 21:49:13 +0200239extern char irq_entries_start[];
Seiji Aguchi25c74b12013-10-30 16:37:00 -0400240#ifdef CONFIG_TRACING
Denys Vlasenko3304c9c2015-04-03 21:49:13 +0200241#define trace_irq_entries_start irq_entries_start
Seiji Aguchi25c74b12013-10-30 16:37:00 -0400242#endif
Eric W. Biedermand388e5f2008-08-09 15:09:02 -0700243
Prarit Bhargava79a51b22014-04-02 08:13:47 -0400244#define VECTOR_UNDEFINED (-1)
245#define VECTOR_RETRIGGERED (-2)
Prarit Bhargava93450052014-01-05 11:10:52 -0500246
Yinghai Lu497c9a12008-08-19 20:50:28 -0700247typedef int vector_irq_t[NR_VECTORS];
248DECLARE_PER_CPU(vector_irq_t, vector_irq);
Thomas Gleixner2e088432008-05-02 19:00:30 +0200249
Thomas Gleixner22dc12d2008-05-02 22:10:39 +0200250#endif /* !ASSEMBLY_ */
251
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700252#endif /* _ASM_X86_HW_IRQ_H */