aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/irq.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/irq.h')
-rw-r--r--include/linux/irq.h105
1 files changed, 90 insertions, 15 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h
index f899b502f186..974890b3c52f 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -17,9 +17,11 @@
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>
23 25
24#include <asm/irq.h> 26#include <asm/irq.h>
25#include <asm/ptrace.h> 27#include <asm/ptrace.h>
@@ -65,6 +67,7 @@ typedef void (*irq_flow_handler_t)(unsigned int irq,
65#define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */ 67#define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */
66#define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */ 68#define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */
67#define IRQ_AFFINITY_SET 0x02000000 /* IRQ affinity was set from userspace*/ 69#define IRQ_AFFINITY_SET 0x02000000 /* IRQ affinity was set from userspace*/
70#define IRQ_SUSPENDED 0x04000000 /* IRQ has gone through suspend sequence */
68 71
69#ifdef CONFIG_IRQ_PER_CPU 72#ifdef CONFIG_IRQ_PER_CPU
70# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) 73# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
@@ -160,12 +163,10 @@ struct irq_2_iommu;
160 */ 163 */
161struct irq_desc { 164struct irq_desc {
162 unsigned int irq; 165 unsigned int irq;
163#ifdef CONFIG_SPARSE_IRQ
164 struct timer_rand_state *timer_rand_state; 166 struct timer_rand_state *timer_rand_state;
165 unsigned int *kstat_irqs; 167 unsigned int *kstat_irqs;
166# ifdef CONFIG_INTR_REMAP 168#ifdef CONFIG_INTR_REMAP
167 struct irq_2_iommu *irq_2_iommu; 169 struct irq_2_iommu *irq_2_iommu;
168# endif
169#endif 170#endif
170 irq_flow_handler_t handle_irq; 171 irq_flow_handler_t handle_irq;
171 struct irq_chip *chip; 172 struct irq_chip *chip;
@@ -182,11 +183,11 @@ struct irq_desc {
182 unsigned int irqs_unhandled; 183 unsigned int irqs_unhandled;
183 spinlock_t lock; 184 spinlock_t lock;
184#ifdef CONFIG_SMP 185#ifdef CONFIG_SMP
185 cpumask_t affinity; 186 cpumask_var_t affinity;
186 unsigned int cpu; 187 unsigned int cpu;
187#endif
188#ifdef CONFIG_GENERIC_PENDING_IRQ 188#ifdef CONFIG_GENERIC_PENDING_IRQ
189 cpumask_t pending_mask; 189 cpumask_var_t pending_mask;
190#endif
190#endif 191#endif
191#ifdef CONFIG_PROC_FS 192#ifdef CONFIG_PROC_FS
192 struct proc_dir_entry *dir; 193 struct proc_dir_entry *dir;
@@ -202,12 +203,6 @@ extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc
202extern struct irq_desc irq_desc[NR_IRQS]; 203extern struct irq_desc irq_desc[NR_IRQS];
203#else /* CONFIG_SPARSE_IRQ */ 204#else /* CONFIG_SPARSE_IRQ */
204extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu); 205extern 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 */ 206#endif /* CONFIG_SPARSE_IRQ */
212 207
213extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu); 208extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu);
@@ -226,7 +221,6 @@ irq_remap_to_desc(unsigned int irq, struct irq_desc *desc)
226 * Migration helpers for obsolete names, they will go away: 221 * Migration helpers for obsolete names, they will go away:
227 */ 222 */
228#define hw_interrupt_type irq_chip 223#define hw_interrupt_type irq_chip
229typedef struct irq_chip hw_irq_controller;
230#define no_irq_type no_irq_chip 224#define no_irq_type no_irq_chip
231typedef struct irq_desc irq_desc_t; 225typedef struct irq_desc irq_desc_t;
232 226
@@ -236,6 +230,7 @@ typedef struct irq_desc irq_desc_t;
236#include <asm/hw_irq.h> 230#include <asm/hw_irq.h>
237 231
238extern int setup_irq(unsigned int irq, struct irqaction *new); 232extern int setup_irq(unsigned int irq, struct irqaction *new);
233extern void remove_irq(unsigned int irq, struct irqaction *act);
239 234
240#ifdef CONFIG_GENERIC_HARDIRQS 235#ifdef CONFIG_GENERIC_HARDIRQS
241 236
@@ -280,7 +275,7 @@ static inline int irq_balancing_disabled(unsigned int irq)
280} 275}
281 276
282/* Handle irq action chains: */ 277/* Handle irq action chains: */
283extern int handle_IRQ_event(unsigned int irq, struct irqaction *action); 278extern irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action);
284 279
285/* 280/*
286 * Built-in IRQ handlers for various IRQ types, 281 * Built-in IRQ handlers for various IRQ types,
@@ -325,7 +320,7 @@ static inline void generic_handle_irq(unsigned int irq)
325 320
326/* Handling of unhandled and spurious interrupts: */ 321/* Handling of unhandled and spurious interrupts: */
327extern void note_interrupt(unsigned int irq, struct irq_desc *desc, 322extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
328 int action_ret); 323 irqreturn_t action_ret);
329 324
330/* Resending of interrupts :*/ 325/* Resending of interrupts :*/
331void check_irq_resend(struct irq_desc *desc, unsigned int irq); 326void check_irq_resend(struct irq_desc *desc, unsigned int irq);
@@ -422,4 +417,84 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
422 417
423#endif /* !CONFIG_S390 */ 418#endif /* !CONFIG_S390 */
424 419
420#ifdef CONFIG_SMP
421/**
422 * init_alloc_desc_masks - allocate cpumasks for irq_desc
423 * @desc: pointer to irq_desc struct
424 * @cpu: cpu which will be handling the cpumasks
425 * @boot: true if need bootmem
426 *
427 * Allocates affinity and pending_mask cpumask if required.
428 * Returns true if successful (or not required).
429 * Side effect: affinity has all bits set, pending_mask has all bits clear.
430 */
431static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
432 bool boot)
433{
434 int node;
435
436 if (boot) {
437 alloc_bootmem_cpumask_var(&desc->affinity);
438 cpumask_setall(desc->affinity);
439
440#ifdef CONFIG_GENERIC_PENDING_IRQ
441 alloc_bootmem_cpumask_var(&desc->pending_mask);
442 cpumask_clear(desc->pending_mask);
443#endif
444 return true;
445 }
446
447 node = cpu_to_node(cpu);
448
449 if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node))
450 return false;
451 cpumask_setall(desc->affinity);
452
453#ifdef CONFIG_GENERIC_PENDING_IRQ
454 if (!alloc_cpumask_var_node(&desc->pending_mask, GFP_ATOMIC, node)) {
455 free_cpumask_var(desc->affinity);
456 return false;
457 }
458 cpumask_clear(desc->pending_mask);
459#endif
460 return true;
461}
462
463/**
464 * init_copy_desc_masks - copy cpumasks for irq_desc
465 * @old_desc: pointer to old irq_desc struct
466 * @new_desc: pointer to new irq_desc struct
467 *
468 * Insures affinity and pending_masks are copied to new irq_desc.
469 * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the
470 * irq_desc struct so the copy is redundant.
471 */
472
473static inline void init_copy_desc_masks(struct irq_desc *old_desc,
474 struct irq_desc *new_desc)
475{
476#ifdef CONFIG_CPUMASKS_OFFSTACK
477 cpumask_copy(new_desc->affinity, old_desc->affinity);
478
479#ifdef CONFIG_GENERIC_PENDING_IRQ
480 cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);
481#endif
482#endif
483}
484
485#else /* !CONFIG_SMP */
486
487static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
488 bool boot)
489{
490 return true;
491}
492
493static inline void init_copy_desc_masks(struct irq_desc *old_desc,
494 struct irq_desc *new_desc)
495{
496}
497
498#endif /* CONFIG_SMP */
499
425#endif /* _LINUX_IRQ_H */ 500#endif /* _LINUX_IRQ_H */