internals.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * IRQ subsystem internal functions and variables:
  3. */
  4. #include <linux/irqdesc.h>
  5. extern int noirqdebug;
  6. #define irq_data_to_desc(data) container_of(data, struct irq_desc, irq_data)
  7. /* Set default functions for irq_chip structures: */
  8. extern void irq_chip_set_defaults(struct irq_chip *chip);
  9. /* Set default handler: */
  10. extern void compat_irq_chip_set_default_handler(struct irq_desc *desc);
  11. extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
  12. unsigned long flags);
  13. extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp);
  14. extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
  15. extern struct lock_class_key irq_desc_lock_class;
  16. extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
  17. extern void clear_kstat_irqs(struct irq_desc *desc);
  18. extern raw_spinlock_t sparse_irq_lock;
  19. /* Resending of interrupts :*/
  20. void check_irq_resend(struct irq_desc *desc, unsigned int irq);
  21. #ifdef CONFIG_SPARSE_IRQ
  22. void replace_irq_desc(unsigned int irq, struct irq_desc *desc);
  23. #endif
  24. #ifdef CONFIG_PROC_FS
  25. extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
  26. extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
  27. extern void register_handler_proc(unsigned int irq, struct irqaction *action);
  28. extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
  29. #else
  30. static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
  31. static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
  32. static inline void register_handler_proc(unsigned int irq,
  33. struct irqaction *action) { }
  34. static inline void unregister_handler_proc(unsigned int irq,
  35. struct irqaction *action) { }
  36. #endif
  37. extern int irq_select_affinity_usr(unsigned int irq);
  38. extern void irq_set_thread_affinity(struct irq_desc *desc);
  39. #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
  40. static inline void irq_end(unsigned int irq, struct irq_desc *desc)
  41. {
  42. if (desc->irq_data.chip && desc->irq_data.chip->end)
  43. desc->irq_data.chip->end(irq);
  44. }
  45. #else
  46. static inline void irq_end(unsigned int irq, struct irq_desc *desc) { }
  47. #endif
  48. /* Inline functions for support of irq chips on slow busses */
  49. static inline void chip_bus_lock(struct irq_desc *desc)
  50. {
  51. if (unlikely(desc->irq_data.chip->irq_bus_lock))
  52. desc->irq_data.chip->irq_bus_lock(&desc->irq_data);
  53. }
  54. static inline void chip_bus_sync_unlock(struct irq_desc *desc)
  55. {
  56. if (unlikely(desc->irq_data.chip->irq_bus_sync_unlock))
  57. desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
  58. }
  59. /*
  60. * Debugging printout:
  61. */
  62. #include <linux/kallsyms.h>
  63. #define P(f) if (desc->status & f) printk("%14s set\n", #f)
  64. static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
  65. {
  66. printk("irq %d, desc: %p, depth: %d, count: %d, unhandled: %d\n",
  67. irq, desc, desc->depth, desc->irq_count, desc->irqs_unhandled);
  68. printk("->handle_irq(): %p, ", desc->handle_irq);
  69. print_symbol("%s\n", (unsigned long)desc->handle_irq);
  70. printk("->irq_data.chip(): %p, ", desc->irq_data.chip);
  71. print_symbol("%s\n", (unsigned long)desc->irq_data.chip);
  72. printk("->action(): %p\n", desc->action);
  73. if (desc->action) {
  74. printk("->action->handler(): %p, ", desc->action->handler);
  75. print_symbol("%s\n", (unsigned long)desc->action->handler);
  76. }
  77. P(IRQ_INPROGRESS);
  78. P(IRQ_DISABLED);
  79. P(IRQ_PENDING);
  80. P(IRQ_REPLAY);
  81. P(IRQ_AUTODETECT);
  82. P(IRQ_WAITING);
  83. P(IRQ_LEVEL);
  84. P(IRQ_MASKED);
  85. #ifdef CONFIG_IRQ_PER_CPU
  86. P(IRQ_PER_CPU);
  87. #endif
  88. P(IRQ_NOPROBE);
  89. P(IRQ_NOREQUEST);
  90. P(IRQ_NOAUTOEN);
  91. }
  92. #undef P
  93. /* Stuff below will be cleaned up after the sparse allocator is done */
  94. #ifdef CONFIG_SMP
  95. /**
  96. * alloc_desc_masks - allocate cpumasks for irq_desc
  97. * @desc: pointer to irq_desc struct
  98. * @node: node which will be handling the cpumasks
  99. * @boot: true if need bootmem
  100. *
  101. * Allocates affinity and pending_mask cpumask if required.
  102. * Returns true if successful (or not required).
  103. */
  104. static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
  105. bool boot)
  106. {
  107. gfp_t gfp = GFP_ATOMIC;
  108. if (boot)
  109. gfp = GFP_NOWAIT;
  110. #ifdef CONFIG_CPUMASK_OFFSTACK
  111. if (!alloc_cpumask_var_node(&desc->irq_data.affinity, gfp, node))
  112. return false;
  113. #ifdef CONFIG_GENERIC_PENDING_IRQ
  114. if (!alloc_cpumask_var_node(&desc->pending_mask, gfp, node)) {
  115. free_cpumask_var(desc->irq_data.affinity);
  116. return false;
  117. }
  118. #endif
  119. #endif
  120. return true;
  121. }
  122. static inline void init_desc_masks(struct irq_desc *desc)
  123. {
  124. cpumask_setall(desc->irq_data.affinity);
  125. #ifdef CONFIG_GENERIC_PENDING_IRQ
  126. cpumask_clear(desc->pending_mask);
  127. #endif
  128. }
  129. /**
  130. * init_copy_desc_masks - copy cpumasks for irq_desc
  131. * @old_desc: pointer to old irq_desc struct
  132. * @new_desc: pointer to new irq_desc struct
  133. *
  134. * Insures affinity and pending_masks are copied to new irq_desc.
  135. * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the
  136. * irq_desc struct so the copy is redundant.
  137. */
  138. static inline void init_copy_desc_masks(struct irq_desc *old_desc,
  139. struct irq_desc *new_desc)
  140. {
  141. #ifdef CONFIG_CPUMASK_OFFSTACK
  142. cpumask_copy(new_desc->irq_data.affinity, old_desc->irq_data.affinity);
  143. #ifdef CONFIG_GENERIC_PENDING_IRQ
  144. cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);
  145. #endif
  146. #endif
  147. }
  148. static inline void free_desc_masks(struct irq_desc *old_desc,
  149. struct irq_desc *new_desc)
  150. {
  151. free_cpumask_var(old_desc->irq_data.affinity);
  152. #ifdef CONFIG_GENERIC_PENDING_IRQ
  153. free_cpumask_var(old_desc->pending_mask);
  154. #endif
  155. }
  156. #else /* !CONFIG_SMP */
  157. static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
  158. bool boot)
  159. {
  160. return true;
  161. }
  162. static inline void init_desc_masks(struct irq_desc *desc)
  163. {
  164. }
  165. static inline void init_copy_desc_masks(struct irq_desc *old_desc,
  166. struct irq_desc *new_desc)
  167. {
  168. }
  169. static inline void free_desc_masks(struct irq_desc *old_desc,
  170. struct irq_desc *new_desc)
  171. {
  172. }
  173. #endif /* CONFIG_SMP */