irqdesc.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. struct irq_data irq_data;
  37. struct timer_rand_state *timer_rand_state;
  38. unsigned int __percpu *kstat_irqs;
  39. irq_flow_handler_t handle_irq;
  40. #ifdef CONFIG_IRQ_PREFLOW_FASTEOI
  41. irq_preflow_handler_t preflow_handler;
  42. #endif
  43. struct irqaction *action; /* IRQ action list */
  44. unsigned int status_use_accessors;
  45. unsigned int core_internal_state__do_not_mess_with_it;
  46. unsigned int depth; /* nested irq disables */
  47. unsigned int wake_depth; /* nested wake enables */
  48. unsigned int irq_count; /* For detecting broken IRQs */
  49. unsigned long last_unhandled; /* Aging timer for unhandled count */
  50. unsigned int irqs_unhandled;
  51. raw_spinlock_t lock;
  52. #ifdef CONFIG_SMP
  53. const struct cpumask *affinity_hint;
  54. struct irq_affinity_notify *affinity_notify;
  55. #ifdef CONFIG_GENERIC_PENDING_IRQ
  56. cpumask_var_t pending_mask;
  57. #endif
  58. #endif
  59. unsigned long threads_oneshot;
  60. atomic_t threads_active;
  61. wait_queue_head_t wait_for_threads;
  62. #ifdef CONFIG_PROC_FS
  63. struct proc_dir_entry *dir;
  64. #endif
  65. const char *name;
  66. } ____cacheline_internodealigned_in_smp;
  67. #ifndef CONFIG_SPARSE_IRQ
  68. extern struct irq_desc irq_desc[NR_IRQS];
  69. #endif
  70. #ifdef CONFIG_GENERIC_HARDIRQS
  71. static inline struct irq_data *irq_desc_get_irq_data(struct irq_desc *desc)
  72. {
  73. return &desc->irq_data;
  74. }
  75. static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
  76. {
  77. return desc->irq_data.chip;
  78. }
  79. static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
  80. {
  81. return desc->irq_data.chip_data;
  82. }
  83. static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
  84. {
  85. return desc->irq_data.handler_data;
  86. }
  87. static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
  88. {
  89. return desc->irq_data.msi_desc;
  90. }
  91. /*
  92. * Architectures call this to let the generic IRQ layer
  93. * handle an interrupt. If the descriptor is attached to an
  94. * irqchip-style controller then we call the ->handle_irq() handler,
  95. * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
  96. */
  97. static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
  98. {
  99. desc->handle_irq(irq, desc);
  100. }
  101. static inline void generic_handle_irq(unsigned int irq)
  102. {
  103. generic_handle_irq_desc(irq, irq_to_desc(irq));
  104. }
  105. /* Test to see if a driver has successfully requested an irq */
  106. static inline int irq_has_action(unsigned int irq)
  107. {
  108. struct irq_desc *desc = irq_to_desc(irq);
  109. return desc->action != NULL;
  110. }
  111. /* caller has locked the irq_desc and both params are valid */
  112. static inline void __irq_set_handler_locked(unsigned int irq,
  113. irq_flow_handler_t handler)
  114. {
  115. struct irq_desc *desc;
  116. desc = irq_to_desc(irq);
  117. desc->handle_irq = handler;
  118. }
  119. /* caller has locked the irq_desc and both params are valid */
  120. static inline void
  121. __irq_set_chip_handler_name_locked(unsigned int irq, struct irq_chip *chip,
  122. irq_flow_handler_t handler, const char *name)
  123. {
  124. struct irq_desc *desc;
  125. desc = irq_to_desc(irq);
  126. irq_desc_get_irq_data(desc)->chip = chip;
  127. desc->handle_irq = handler;
  128. desc->name = name;
  129. }
  130. static inline int irq_balancing_disabled(unsigned int irq)
  131. {
  132. struct irq_desc *desc;
  133. desc = irq_to_desc(irq);
  134. return desc->status_use_accessors & IRQ_NO_BALANCING_MASK;
  135. }
  136. static inline void
  137. irq_set_lockdep_class(unsigned int irq, struct lock_class_key *class)
  138. {
  139. struct irq_desc *desc = irq_to_desc(irq);
  140. if (desc)
  141. lockdep_set_class(&desc->lock, class);
  142. }
  143. #ifdef CONFIG_IRQ_PREFLOW_FASTEOI
  144. static inline void
  145. __irq_set_preflow_handler(unsigned int irq, irq_preflow_handler_t handler)
  146. {
  147. struct irq_desc *desc;
  148. desc = irq_to_desc(irq);
  149. desc->preflow_handler = handler;
  150. }
  151. #endif
  152. #endif
  153. #endif