1 #ifndef _LINUX_IRQDESC_H
2 #define _LINUX_IRQDESC_H
5 * Core internal functions to deal with irq descriptors
7 * This include will move to kernel/irq once we cleaned up the tree.
8 * For now it's included from <linux/irq.h>
11 struct proc_dir_entry;
12 struct timer_rand_state;
14 * struct irq_desc - interrupt descriptor
15 * @irq_data: per irq and chip data passed down to chip functions
16 * @timer_rand_state: pointer to timer rand state struct
17 * @kstat_irqs: irq stats per cpu
18 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
19 * @action: the irq action chain
20 * @status: status information
21 * @depth: disable-depth, for nested irq_disable() calls
22 * @wake_depth: enable depth, for multiple set_irq_wake() callers
23 * @irq_count: stats field to detect stalled irqs
24 * @last_unhandled: aging timer for unhandled count
25 * @irqs_unhandled: stats field for spurious unhandled interrupts
26 * @lock: locking for SMP
27 * @pending_mask: pending rebalanced interrupts
28 * @threads_active: number of irqaction threads currently running
29 * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
30 * @dir: /proc/irq/ procfs entry
31 * @name: flow handler name for /proc/interrupts output
35 #ifdef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
36 struct irq_data irq_data;
39 * This union will go away, once we fixed the direct access to
40 * irq_desc all over the place. The direct fields are a 1:1
41 * overlay of irq_data.
44 struct irq_data irq_data;
48 struct irq_chip *chip;
51 struct msi_desc *msi_desc;
53 cpumask_var_t affinity;
59 struct timer_rand_state *timer_rand_state;
60 unsigned int *kstat_irqs;
61 irq_flow_handler_t handle_irq;
62 struct irqaction *action; /* IRQ action list */
63 unsigned int status; /* IRQ status */
65 unsigned int depth; /* nested irq disables */
66 unsigned int wake_depth; /* nested wake enables */
67 unsigned int irq_count; /* For detecting broken IRQs */
68 unsigned long last_unhandled; /* Aging timer for unhandled count */
69 unsigned int irqs_unhandled;
72 const struct cpumask *affinity_hint;
73 #ifdef CONFIG_GENERIC_PENDING_IRQ
74 cpumask_var_t pending_mask;
77 atomic_t threads_active;
78 wait_queue_head_t wait_for_threads;
80 struct proc_dir_entry *dir;
83 } ____cacheline_internodealigned_in_smp;
85 extern void arch_init_copy_chip_data(struct irq_desc *old_desc,
86 struct irq_desc *desc, int node);
87 extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc);
89 #ifndef CONFIG_SPARSE_IRQ
90 extern struct irq_desc irq_desc[NR_IRQS];
93 #ifdef CONFIG_NUMA_IRQ_DESC
94 extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int node);
96 static inline struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
102 extern struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node);
104 #ifdef CONFIG_GENERIC_HARDIRQS
106 #define get_irq_desc_chip(desc) ((desc)->irq_data.chip)
107 #define get_irq_desc_chip_data(desc) ((desc)->irq_data.chip_data)
108 #define get_irq_desc_data(desc) ((desc)->irq_data.handler_data)
109 #define get_irq_desc_msi(desc) ((desc)->irq_data.msi_desc)
112 * Monolithic do_IRQ implementation.
114 #ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
115 extern unsigned int __do_IRQ(unsigned int irq);
119 * Architectures call this to let the generic IRQ layer
120 * handle an interrupt. If the descriptor is attached to an
121 * irqchip-style controller then we call the ->handle_irq() handler,
122 * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
124 static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
126 #ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
127 desc->handle_irq(irq, desc);
129 if (likely(desc->handle_irq))
130 desc->handle_irq(irq, desc);
136 static inline void generic_handle_irq(unsigned int irq)
138 generic_handle_irq_desc(irq, irq_to_desc(irq));
141 /* Test to see if a driver has successfully requested an irq */
142 static inline int irq_has_action(unsigned int irq)
144 struct irq_desc *desc = irq_to_desc(irq);
145 return desc->action != NULL;
148 static inline int irq_balancing_disabled(unsigned int irq)
150 struct irq_desc *desc;
152 desc = irq_to_desc(irq);
153 return desc->status & IRQ_NO_BALANCING_MASK;
156 /* caller has locked the irq_desc and both params are valid */
157 static inline void __set_irq_handler_unlocked(int irq,
158 irq_flow_handler_t handler)
160 struct irq_desc *desc;
162 desc = irq_to_desc(irq);
163 desc->handle_irq = handler;