diff options
Diffstat (limited to 'include/linux/irq.h')
-rw-r--r-- | include/linux/irq.h | 124 |
1 files changed, 109 insertions, 15 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h index f899b502f186..b7cbeed972e4 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -17,9 +17,12 @@ | |||
17 | #include <linux/cache.h> | 17 | #include <linux/cache.h> |
18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
19 | #include <linux/cpumask.h> | 19 | #include <linux/cpumask.h> |
20 | #include <linux/gfp.h> | ||
20 | #include <linux/irqreturn.h> | 21 | #include <linux/irqreturn.h> |
21 | #include <linux/irqnr.h> | 22 | #include <linux/irqnr.h> |
22 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/topology.h> | ||
25 | #include <linux/wait.h> | ||
23 | 26 | ||
24 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
25 | #include <asm/ptrace.h> | 28 | #include <asm/ptrace.h> |
@@ -65,6 +68,7 @@ typedef void (*irq_flow_handler_t)(unsigned int irq, | |||
65 | #define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */ | 68 | #define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */ |
66 | #define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */ | 69 | #define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */ |
67 | #define IRQ_AFFINITY_SET 0x02000000 /* IRQ affinity was set from userspace*/ | 70 | #define IRQ_AFFINITY_SET 0x02000000 /* IRQ affinity was set from userspace*/ |
71 | #define IRQ_SUSPENDED 0x04000000 /* IRQ has gone through suspend sequence */ | ||
68 | 72 | ||
69 | #ifdef CONFIG_IRQ_PER_CPU | 73 | #ifdef CONFIG_IRQ_PER_CPU |
70 | # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) | 74 | # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) |
@@ -155,17 +159,17 @@ struct irq_2_iommu; | |||
155 | * @affinity: IRQ affinity on SMP | 159 | * @affinity: IRQ affinity on SMP |
156 | * @cpu: cpu index useful for balancing | 160 | * @cpu: cpu index useful for balancing |
157 | * @pending_mask: pending rebalanced interrupts | 161 | * @pending_mask: pending rebalanced interrupts |
162 | * @threads_active: number of irqaction threads currently running | ||
163 | * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers | ||
158 | * @dir: /proc/irq/ procfs entry | 164 | * @dir: /proc/irq/ procfs entry |
159 | * @name: flow handler name for /proc/interrupts output | 165 | * @name: flow handler name for /proc/interrupts output |
160 | */ | 166 | */ |
161 | struct irq_desc { | 167 | struct irq_desc { |
162 | unsigned int irq; | 168 | unsigned int irq; |
163 | #ifdef CONFIG_SPARSE_IRQ | ||
164 | struct timer_rand_state *timer_rand_state; | 169 | struct timer_rand_state *timer_rand_state; |
165 | unsigned int *kstat_irqs; | 170 | unsigned int *kstat_irqs; |
166 | # ifdef CONFIG_INTR_REMAP | 171 | #ifdef CONFIG_INTR_REMAP |
167 | struct irq_2_iommu *irq_2_iommu; | 172 | struct irq_2_iommu *irq_2_iommu; |
168 | # endif | ||
169 | #endif | 173 | #endif |
170 | irq_flow_handler_t handle_irq; | 174 | irq_flow_handler_t handle_irq; |
171 | struct irq_chip *chip; | 175 | struct irq_chip *chip; |
@@ -182,12 +186,14 @@ struct irq_desc { | |||
182 | unsigned int irqs_unhandled; | 186 | unsigned int irqs_unhandled; |
183 | spinlock_t lock; | 187 | spinlock_t lock; |
184 | #ifdef CONFIG_SMP | 188 | #ifdef CONFIG_SMP |
185 | cpumask_t affinity; | 189 | cpumask_var_t affinity; |
186 | unsigned int cpu; | 190 | unsigned int cpu; |
187 | #endif | ||
188 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 191 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
189 | cpumask_t pending_mask; | 192 | cpumask_var_t pending_mask; |
193 | #endif | ||
190 | #endif | 194 | #endif |
195 | atomic_t threads_active; | ||
196 | wait_queue_head_t wait_for_threads; | ||
191 | #ifdef CONFIG_PROC_FS | 197 | #ifdef CONFIG_PROC_FS |
192 | struct proc_dir_entry *dir; | 198 | struct proc_dir_entry *dir; |
193 | #endif | 199 | #endif |
@@ -202,12 +208,6 @@ extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc | |||
202 | extern struct irq_desc irq_desc[NR_IRQS]; | 208 | extern struct irq_desc irq_desc[NR_IRQS]; |
203 | #else /* CONFIG_SPARSE_IRQ */ | 209 | #else /* CONFIG_SPARSE_IRQ */ |
204 | extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu); | 210 | extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu); |
205 | |||
206 | #define kstat_irqs_this_cpu(DESC) \ | ||
207 | ((DESC)->kstat_irqs[smp_processor_id()]) | ||
208 | #define kstat_incr_irqs_this_cpu(irqno, DESC) \ | ||
209 | ((DESC)->kstat_irqs[smp_processor_id()]++) | ||
210 | |||
211 | #endif /* CONFIG_SPARSE_IRQ */ | 211 | #endif /* CONFIG_SPARSE_IRQ */ |
212 | 212 | ||
213 | extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu); | 213 | extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu); |
@@ -226,7 +226,6 @@ irq_remap_to_desc(unsigned int irq, struct irq_desc *desc) | |||
226 | * Migration helpers for obsolete names, they will go away: | 226 | * Migration helpers for obsolete names, they will go away: |
227 | */ | 227 | */ |
228 | #define hw_interrupt_type irq_chip | 228 | #define hw_interrupt_type irq_chip |
229 | typedef struct irq_chip hw_irq_controller; | ||
230 | #define no_irq_type no_irq_chip | 229 | #define no_irq_type no_irq_chip |
231 | typedef struct irq_desc irq_desc_t; | 230 | typedef struct irq_desc irq_desc_t; |
232 | 231 | ||
@@ -236,6 +235,7 @@ typedef struct irq_desc irq_desc_t; | |||
236 | #include <asm/hw_irq.h> | 235 | #include <asm/hw_irq.h> |
237 | 236 | ||
238 | extern int setup_irq(unsigned int irq, struct irqaction *new); | 237 | extern int setup_irq(unsigned int irq, struct irqaction *new); |
238 | extern void remove_irq(unsigned int irq, struct irqaction *act); | ||
239 | 239 | ||
240 | #ifdef CONFIG_GENERIC_HARDIRQS | 240 | #ifdef CONFIG_GENERIC_HARDIRQS |
241 | 241 | ||
@@ -280,7 +280,7 @@ static inline int irq_balancing_disabled(unsigned int irq) | |||
280 | } | 280 | } |
281 | 281 | ||
282 | /* Handle irq action chains: */ | 282 | /* Handle irq action chains: */ |
283 | extern int handle_IRQ_event(unsigned int irq, struct irqaction *action); | 283 | extern irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action); |
284 | 284 | ||
285 | /* | 285 | /* |
286 | * Built-in IRQ handlers for various IRQ types, | 286 | * Built-in IRQ handlers for various IRQ types, |
@@ -325,7 +325,7 @@ static inline void generic_handle_irq(unsigned int irq) | |||
325 | 325 | ||
326 | /* Handling of unhandled and spurious interrupts: */ | 326 | /* Handling of unhandled and spurious interrupts: */ |
327 | extern void note_interrupt(unsigned int irq, struct irq_desc *desc, | 327 | extern void note_interrupt(unsigned int irq, struct irq_desc *desc, |
328 | int action_ret); | 328 | irqreturn_t action_ret); |
329 | 329 | ||
330 | /* Resending of interrupts :*/ | 330 | /* Resending of interrupts :*/ |
331 | void check_irq_resend(struct irq_desc *desc, unsigned int irq); | 331 | void check_irq_resend(struct irq_desc *desc, unsigned int irq); |
@@ -422,4 +422,98 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry); | |||
422 | 422 | ||
423 | #endif /* !CONFIG_S390 */ | 423 | #endif /* !CONFIG_S390 */ |
424 | 424 | ||
425 | #ifdef CONFIG_SMP | ||
426 | /** | ||
427 | * init_alloc_desc_masks - allocate cpumasks for irq_desc | ||
428 | * @desc: pointer to irq_desc struct | ||
429 | * @cpu: cpu which will be handling the cpumasks | ||
430 | * @boot: true if need bootmem | ||
431 | * | ||
432 | * Allocates affinity and pending_mask cpumask if required. | ||
433 | * Returns true if successful (or not required). | ||
434 | * Side effect: affinity has all bits set, pending_mask has all bits clear. | ||
435 | */ | ||
436 | static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu, | ||
437 | bool boot) | ||
438 | { | ||
439 | int node; | ||
440 | |||
441 | if (boot) { | ||
442 | alloc_bootmem_cpumask_var(&desc->affinity); | ||
443 | cpumask_setall(desc->affinity); | ||
444 | |||
445 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
446 | alloc_bootmem_cpumask_var(&desc->pending_mask); | ||
447 | cpumask_clear(desc->pending_mask); | ||
448 | #endif | ||
449 | return true; | ||
450 | } | ||
451 | |||
452 | node = cpu_to_node(cpu); | ||
453 | |||
454 | if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node)) | ||
455 | return false; | ||
456 | cpumask_setall(desc->affinity); | ||
457 | |||
458 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
459 | if (!alloc_cpumask_var_node(&desc->pending_mask, GFP_ATOMIC, node)) { | ||
460 | free_cpumask_var(desc->affinity); | ||
461 | return false; | ||
462 | } | ||
463 | cpumask_clear(desc->pending_mask); | ||
464 | #endif | ||
465 | return true; | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * init_copy_desc_masks - copy cpumasks for irq_desc | ||
470 | * @old_desc: pointer to old irq_desc struct | ||
471 | * @new_desc: pointer to new irq_desc struct | ||
472 | * | ||
473 | * Insures affinity and pending_masks are copied to new irq_desc. | ||
474 | * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the | ||
475 | * irq_desc struct so the copy is redundant. | ||
476 | */ | ||
477 | |||
478 | static inline void init_copy_desc_masks(struct irq_desc *old_desc, | ||
479 | struct irq_desc *new_desc) | ||
480 | { | ||
481 | #ifdef CONFIG_CPUMASKS_OFFSTACK | ||
482 | cpumask_copy(new_desc->affinity, old_desc->affinity); | ||
483 | |||
484 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
485 | cpumask_copy(new_desc->pending_mask, old_desc->pending_mask); | ||
486 | #endif | ||
487 | #endif | ||
488 | } | ||
489 | |||
490 | static inline void free_desc_masks(struct irq_desc *old_desc, | ||
491 | struct irq_desc *new_desc) | ||
492 | { | ||
493 | free_cpumask_var(old_desc->affinity); | ||
494 | |||
495 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
496 | free_cpumask_var(old_desc->pending_mask); | ||
497 | #endif | ||
498 | } | ||
499 | |||
500 | #else /* !CONFIG_SMP */ | ||
501 | |||
502 | static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu, | ||
503 | bool boot) | ||
504 | { | ||
505 | return true; | ||
506 | } | ||
507 | |||
508 | static inline void init_copy_desc_masks(struct irq_desc *old_desc, | ||
509 | struct irq_desc *new_desc) | ||
510 | { | ||
511 | } | ||
512 | |||
513 | static inline void free_desc_masks(struct irq_desc *old_desc, | ||
514 | struct irq_desc *new_desc) | ||
515 | { | ||
516 | } | ||
517 | #endif /* CONFIG_SMP */ | ||
518 | |||
425 | #endif /* _LINUX_IRQ_H */ | 519 | #endif /* _LINUX_IRQ_H */ |