irqdesc.h 4.3 KB

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