irqdesc.h 4.4 KB

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