irq.h 7.0 KB

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