irq.h 6.9 KB

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