0001
0002 #ifndef _LINUX_IRQDESC_H
0003 #define _LINUX_IRQDESC_H
0004
0005 #include <linux/rcupdate.h>
0006 #include <linux/kobject.h>
0007 #include <linux/mutex.h>
0008
0009
0010
0011
0012
0013 struct irq_affinity_notify;
0014 struct proc_dir_entry;
0015 struct module;
0016 struct irq_desc;
0017 struct irq_domain;
0018 struct pt_regs;
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 struct irq_desc {
0056 struct irq_common_data irq_common_data;
0057 struct irq_data irq_data;
0058 unsigned int __percpu *kstat_irqs;
0059 irq_flow_handler_t handle_irq;
0060 struct irqaction *action;
0061 unsigned int status_use_accessors;
0062 unsigned int core_internal_state__do_not_mess_with_it;
0063 unsigned int depth;
0064 unsigned int wake_depth;
0065 unsigned int tot_count;
0066 unsigned int irq_count;
0067 unsigned long last_unhandled;
0068 unsigned int irqs_unhandled;
0069 atomic_t threads_handled;
0070 int threads_handled_last;
0071 raw_spinlock_t lock;
0072 struct cpumask *percpu_enabled;
0073 const struct cpumask *percpu_affinity;
0074 #ifdef CONFIG_SMP
0075 const struct cpumask *affinity_hint;
0076 struct irq_affinity_notify *affinity_notify;
0077 #ifdef CONFIG_GENERIC_PENDING_IRQ
0078 cpumask_var_t pending_mask;
0079 #endif
0080 #endif
0081 unsigned long threads_oneshot;
0082 atomic_t threads_active;
0083 wait_queue_head_t wait_for_threads;
0084 #ifdef CONFIG_PM_SLEEP
0085 unsigned int nr_actions;
0086 unsigned int no_suspend_depth;
0087 unsigned int cond_suspend_depth;
0088 unsigned int force_resume_depth;
0089 #endif
0090 #ifdef CONFIG_PROC_FS
0091 struct proc_dir_entry *dir;
0092 #endif
0093 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
0094 struct dentry *debugfs_file;
0095 const char *dev_name;
0096 #endif
0097 #ifdef CONFIG_SPARSE_IRQ
0098 struct rcu_head rcu;
0099 struct kobject kobj;
0100 #endif
0101 struct mutex request_mutex;
0102 int parent_irq;
0103 struct module *owner;
0104 const char *name;
0105 } ____cacheline_internodealigned_in_smp;
0106
0107 #ifdef CONFIG_SPARSE_IRQ
0108 extern void irq_lock_sparse(void);
0109 extern void irq_unlock_sparse(void);
0110 #else
0111 static inline void irq_lock_sparse(void) { }
0112 static inline void irq_unlock_sparse(void) { }
0113 extern struct irq_desc irq_desc[NR_IRQS];
0114 #endif
0115
0116 static inline unsigned int irq_desc_kstat_cpu(struct irq_desc *desc,
0117 unsigned int cpu)
0118 {
0119 return desc->kstat_irqs ? *per_cpu_ptr(desc->kstat_irqs, cpu) : 0;
0120 }
0121
0122 static inline struct irq_desc *irq_data_to_desc(struct irq_data *data)
0123 {
0124 return container_of(data->common, struct irq_desc, irq_common_data);
0125 }
0126
0127 static inline unsigned int irq_desc_get_irq(struct irq_desc *desc)
0128 {
0129 return desc->irq_data.irq;
0130 }
0131
0132 static inline struct irq_data *irq_desc_get_irq_data(struct irq_desc *desc)
0133 {
0134 return &desc->irq_data;
0135 }
0136
0137 static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
0138 {
0139 return desc->irq_data.chip;
0140 }
0141
0142 static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
0143 {
0144 return desc->irq_data.chip_data;
0145 }
0146
0147 static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
0148 {
0149 return desc->irq_common_data.handler_data;
0150 }
0151
0152
0153
0154
0155
0156 static inline void generic_handle_irq_desc(struct irq_desc *desc)
0157 {
0158 desc->handle_irq(desc);
0159 }
0160
0161 int handle_irq_desc(struct irq_desc *desc);
0162 int generic_handle_irq(unsigned int irq);
0163 int generic_handle_irq_safe(unsigned int irq);
0164
0165 #ifdef CONFIG_IRQ_DOMAIN
0166
0167
0168
0169
0170
0171 int generic_handle_domain_irq(struct irq_domain *domain, unsigned int hwirq);
0172 int generic_handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq);
0173 #endif
0174
0175
0176 static inline int irq_desc_has_action(struct irq_desc *desc)
0177 {
0178 return desc && desc->action != NULL;
0179 }
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191 static inline void irq_set_handler_locked(struct irq_data *data,
0192 irq_flow_handler_t handler)
0193 {
0194 struct irq_desc *desc = irq_data_to_desc(data);
0195
0196 desc->handle_irq = handler;
0197 }
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211 static inline void
0212 irq_set_chip_handler_name_locked(struct irq_data *data,
0213 const struct irq_chip *chip,
0214 irq_flow_handler_t handler, const char *name)
0215 {
0216 struct irq_desc *desc = irq_data_to_desc(data);
0217
0218 desc->handle_irq = handler;
0219 desc->name = name;
0220 data->chip = (struct irq_chip *)chip;
0221 }
0222
0223 bool irq_check_status_bit(unsigned int irq, unsigned int bitmask);
0224
0225 static inline bool irq_balancing_disabled(unsigned int irq)
0226 {
0227 return irq_check_status_bit(irq, IRQ_NO_BALANCING_MASK);
0228 }
0229
0230 static inline bool irq_is_percpu(unsigned int irq)
0231 {
0232 return irq_check_status_bit(irq, IRQ_PER_CPU);
0233 }
0234
0235 static inline bool irq_is_percpu_devid(unsigned int irq)
0236 {
0237 return irq_check_status_bit(irq, IRQ_PER_CPU_DEVID);
0238 }
0239
0240 void __irq_set_lockdep_class(unsigned int irq, struct lock_class_key *lock_class,
0241 struct lock_class_key *request_class);
0242 static inline void
0243 irq_set_lockdep_class(unsigned int irq, struct lock_class_key *lock_class,
0244 struct lock_class_key *request_class)
0245 {
0246 if (IS_ENABLED(CONFIG_LOCKDEP))
0247 __irq_set_lockdep_class(irq, lock_class, request_class);
0248 }
0249
0250 #endif