irqdesc.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 proc_dir_entry;
  10. struct timer_rand_state;
  11. struct irq_2_iommu;
  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. * @depth: disable-depth, for nested irq_disable() calls
  21. * @wake_depth: enable depth, for multiple set_irq_wake() callers
  22. * @irq_count: stats field to detect stalled irqs
  23. * @last_unhandled: aging timer for unhandled count
  24. * @irqs_unhandled: stats field for spurious unhandled interrupts
  25. * @lock: locking for SMP
  26. * @pending_mask: pending rebalanced interrupts
  27. * @threads_active: number of irqaction threads currently running
  28. * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
  29. * @dir: /proc/irq/ procfs entry
  30. * @name: flow handler name for /proc/interrupts output
  31. */
  32. struct irq_desc {
  33. #ifdef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
  34. struct irq_data irq_data;
  35. #else
  36. /*
  37. * This union will go away, once we fixed the direct access to
  38. * irq_desc all over the place. The direct fields are a 1:1
  39. * overlay of irq_data.
  40. */
  41. union {
  42. struct irq_data irq_data;
  43. struct {
  44. unsigned int irq;
  45. unsigned int node;
  46. struct irq_chip *chip;
  47. void *handler_data;
  48. void *chip_data;
  49. struct msi_desc *msi_desc;
  50. #ifdef CONFIG_SMP
  51. cpumask_var_t affinity;
  52. #endif
  53. #ifdef CONFIG_INTR_REMAP
  54. struct irq_2_iommu *irq_2_iommu;
  55. #endif
  56. };
  57. };
  58. #endif
  59. struct timer_rand_state *timer_rand_state;
  60. unsigned int *kstat_irqs;
  61. irq_flow_handler_t handle_irq;
  62. struct irqaction *action; /* IRQ action list */
  63. unsigned int status; /* IRQ status */
  64. unsigned int depth; /* nested irq disables */
  65. unsigned int wake_depth; /* nested wake enables */
  66. unsigned int irq_count; /* For detecting broken IRQs */
  67. unsigned long last_unhandled; /* Aging timer for unhandled count */
  68. unsigned int irqs_unhandled;
  69. raw_spinlock_t lock;
  70. #ifdef CONFIG_SMP
  71. const struct cpumask *affinity_hint;
  72. #ifdef CONFIG_GENERIC_PENDING_IRQ
  73. cpumask_var_t pending_mask;
  74. #endif
  75. #endif
  76. atomic_t threads_active;
  77. wait_queue_head_t wait_for_threads;
  78. #ifdef CONFIG_PROC_FS
  79. struct proc_dir_entry *dir;
  80. #endif
  81. const char *name;
  82. } ____cacheline_internodealigned_in_smp;
  83. extern void arch_init_copy_chip_data(struct irq_desc *old_desc,
  84. struct irq_desc *desc, int node);
  85. extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc);
  86. #ifndef CONFIG_SPARSE_IRQ
  87. extern struct irq_desc irq_desc[NR_IRQS];
  88. #endif
  89. #ifdef CONFIG_NUMA_IRQ_DESC
  90. extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int node);
  91. #else
  92. static inline struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
  93. {
  94. return desc;
  95. }
  96. #endif
  97. extern struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node);
  98. #ifdef CONFIG_GENERIC_HARDIRQS
  99. #define get_irq_desc_chip(desc) ((desc)->irq_data.chip)
  100. #define get_irq_desc_chip_data(desc) ((desc)->irq_data.chip_data)
  101. #define get_irq_desc_data(desc) ((desc)->irq_data.handler_data)
  102. #define get_irq_desc_msi(desc) ((desc)->irq_data.msi_desc)
  103. /*
  104. * Monolithic do_IRQ implementation.
  105. */
  106. #ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
  107. extern unsigned int __do_IRQ(unsigned int irq);
  108. #endif
  109. /*
  110. * Architectures call this to let the generic IRQ layer
  111. * handle an interrupt. If the descriptor is attached to an
  112. * irqchip-style controller then we call the ->handle_irq() handler,
  113. * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
  114. */
  115. static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
  116. {
  117. #ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
  118. desc->handle_irq(irq, desc);
  119. #else
  120. if (likely(desc->handle_irq))
  121. desc->handle_irq(irq, desc);
  122. else
  123. __do_IRQ(irq);
  124. #endif
  125. }
  126. static inline void generic_handle_irq(unsigned int irq)
  127. {
  128. generic_handle_irq_desc(irq, irq_to_desc(irq));
  129. }
  130. /* Test to see if a driver has successfully requested an irq */
  131. static inline int irq_has_action(unsigned int irq)
  132. {
  133. struct irq_desc *desc = irq_to_desc(irq);
  134. return desc->action != NULL;
  135. }
  136. static inline int irq_balancing_disabled(unsigned int irq)
  137. {
  138. struct irq_desc *desc;
  139. desc = irq_to_desc(irq);
  140. return desc->status & IRQ_NO_BALANCING_MASK;
  141. }
  142. /* caller has locked the irq_desc and both params are valid */
  143. static inline void __set_irq_handler_unlocked(int irq,
  144. irq_flow_handler_t handler)
  145. {
  146. struct irq_desc *desc;
  147. desc = irq_to_desc(irq);
  148. desc->handle_irq = handler;
  149. }
  150. #endif
  151. #endif