Blame view

kernel/irq/internals.h 6.67 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  /*
   * IRQ subsystem internal functions and variables:
dbec07bac   Thomas Gleixner   genirq: Add inter...
3
4
5
6
   *
   * Do not ever include this file from anything else than
   * kernel/irq/. Do not even think about using any information outside
   * of this file for your non core code.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
   */
e144710b3   Thomas Gleixner   genirq: Distangle...
8
  #include <linux/irqdesc.h>
8f945a332   Thomas Gleixner   genirq: Move ksta...
9
  #include <linux/kernel_stat.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10

c1ee62642   Thomas Gleixner   genirq: Prevent a...
11
12
13
14
15
  #ifdef CONFIG_SPARSE_IRQ
  # define IRQ_BITMAP_BITS	(NR_IRQS + 8196)
  #else
  # define IRQ_BITMAP_BITS	NR_IRQS
  #endif
dbec07bac   Thomas Gleixner   genirq: Add inter...
16
  #define istate core_internal_state__do_not_mess_with_it
2329abfa3   Rusty Russell   module_param: mak...
17
  extern bool noirqdebug;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18

1535dfacb   Thomas Gleixner   genirq: Move irq ...
19
20
21
  /*
   * Bits used by threaded handlers:
   * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
1535dfacb   Thomas Gleixner   genirq: Move irq ...
22
23
   * IRQTF_WARNED    - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
   * IRQTF_AFFINITY  - irq thread is requested to adjust affinity
8d32a307e   Thomas Gleixner   genirq: Provide f...
24
   * IRQTF_FORCED_THREAD  - irq action is force threaded
1535dfacb   Thomas Gleixner   genirq: Move irq ...
25
26
27
   */
  enum {
  	IRQTF_RUNTHREAD,
1535dfacb   Thomas Gleixner   genirq: Move irq ...
28
29
  	IRQTF_WARNED,
  	IRQTF_AFFINITY,
8d32a307e   Thomas Gleixner   genirq: Provide f...
30
  	IRQTF_FORCED_THREAD,
1535dfacb   Thomas Gleixner   genirq: Move irq ...
31
  };
bd062e766   Thomas Gleixner   genirq: Move IRQ_...
32
  /*
a257954bb   Jiang Liu   genirq: Improve d...
33
   * Bit masks for desc->core_internal_state__do_not_mess_with_it
bd062e766   Thomas Gleixner   genirq: Move IRQ_...
34
35
   *
   * IRQS_AUTODETECT		- autodetection in progress
7acdd53e5   Thomas Gleixner   genirq: Move IRQ_...
36
37
   * IRQS_SPURIOUS_DISABLED	- was disabled due to spurious interrupt
   *				  detection
6954b75b4   Thomas Gleixner   genirq: Move IRQ_...
38
   * IRQS_POLL_INPROGRESS		- polling in progress
3d67baec7   Thomas Gleixner   genirq: Move IRQ_...
39
   * IRQS_ONESHOT			- irq is not unmasked in primary handler
163ef3091   Thomas Gleixner   genirq: Move IRQ_...
40
41
   * IRQS_REPLAY			- irq is replayed
   * IRQS_WAITING			- irq is waiting
2a0d6fb33   Thomas Gleixner   genirq: Move IRQ_...
42
   * IRQS_PENDING			- irq is pending and replayed later
c531e8361   Thomas Gleixner   genirq: Move IRQ_...
43
   * IRQS_SUSPENDED		- irq is suspended
bd062e766   Thomas Gleixner   genirq: Move IRQ_...
44
45
46
   */
  enum {
  	IRQS_AUTODETECT		= 0x00000001,
7acdd53e5   Thomas Gleixner   genirq: Move IRQ_...
47
  	IRQS_SPURIOUS_DISABLED	= 0x00000002,
6954b75b4   Thomas Gleixner   genirq: Move IRQ_...
48
  	IRQS_POLL_INPROGRESS	= 0x00000008,
3d67baec7   Thomas Gleixner   genirq: Move IRQ_...
49
  	IRQS_ONESHOT		= 0x00000020,
163ef3091   Thomas Gleixner   genirq: Move IRQ_...
50
51
  	IRQS_REPLAY		= 0x00000040,
  	IRQS_WAITING		= 0x00000080,
2a0d6fb33   Thomas Gleixner   genirq: Move IRQ_...
52
  	IRQS_PENDING		= 0x00000200,
c531e8361   Thomas Gleixner   genirq: Move IRQ_...
53
  	IRQS_SUSPENDED		= 0x00000800,
bd062e766   Thomas Gleixner   genirq: Move IRQ_...
54
  };
1ce6068da   Thomas Gleixner   genirq: Move debu...
55
56
  #include "debug.h"
  #include "settings.h"
a77c46359   Thomas Gleixner   genirq: Add new f...
57
  #define irq_data_to_desc(data)	container_of(data, struct irq_desc, irq_data)
0c5d1eb77   David Brownell   genirq: record tr...
58
59
  extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
  		unsigned long flags);
8df2e02c5   Thomas Gleixner   genirq: Move susp...
60
61
  extern void __disable_irq(struct irq_desc *desc, unsigned int irq);
  extern void __enable_irq(struct irq_desc *desc, unsigned int irq);
0c5d1eb77   David Brownell   genirq: record tr...
62

b4bc724e8   Thomas Gleixner   genirq: Handle pe...
63
  extern int irq_startup(struct irq_desc *desc, bool resend);
469992386   Thomas Gleixner   genirq: Consolida...
64
  extern void irq_shutdown(struct irq_desc *desc);
87923470c   Thomas Gleixner   genirq: Consolida...
65
66
  extern void irq_enable(struct irq_desc *desc);
  extern void irq_disable(struct irq_desc *desc);
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
67
68
  extern void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu);
  extern void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu);
d4d5e0896   Thomas Gleixner   genirq: Add IRQCH...
69
70
  extern void mask_irq(struct irq_desc *desc);
  extern void unmask_irq(struct irq_desc *desc);
328a4978d   Thomas Gleixner   genirq: Add a new...
71
  extern void unmask_threaded_irq(struct irq_desc *desc);
469992386   Thomas Gleixner   genirq: Consolida...
72

f63b6a05f   Thomas Gleixner   genirq: Replace r...
73
74
  #ifdef CONFIG_SPARSE_IRQ
  static inline void irq_mark_irq(unsigned int irq) { }
c291ee622   Thomas Gleixner   genirq: Prevent p...
75
76
  extern void irq_lock_sparse(void);
  extern void irq_unlock_sparse(void);
f63b6a05f   Thomas Gleixner   genirq: Replace r...
77
78
  #else
  extern void irq_mark_irq(unsigned int irq);
c291ee622   Thomas Gleixner   genirq: Prevent p...
79
80
  static inline void irq_lock_sparse(void) { }
  static inline void irq_unlock_sparse(void) { }
f63b6a05f   Thomas Gleixner   genirq: Replace r...
81
  #endif
85ac16d03   Yinghai Lu   x86/irq: change i...
82
  extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
0fa0ebbf1   Mike Travis   irq: allocate irq...
83

4912609f2   Thomas Gleixner   genirq: Implement...
84
85
  irqreturn_t handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action);
  irqreturn_t handle_irq_event(struct irq_desc *desc);
e144710b3   Thomas Gleixner   genirq: Distangle...
86
87
  /* Resending of interrupts :*/
  void check_irq_resend(struct irq_desc *desc, unsigned int irq);
fe200ae48   Thomas Gleixner   genirq: Mark poll...
88
  bool irq_wait_for_poll(struct irq_desc *desc);
a92444c6b   Thomas Gleixner   genirq: Provide i...
89
  void __irq_wake_thread(struct irq_desc *desc, struct irqaction *action);
e144710b3   Thomas Gleixner   genirq: Distangle...
90

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
  #ifdef CONFIG_PROC_FS
2c6927a38   Yinghai Lu   irq: replace loop...
92
  extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
13bfe99e0   Thomas Gleixner   genirq: Prepare p...
93
  extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94
95
96
  extern void register_handler_proc(unsigned int irq, struct irqaction *action);
  extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
  #else
2c6927a38   Yinghai Lu   irq: replace loop...
97
  static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
13bfe99e0   Thomas Gleixner   genirq: Prepare p...
98
  static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99
100
101
102
103
  static inline void register_handler_proc(unsigned int irq,
  					 struct irqaction *action) { }
  static inline void unregister_handler_proc(unsigned int irq,
  					   struct irqaction *action) { }
  #endif
3b8249e75   Thomas Gleixner   genirq: Do not co...
104
  extern int irq_select_affinity_usr(unsigned int irq, struct cpumask *mask);
f6d87f4bd   Thomas Gleixner   genirq: keep affi...
105

591d2fb02   Thomas Gleixner   genirq: Delegate ...
106
  extern void irq_set_thread_affinity(struct irq_desc *desc);
57b150cce   Yinghai Lu   irq: only update ...
107

818b0f3bf   Jiang Liu   genirq: Introduce...
108
109
  extern int irq_do_set_affinity(struct irq_data *data,
  			       const struct cpumask *dest, bool force);
70aedd24d   Thomas Gleixner   genirq: Add buslo...
110
  /* Inline functions for support of irq chips on slow busses */
3876ec9ef   Thomas Gleixner   genirq: Provide c...
111
  static inline void chip_bus_lock(struct irq_desc *desc)
70aedd24d   Thomas Gleixner   genirq: Add buslo...
112
  {
3876ec9ef   Thomas Gleixner   genirq: Provide c...
113
114
  	if (unlikely(desc->irq_data.chip->irq_bus_lock))
  		desc->irq_data.chip->irq_bus_lock(&desc->irq_data);
70aedd24d   Thomas Gleixner   genirq: Add buslo...
115
  }
3876ec9ef   Thomas Gleixner   genirq: Provide c...
116
  static inline void chip_bus_sync_unlock(struct irq_desc *desc)
70aedd24d   Thomas Gleixner   genirq: Add buslo...
117
  {
3876ec9ef   Thomas Gleixner   genirq: Provide c...
118
119
  	if (unlikely(desc->irq_data.chip->irq_bus_sync_unlock))
  		desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
70aedd24d   Thomas Gleixner   genirq: Add buslo...
120
  }
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
121
122
123
124
125
  #define _IRQ_DESC_CHECK		(1 << 0)
  #define _IRQ_DESC_PERCPU	(1 << 1)
  
  #define IRQ_GET_DESC_CHECK_GLOBAL	(_IRQ_DESC_CHECK)
  #define IRQ_GET_DESC_CHECK_PERCPU	(_IRQ_DESC_CHECK | _IRQ_DESC_PERCPU)
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
126
  struct irq_desc *
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
127
128
  __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
  		    unsigned int check);
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
129
130
131
  void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus);
  
  static inline struct irq_desc *
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
132
  irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int check)
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
133
  {
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
134
  	return __irq_get_desc_lock(irq, flags, true, check);
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
135
136
137
138
139
140
141
142
143
  }
  
  static inline void
  irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags)
  {
  	__irq_put_desc_unlock(desc, flags, true);
  }
  
  static inline struct irq_desc *
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
144
  irq_get_desc_lock(unsigned int irq, unsigned long *flags, unsigned int check)
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
145
  {
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
146
  	return __irq_get_desc_lock(irq, flags, false, check);
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
147
148
149
150
151
152
153
  }
  
  static inline void
  irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags)
  {
  	__irq_put_desc_unlock(desc, flags, false);
  }
43f777594   Ingo Molnar   [PATCH] genirq: m...
154
  /*
f230b6d5c   Thomas Gleixner   genirq: Add IRQ_M...
155
156
157
158
159
   * Manipulation functions for irq_data.state
   */
  static inline void irqd_set_move_pending(struct irq_data *d)
  {
  	d->state_use_accessors |= IRQD_SETAFFINITY_PENDING;
f230b6d5c   Thomas Gleixner   genirq: Add IRQ_M...
160
161
162
163
164
  }
  
  static inline void irqd_clr_move_pending(struct irq_data *d)
  {
  	d->state_use_accessors &= ~IRQD_SETAFFINITY_PENDING;
f230b6d5c   Thomas Gleixner   genirq: Add IRQ_M...
165
  }
a005677b3   Thomas Gleixner   genirq: Mirror IR...
166
167
168
169
170
171
172
173
174
175
  
  static inline void irqd_clear(struct irq_data *d, unsigned int mask)
  {
  	d->state_use_accessors &= ~mask;
  }
  
  static inline void irqd_set(struct irq_data *d, unsigned int mask)
  {
  	d->state_use_accessors |= mask;
  }
2bdd10558   Thomas Gleixner   genirq: Move IRQ_...
176
177
178
179
  static inline bool irqd_has_set(struct irq_data *d, unsigned int mask)
  {
  	return d->state_use_accessors & mask;
  }
8f945a332   Thomas Gleixner   genirq: Move ksta...
180
181
182
183
184
185
  
  static inline void kstat_incr_irqs_this_cpu(unsigned int irq, struct irq_desc *desc)
  {
  	__this_cpu_inc(*desc->kstat_irqs);
  	__this_cpu_inc(kstat.irqs_sum);
  }
cab303be9   Thomas Gleixner   genirq: Add sanit...
186
187
  
  #ifdef CONFIG_PM_SLEEP
9ce7a2584   Thomas Gleixner   genirq: Simplify ...
188
  bool irq_pm_check_wakeup(struct irq_desc *desc);
cab303be9   Thomas Gleixner   genirq: Add sanit...
189
190
191
  void irq_pm_install_action(struct irq_desc *desc, struct irqaction *action);
  void irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action);
  #else
9ce7a2584   Thomas Gleixner   genirq: Simplify ...
192
  static inline bool irq_pm_check_wakeup(struct irq_desc *desc) { return false; }
cab303be9   Thomas Gleixner   genirq: Add sanit...
193
194
195
196
197
  static inline void
  irq_pm_install_action(struct irq_desc *desc, struct irqaction *action) { }
  static inline void
  irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action) { }
  #endif