]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - kernel/irq/internals.h
genirq: Move IRQ_MASKED to core
[mirror_ubuntu-bionic-kernel.git] / kernel / irq / internals.h
1 /*
2 * IRQ subsystem internal functions and variables:
3 *
4 * Do not ever include this file from anything else than
5 * kernel/irq/. Do not even think about using any information outside
6 * of this file for your non core code.
7 */
8 #include <linux/irqdesc.h>
9
10 #ifdef CONFIG_SPARSE_IRQ
11 # define IRQ_BITMAP_BITS (NR_IRQS + 8196)
12 #else
13 # define IRQ_BITMAP_BITS NR_IRQS
14 #endif
15
16 #include "compat.h"
17 #include "settings.h"
18
19 #define istate core_internal_state__do_not_mess_with_it
20
21 extern int noirqdebug;
22
23 /*
24 * Bits used by threaded handlers:
25 * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
26 * IRQTF_DIED - handler thread died
27 * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
28 * IRQTF_AFFINITY - irq thread is requested to adjust affinity
29 */
30 enum {
31 IRQTF_RUNTHREAD,
32 IRQTF_DIED,
33 IRQTF_WARNED,
34 IRQTF_AFFINITY,
35 };
36
37 /*
38 * Bit masks for desc->state
39 *
40 * IRQS_AUTODETECT - autodetection in progress
41 * IRQS_SPURIOUS_DISABLED - was disabled due to spurious interrupt
42 * detection
43 * IRQS_POLL_INPROGRESS - polling in progress
44 * IRQS_INPROGRESS - Interrupt in progress
45 * IRQS_ONESHOT - irq is not unmasked in primary handler
46 * IRQS_REPLAY - irq is replayed
47 * IRQS_WAITING - irq is waiting
48 * IRQS_DISABLED - irq is disabled
49 * IRQS_PENDING - irq is pending and replayed later
50 * IRQS_MASKED - irq is masked
51 */
52 enum {
53 IRQS_AUTODETECT = 0x00000001,
54 IRQS_SPURIOUS_DISABLED = 0x00000002,
55 IRQS_POLL_INPROGRESS = 0x00000008,
56 IRQS_INPROGRESS = 0x00000010,
57 IRQS_ONESHOT = 0x00000020,
58 IRQS_REPLAY = 0x00000040,
59 IRQS_WAITING = 0x00000080,
60 IRQS_DISABLED = 0x00000100,
61 IRQS_PENDING = 0x00000200,
62 IRQS_MASKED = 0x00000400,
63 };
64
65 #define irq_data_to_desc(data) container_of(data, struct irq_desc, irq_data)
66
67 /* Set default functions for irq_chip structures: */
68 extern void irq_chip_set_defaults(struct irq_chip *chip);
69
70 /* Set default handler: */
71 extern void compat_irq_chip_set_default_handler(struct irq_desc *desc);
72
73 extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
74 unsigned long flags);
75 extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp);
76 extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
77
78 extern int irq_startup(struct irq_desc *desc);
79 extern void irq_shutdown(struct irq_desc *desc);
80 extern void irq_enable(struct irq_desc *desc);
81 extern void irq_disable(struct irq_desc *desc);
82
83 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
84
85 irqreturn_t handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action);
86 irqreturn_t handle_irq_event(struct irq_desc *desc);
87
88 /* Resending of interrupts :*/
89 void check_irq_resend(struct irq_desc *desc, unsigned int irq);
90 bool irq_wait_for_poll(struct irq_desc *desc);
91
92 #ifdef CONFIG_PROC_FS
93 extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
94 extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
95 extern void register_handler_proc(unsigned int irq, struct irqaction *action);
96 extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
97 #else
98 static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
99 static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
100 static inline void register_handler_proc(unsigned int irq,
101 struct irqaction *action) { }
102 static inline void unregister_handler_proc(unsigned int irq,
103 struct irqaction *action) { }
104 #endif
105
106 extern int irq_select_affinity_usr(unsigned int irq, struct cpumask *mask);
107
108 extern void irq_set_thread_affinity(struct irq_desc *desc);
109
110 /* Inline functions for support of irq chips on slow busses */
111 static inline void chip_bus_lock(struct irq_desc *desc)
112 {
113 if (unlikely(desc->irq_data.chip->irq_bus_lock))
114 desc->irq_data.chip->irq_bus_lock(&desc->irq_data);
115 }
116
117 static inline void chip_bus_sync_unlock(struct irq_desc *desc)
118 {
119 if (unlikely(desc->irq_data.chip->irq_bus_sync_unlock))
120 desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
121 }
122
123 /*
124 * Debugging printout:
125 */
126
127 #include <linux/kallsyms.h>
128
129 #define P(f) if (desc->status & f) printk("%14s set\n", #f)
130 #define PS(f) if (desc->istate & f) printk("%14s set\n", #f)
131
132 static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
133 {
134 printk("irq %d, desc: %p, depth: %d, count: %d, unhandled: %d\n",
135 irq, desc, desc->depth, desc->irq_count, desc->irqs_unhandled);
136 printk("->handle_irq(): %p, ", desc->handle_irq);
137 print_symbol("%s\n", (unsigned long)desc->handle_irq);
138 printk("->irq_data.chip(): %p, ", desc->irq_data.chip);
139 print_symbol("%s\n", (unsigned long)desc->irq_data.chip);
140 printk("->action(): %p\n", desc->action);
141 if (desc->action) {
142 printk("->action->handler(): %p, ", desc->action->handler);
143 print_symbol("%s\n", (unsigned long)desc->action->handler);
144 }
145
146 P(IRQ_LEVEL);
147 #ifdef CONFIG_IRQ_PER_CPU
148 P(IRQ_PER_CPU);
149 #endif
150 P(IRQ_NOPROBE);
151 P(IRQ_NOREQUEST);
152 P(IRQ_NOAUTOEN);
153
154 PS(IRQS_AUTODETECT);
155 PS(IRQS_INPROGRESS);
156 PS(IRQS_REPLAY);
157 PS(IRQS_WAITING);
158 PS(IRQS_DISABLED);
159 PS(IRQS_PENDING);
160 PS(IRQS_MASKED);
161 }
162
163 #undef P
164 #undef PS