irq.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. #ifndef _LINUX_IRQ_H
  2. #define _LINUX_IRQ_H
  3. /*
  4. * Please do not include this file in generic code. There is currently
  5. * no requirement for any architecture to implement anything held
  6. * within this file.
  7. *
  8. * Thanks. --rmk
  9. */
  10. #include <linux/smp.h>
  11. #ifndef CONFIG_S390
  12. #include <linux/linkage.h>
  13. #include <linux/cache.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/cpumask.h>
  16. #include <linux/irqreturn.h>
  17. #include <asm/irq.h>
  18. #include <asm/ptrace.h>
  19. /*
  20. * IRQ line status.
  21. */
  22. #define IRQ_INPROGRESS 1 /* IRQ handler active - do not enter! */
  23. #define IRQ_DISABLED 2 /* IRQ disabled - do not enter! */
  24. #define IRQ_PENDING 4 /* IRQ pending - replay on enable */
  25. #define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */
  26. #define IRQ_AUTODETECT 16 /* IRQ is being autodetected */
  27. #define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */
  28. #define IRQ_LEVEL 64 /* IRQ level triggered */
  29. #define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */
  30. #ifdef CONFIG_IRQ_PER_CPU
  31. # define IRQ_PER_CPU 256 /* IRQ is per CPU */
  32. # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
  33. #else
  34. # define CHECK_IRQ_PER_CPU(var) 0
  35. #endif
  36. /**
  37. * struct hw_interrupt_type - hardware interrupt type descriptor
  38. *
  39. * @name: name for /proc/interrupts
  40. * @startup: start up the interrupt (defaults to ->enable if NULL)
  41. * @shutdown: shut down the interrupt (defaults to ->disable if NULL)
  42. * @enable: enable the interrupt (defaults to chip->unmask if NULL)
  43. * @disable: disable the interrupt (defaults to chip->mask if NULL)
  44. * @handle_irq: irq flow handler called from the arch IRQ glue code
  45. * @ack: start of a new interrupt
  46. * @mask: mask an interrupt source
  47. * @mask_ack: ack and mask an interrupt source
  48. * @unmask: unmask an interrupt source
  49. * @hold: same interrupt while the handler is running
  50. * @end: end of interrupt
  51. * @set_affinity: set the CPU affinity on SMP machines
  52. * @retrigger: resend an IRQ to the CPU
  53. * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
  54. * @set_wake: enable/disable power-management wake-on of an IRQ
  55. *
  56. * @release: release function solely used by UML
  57. */
  58. struct hw_interrupt_type {
  59. const char *typename;
  60. unsigned int (*startup)(unsigned int irq);
  61. void (*shutdown)(unsigned int irq);
  62. void (*enable)(unsigned int irq);
  63. void (*disable)(unsigned int irq);
  64. void (*ack)(unsigned int irq);
  65. void (*end)(unsigned int irq);
  66. void (*set_affinity)(unsigned int irq, cpumask_t dest);
  67. int (*retrigger)(unsigned int irq);
  68. /* Currently used only by UML, might disappear one day.*/
  69. #ifdef CONFIG_IRQ_RELEASE_METHOD
  70. void (*release)(unsigned int irq, void *dev_id);
  71. #endif
  72. };
  73. typedef struct hw_interrupt_type hw_irq_controller;
  74. struct proc_dir_entry;
  75. /**
  76. * struct irq_desc - interrupt descriptor
  77. *
  78. * @handler: interrupt type dependent handler functions
  79. * @handler_data: data for the type handlers
  80. * @action: the irq action chain
  81. * @status: status information
  82. * @depth: disable-depth, for nested irq_disable() calls
  83. * @irq_count: stats field to detect stalled irqs
  84. * @irqs_unhandled: stats field for spurious unhandled interrupts
  85. * @lock: locking for SMP
  86. * @affinity: IRQ affinity on SMP
  87. * @pending_mask: pending rebalanced interrupts
  88. * @move_irq: need to re-target IRQ destination
  89. * @dir: /proc/irq/ procfs entry
  90. * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP
  91. *
  92. * Pad this out to 32 bytes for cache and indexing reasons.
  93. */
  94. struct irq_desc {
  95. hw_irq_controller *chip;
  96. void *chip_data;
  97. struct irqaction *action; /* IRQ action list */
  98. unsigned int status; /* IRQ status */
  99. unsigned int depth; /* nested irq disables */
  100. unsigned int irq_count; /* For detecting broken IRQs */
  101. unsigned int irqs_unhandled;
  102. spinlock_t lock;
  103. #ifdef CONFIG_SMP
  104. cpumask_t affinity;
  105. #endif
  106. #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
  107. cpumask_t pending_mask;
  108. unsigned int move_irq; /* need to re-target IRQ dest */
  109. #endif
  110. #ifdef CONFIG_PROC_FS
  111. struct proc_dir_entry *dir;
  112. #endif
  113. } ____cacheline_aligned;
  114. extern struct irq_desc irq_desc[NR_IRQS];
  115. /*
  116. * Migration helpers for obsolete names, they will go away:
  117. */
  118. typedef struct irq_desc irq_desc_t;
  119. /*
  120. * Pick up the arch-dependent methods:
  121. */
  122. #include <asm/hw_irq.h>
  123. extern int setup_irq(unsigned int irq, struct irqaction *new);
  124. #ifdef CONFIG_GENERIC_HARDIRQS
  125. #ifdef CONFIG_SMP
  126. static inline void set_native_irq_info(int irq, cpumask_t mask)
  127. {
  128. irq_desc[irq].affinity = mask;
  129. }
  130. #else
  131. static inline void set_native_irq_info(int irq, cpumask_t mask)
  132. {
  133. }
  134. #endif
  135. #ifdef CONFIG_SMP
  136. #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
  137. void set_pending_irq(unsigned int irq, cpumask_t mask);
  138. void move_native_irq(int irq);
  139. #ifdef CONFIG_PCI_MSI
  140. /*
  141. * Wonder why these are dummies?
  142. * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq()
  143. * counter part after translating the vector to irq info. We need to perform
  144. * this operation on the real irq, when we dont use vector, i.e when
  145. * pci_use_vector() is false.
  146. */
  147. static inline void move_irq(int irq)
  148. {
  149. }
  150. static inline void set_irq_info(int irq, cpumask_t mask)
  151. {
  152. }
  153. #else /* CONFIG_PCI_MSI */
  154. static inline void move_irq(int irq)
  155. {
  156. move_native_irq(irq);
  157. }
  158. static inline void set_irq_info(int irq, cpumask_t mask)
  159. {
  160. set_native_irq_info(irq, mask);
  161. }
  162. #endif /* CONFIG_PCI_MSI */
  163. #else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */
  164. static inline void move_irq(int irq)
  165. {
  166. }
  167. static inline void move_native_irq(int irq)
  168. {
  169. }
  170. static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
  171. {
  172. }
  173. static inline void set_irq_info(int irq, cpumask_t mask)
  174. {
  175. set_native_irq_info(irq, mask);
  176. }
  177. #endif /* CONFIG_GENERIC_PENDING_IRQ */
  178. #else /* CONFIG_SMP */
  179. #define move_irq(x)
  180. #define move_native_irq(x)
  181. #endif /* CONFIG_SMP */
  182. #ifdef CONFIG_IRQBALANCE
  183. extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
  184. #else
  185. static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
  186. {
  187. }
  188. #endif
  189. #ifdef CONFIG_AUTO_IRQ_AFFINITY
  190. extern int select_smp_affinity(unsigned int irq);
  191. #else
  192. static inline int select_smp_affinity(unsigned int irq)
  193. {
  194. return 1;
  195. }
  196. #endif
  197. extern int no_irq_affinity;
  198. extern int noirqdebug_setup(char *str);
  199. extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
  200. struct irqaction *action);
  201. /*
  202. * Explicit fastcall, because i386 4KSTACKS calls it from assembly:
  203. */
  204. extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
  205. extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
  206. int action_ret, struct pt_regs *regs);
  207. extern int can_request_irq(unsigned int irq, unsigned long irqflags);
  208. /* Resending of interrupts :*/
  209. void check_irq_resend(struct irq_desc *desc, unsigned int irq);
  210. extern void init_irq_proc(void);
  211. #endif /* CONFIG_GENERIC_HARDIRQS */
  212. extern hw_irq_controller no_irq_type; /* needed in every arch ? */
  213. #endif /* !CONFIG_S390 */
  214. #endif /* _LINUX_IRQ_H */