irqdesc.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #ifndef _LINUX_IRQDESC_H
  2. #define _LINUX_IRQDESC_H
  3. /*
  4. * Core internal functions to deal with irq descriptors
  5. *
  6. * This include will move to kernel/irq once we cleaned up the tree.
  7. * For now it's included from <linux/irq.h>
  8. */
  9. struct irq_affinity_notify;
  10. struct proc_dir_entry;
  11. struct timer_rand_state;
  12. /**
  13. * struct irq_desc - interrupt descriptor
  14. * @irq_data: per irq and chip data passed down to chip functions
  15. * @timer_rand_state: pointer to timer rand state struct
  16. * @kstat_irqs: irq stats per cpu
  17. * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
  18. * @action: the irq action chain
  19. * @status: status information
  20. * @core_internal_state__do_not_mess_with_it: core internal 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. * @affinity_notify: context for notification of affinity changes
  28. * @pending_mask: pending rebalanced interrupts
  29. * @threads_oneshot: bitfield to handle shared oneshot threads
  30. * @threads_active: number of irqaction threads currently running
  31. * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
  32. * @dir: /proc/irq/ procfs entry
  33. * @name: flow handler name for /proc/interrupts output
  34. */
  35. struct irq_desc {
  36. #ifdef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
  37. struct irq_data irq_data;
  38. #else
  39. /*
  40. * This union will go away, once we fixed the direct access to
  41. * irq_desc all over the place. The direct fields are a 1:1
  42. * overlay of irq_data.
  43. */
  44. union {
  45. struct irq_data irq_data;
  46. struct {
  47. unsigned int irq;
  48. unsigned int node;
  49. unsigned int pad_do_not_even_think_about_it;
  50. struct irq_chip *chip;
  51. void *handler_data;
  52. void *chip_data;
  53. struct msi_desc *msi_desc;
  54. #ifdef CONFIG_SMP
  55. cpumask_var_t affinity;
  56. #endif
  57. };
  58. };
  59. #endif
  60. struct timer_rand_state *timer_rand_state;
  61. unsigned int __percpu *kstat_irqs;
  62. irq_flow_handler_t handle_irq;
  63. #ifdef CONFIG_IRQ_PREFLOW_FASTEOI
  64. irq_preflow_handler_t preflow_handler;
  65. #endif
  66. struct irqaction *action; /* IRQ action list */
  67. #ifdef CONFIG_GENERIC_HARDIRQS_NO_COMPAT
  68. unsigned int status_use_accessors;
  69. #else
  70. unsigned int status; /* IRQ status */
  71. #endif
  72. unsigned int core_internal_state__do_not_mess_with_it;
  73. unsigned int depth; /* nested irq disables */
  74. unsigned int wake_depth; /* nested wake enables */
  75. unsigned int irq_count; /* For detecting broken IRQs */
  76. unsigned long last_unhandled; /* Aging timer for unhandled count */
  77. unsigned int irqs_unhandled;
  78. raw_spinlock_t lock;
  79. #ifdef CONFIG_SMP
  80. const struct cpumask *affinity_hint;
  81. struct irq_affinity_notify *affinity_notify;
  82. #ifdef CONFIG_GENERIC_PENDING_IRQ
  83. cpumask_var_t pending_mask;
  84. #endif
  85. #endif
  86. unsigned long threads_oneshot;
  87. atomic_t threads_active;
  88. wait_queue_head_t wait_for_threads;
  89. #ifdef CONFIG_PROC_FS
  90. struct proc_dir_entry *dir;
  91. #endif
  92. const char *name;
  93. } ____cacheline_internodealigned_in_smp;
  94. #ifndef CONFIG_SPARSE_IRQ
  95. extern struct irq_desc irq_desc[NR_IRQS];
  96. #endif
  97. /* Will be removed once the last users in power and sh are gone */
  98. extern struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node);
  99. static inline struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
  100. {
  101. return desc;
  102. }
  103. #ifdef CONFIG_GENERIC_HARDIRQS
  104. static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
  105. {
  106. return desc->irq_data.chip;
  107. }
  108. static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
  109. {
  110. return desc->irq_data.chip_data;
  111. }
  112. static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
  113. {
  114. return desc->irq_data.handler_data;
  115. }
  116. static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
  117. {
  118. return desc->irq_data.msi_desc;
  119. }
  120. #ifndef CONFIG_GENERIC_HARDIRQS_NO_COMPAT
  121. static inline struct irq_chip *get_irq_desc_chip(struct irq_desc *desc)
  122. {
  123. return irq_desc_get_chip(desc);
  124. }
  125. static inline void *get_irq_desc_data(struct irq_desc *desc)
  126. {
  127. return irq_desc_get_handler_data(desc);
  128. }
  129. static inline void *get_irq_desc_chip_data(struct irq_desc *desc)
  130. {
  131. return irq_desc_get_chip_data(desc);
  132. }
  133. static inline struct msi_desc *get_irq_desc_msi(struct irq_desc *desc)
  134. {
  135. return irq_desc_get_msi_desc(desc);
  136. }
  137. #endif
  138. /*
  139. * Architectures call this to let the generic IRQ layer
  140. * handle an interrupt. If the descriptor is attached to an
  141. * irqchip-style controller then we call the ->handle_irq() handler,
  142. * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
  143. */
  144. static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
  145. {
  146. desc->handle_irq(irq, desc);
  147. }
  148. static inline void generic_handle_irq(unsigned int irq)
  149. {
  150. generic_handle_irq_desc(irq, irq_to_desc(irq));
  151. }
  152. /* Test to see if a driver has successfully requested an irq */
  153. static inline int irq_has_action(unsigned int irq)
  154. {
  155. struct irq_desc *desc = irq_to_desc(irq);
  156. return desc->action != NULL;
  157. }
  158. #ifndef CONFIG_GENERIC_HARDIRQS_NO_COMPAT
  159. static inline int irq_balancing_disabled(unsigned int irq)
  160. {
  161. struct irq_desc *desc;
  162. desc = irq_to_desc(irq);
  163. return desc->status & IRQ_NO_BALANCING_MASK;
  164. }
  165. #endif
  166. /* caller has locked the irq_desc and both params are valid */
  167. static inline void __set_irq_handler_unlocked(int irq,
  168. irq_flow_handler_t handler)
  169. {
  170. struct irq_desc *desc;
  171. desc = irq_to_desc(irq);
  172. desc->handle_irq = handler;
  173. }
  174. #ifdef CONFIG_IRQ_PREFLOW_FASTEOI
  175. static inline void
  176. __irq_set_preflow_handler(unsigned int irq, irq_preflow_handler_t handler)
  177. {
  178. struct irq_desc *desc;
  179. desc = irq_to_desc(irq);
  180. desc->preflow_handler = handler;
  181. }
  182. #endif
  183. #endif
  184. #endif