internals.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * IRQ subsystem internal functions and variables:
  3. *
  4. * Do not ever include this file from anything else than
  5. * kernel/irq/. Do not even think about using any information outside
  6. * of this file for your non core code.
  7. */
  8. #include <linux/irqdesc.h>
  9. #include <linux/kernel_stat.h>
  10. #ifdef CONFIG_SPARSE_IRQ
  11. # define IRQ_BITMAP_BITS (NR_IRQS + 8196)
  12. #else
  13. # define IRQ_BITMAP_BITS NR_IRQS
  14. #endif
  15. #define istate core_internal_state__do_not_mess_with_it
  16. extern bool noirqdebug;
  17. /*
  18. * Bits used by threaded handlers:
  19. * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
  20. * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
  21. * IRQTF_AFFINITY - irq thread is requested to adjust affinity
  22. * IRQTF_FORCED_THREAD - irq action is force threaded
  23. */
  24. enum {
  25. IRQTF_RUNTHREAD,
  26. IRQTF_WARNED,
  27. IRQTF_AFFINITY,
  28. IRQTF_FORCED_THREAD,
  29. };
  30. /*
  31. * Bit masks for desc->core_internal_state__do_not_mess_with_it
  32. *
  33. * IRQS_AUTODETECT - autodetection in progress
  34. * IRQS_SPURIOUS_DISABLED - was disabled due to spurious interrupt
  35. * detection
  36. * IRQS_POLL_INPROGRESS - polling in progress
  37. * IRQS_ONESHOT - irq is not unmasked in primary handler
  38. * IRQS_REPLAY - irq is replayed
  39. * IRQS_WAITING - irq is waiting
  40. * IRQS_PENDING - irq is pending and replayed later
  41. * IRQS_SUSPENDED - irq is suspended
  42. */
  43. enum {
  44. IRQS_AUTODETECT = 0x00000001,
  45. IRQS_SPURIOUS_DISABLED = 0x00000002,
  46. IRQS_POLL_INPROGRESS = 0x00000008,
  47. IRQS_ONESHOT = 0x00000020,
  48. IRQS_REPLAY = 0x00000040,
  49. IRQS_WAITING = 0x00000080,
  50. IRQS_PENDING = 0x00000200,
  51. IRQS_SUSPENDED = 0x00000800,
  52. };
  53. #include "debug.h"
  54. #include "settings.h"
  55. extern int __irq_set_trigger(struct irq_desc *desc, unsigned long flags);
  56. extern void __disable_irq(struct irq_desc *desc);
  57. extern void __enable_irq(struct irq_desc *desc);
  58. extern int irq_startup(struct irq_desc *desc, bool resend);
  59. extern void irq_shutdown(struct irq_desc *desc);
  60. extern void irq_enable(struct irq_desc *desc);
  61. extern void irq_disable(struct irq_desc *desc);
  62. extern void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu);
  63. extern void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu);
  64. extern void mask_irq(struct irq_desc *desc);
  65. extern void unmask_irq(struct irq_desc *desc);
  66. extern void unmask_threaded_irq(struct irq_desc *desc);
  67. #ifdef CONFIG_SPARSE_IRQ
  68. static inline void irq_mark_irq(unsigned int irq) { }
  69. #else
  70. extern void irq_mark_irq(unsigned int irq);
  71. #endif
  72. extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
  73. irqreturn_t handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action);
  74. irqreturn_t handle_irq_event(struct irq_desc *desc);
  75. /* Resending of interrupts :*/
  76. void check_irq_resend(struct irq_desc *desc);
  77. bool irq_wait_for_poll(struct irq_desc *desc);
  78. void __irq_wake_thread(struct irq_desc *desc, struct irqaction *action);
  79. #ifdef CONFIG_PROC_FS
  80. extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
  81. extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
  82. extern void register_handler_proc(unsigned int irq, struct irqaction *action);
  83. extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
  84. #else
  85. static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
  86. static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
  87. static inline void register_handler_proc(unsigned int irq,
  88. struct irqaction *action) { }
  89. static inline void unregister_handler_proc(unsigned int irq,
  90. struct irqaction *action) { }
  91. #endif
  92. extern int irq_select_affinity_usr(unsigned int irq, struct cpumask *mask);
  93. extern void irq_set_thread_affinity(struct irq_desc *desc);
  94. extern int irq_do_set_affinity(struct irq_data *data,
  95. const struct cpumask *dest, bool force);
  96. /* Inline functions for support of irq chips on slow busses */
  97. static inline void chip_bus_lock(struct irq_desc *desc)
  98. {
  99. if (unlikely(desc->irq_data.chip->irq_bus_lock))
  100. desc->irq_data.chip->irq_bus_lock(&desc->irq_data);
  101. }
  102. static inline void chip_bus_sync_unlock(struct irq_desc *desc)
  103. {
  104. if (unlikely(desc->irq_data.chip->irq_bus_sync_unlock))
  105. desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
  106. }
  107. #define _IRQ_DESC_CHECK (1 << 0)
  108. #define _IRQ_DESC_PERCPU (1 << 1)
  109. #define IRQ_GET_DESC_CHECK_GLOBAL (_IRQ_DESC_CHECK)
  110. #define IRQ_GET_DESC_CHECK_PERCPU (_IRQ_DESC_CHECK | _IRQ_DESC_PERCPU)
  111. struct irq_desc *
  112. __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
  113. unsigned int check);
  114. void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus);
  115. static inline struct irq_desc *
  116. irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int check)
  117. {
  118. return __irq_get_desc_lock(irq, flags, true, check);
  119. }
  120. static inline void
  121. irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags)
  122. {
  123. __irq_put_desc_unlock(desc, flags, true);
  124. }
  125. static inline struct irq_desc *
  126. irq_get_desc_lock(unsigned int irq, unsigned long *flags, unsigned int check)
  127. {
  128. return __irq_get_desc_lock(irq, flags, false, check);
  129. }
  130. static inline void
  131. irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags)
  132. {
  133. __irq_put_desc_unlock(desc, flags, false);
  134. }
  135. /*
  136. * Manipulation functions for irq_data.state
  137. */
  138. static inline void irqd_set_move_pending(struct irq_data *d)
  139. {
  140. __irqd_to_state(d) |= IRQD_SETAFFINITY_PENDING;
  141. }
  142. static inline void irqd_clr_move_pending(struct irq_data *d)
  143. {
  144. __irqd_to_state(d) &= ~IRQD_SETAFFINITY_PENDING;
  145. }
  146. static inline void irqd_clear(struct irq_data *d, unsigned int mask)
  147. {
  148. __irqd_to_state(d) &= ~mask;
  149. }
  150. static inline void irqd_set(struct irq_data *d, unsigned int mask)
  151. {
  152. __irqd_to_state(d) |= mask;
  153. }
  154. static inline bool irqd_has_set(struct irq_data *d, unsigned int mask)
  155. {
  156. return __irqd_to_state(d) & mask;
  157. }
  158. static inline void kstat_incr_irqs_this_cpu(struct irq_desc *desc)
  159. {
  160. __this_cpu_inc(*desc->kstat_irqs);
  161. __this_cpu_inc(kstat.irqs_sum);
  162. }
  163. static inline int irq_desc_get_node(struct irq_desc *desc)
  164. {
  165. return irq_common_data_get_node(&desc->irq_common_data);
  166. }
  167. #ifdef CONFIG_PM_SLEEP
  168. bool irq_pm_check_wakeup(struct irq_desc *desc);
  169. void irq_pm_install_action(struct irq_desc *desc, struct irqaction *action);
  170. void irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action);
  171. #else
  172. static inline bool irq_pm_check_wakeup(struct irq_desc *desc) { return false; }
  173. static inline void
  174. irq_pm_install_action(struct irq_desc *desc, struct irqaction *action) { }
  175. static inline void
  176. irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action) { }
  177. #endif