Blame view

kernel/irq/internals.h 5.5 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>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9

c1ee62642   Thomas Gleixner   genirq: Prevent a...
10
11
12
13
14
  #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...
15
  #define istate core_internal_state__do_not_mess_with_it
2329abfa3   Rusty Russell   module_param: mak...
16
  extern bool noirqdebug;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17

1535dfacb   Thomas Gleixner   genirq: Move irq ...
18
19
20
21
22
23
  /*
   * Bits used by threaded handlers:
   * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
   * IRQTF_DIED      - handler thread died
   * 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
28
29
30
   */
  enum {
  	IRQTF_RUNTHREAD,
  	IRQTF_DIED,
  	IRQTF_WARNED,
  	IRQTF_AFFINITY,
8d32a307e   Thomas Gleixner   genirq: Provide f...
31
  	IRQTF_FORCED_THREAD,
1535dfacb   Thomas Gleixner   genirq: Move irq ...
32
  };
bd062e766   Thomas Gleixner   genirq: Move IRQ_...
33
34
35
36
  /*
   * Bit masks for desc->state
   *
   * IRQS_AUTODETECT		- autodetection in progress
7acdd53e5   Thomas Gleixner   genirq: Move IRQ_...
37
38
   * IRQS_SPURIOUS_DISABLED	- was disabled due to spurious interrupt
   *				  detection
6954b75b4   Thomas Gleixner   genirq: Move IRQ_...
39
   * IRQS_POLL_INPROGRESS		- polling in progress
3d67baec7   Thomas Gleixner   genirq: Move IRQ_...
40
   * IRQS_ONESHOT			- irq is not unmasked in primary handler
163ef3091   Thomas Gleixner   genirq: Move IRQ_...
41
42
   * IRQS_REPLAY			- irq is replayed
   * IRQS_WAITING			- irq is waiting
2a0d6fb33   Thomas Gleixner   genirq: Move IRQ_...
43
   * IRQS_PENDING			- irq is pending and replayed later
c531e8361   Thomas Gleixner   genirq: Move IRQ_...
44
   * IRQS_SUSPENDED		- irq is suspended
bd062e766   Thomas Gleixner   genirq: Move IRQ_...
45
46
47
   */
  enum {
  	IRQS_AUTODETECT		= 0x00000001,
7acdd53e5   Thomas Gleixner   genirq: Move IRQ_...
48
  	IRQS_SPURIOUS_DISABLED	= 0x00000002,
6954b75b4   Thomas Gleixner   genirq: Move IRQ_...
49
  	IRQS_POLL_INPROGRESS	= 0x00000008,
3d67baec7   Thomas Gleixner   genirq: Move IRQ_...
50
  	IRQS_ONESHOT		= 0x00000020,
163ef3091   Thomas Gleixner   genirq: Move IRQ_...
51
52
  	IRQS_REPLAY		= 0x00000040,
  	IRQS_WAITING		= 0x00000080,
2a0d6fb33   Thomas Gleixner   genirq: Move IRQ_...
53
  	IRQS_PENDING		= 0x00000200,
c531e8361   Thomas Gleixner   genirq: Move IRQ_...
54
  	IRQS_SUSPENDED		= 0x00000800,
bd062e766   Thomas Gleixner   genirq: Move IRQ_...
55
  };
1ce6068da   Thomas Gleixner   genirq: Move debu...
56
57
  #include "debug.h"
  #include "settings.h"
a77c46359   Thomas Gleixner   genirq: Add new f...
58
  #define irq_data_to_desc(data)	container_of(data, struct irq_desc, irq_data)
0c5d1eb77   David Brownell   genirq: record tr...
59
60
  extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
  		unsigned long flags);
0a0c5168d   Rafael J. Wysocki   PM: Introduce fun...
61
62
  extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp);
  extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
0c5d1eb77   David Brownell   genirq: record tr...
63

469992386   Thomas Gleixner   genirq: Consolida...
64
65
  extern int irq_startup(struct irq_desc *desc);
  extern void irq_shutdown(struct irq_desc *desc);
87923470c   Thomas Gleixner   genirq: Consolida...
66
67
  extern void irq_enable(struct irq_desc *desc);
  extern void irq_disable(struct irq_desc *desc);
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
68
69
  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...
70
71
  extern void mask_irq(struct irq_desc *desc);
  extern void unmask_irq(struct irq_desc *desc);
469992386   Thomas Gleixner   genirq: Consolida...
72

85ac16d03   Yinghai Lu   x86/irq: change i...
73
  extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
0fa0ebbf1   Mike Travis   irq: allocate irq...
74

4912609f2   Thomas Gleixner   genirq: Implement...
75
76
  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...
77
78
  /* Resending of interrupts :*/
  void check_irq_resend(struct irq_desc *desc, unsigned int irq);
fe200ae48   Thomas Gleixner   genirq: Mark poll...
79
  bool irq_wait_for_poll(struct irq_desc *desc);
e144710b3   Thomas Gleixner   genirq: Distangle...
80

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
  #ifdef CONFIG_PROC_FS
2c6927a38   Yinghai Lu   irq: replace loop...
82
  extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
13bfe99e0   Thomas Gleixner   genirq: Prepare p...
83
  extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
84
85
86
  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...
87
  static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
13bfe99e0   Thomas Gleixner   genirq: Prepare p...
88
  static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
90
91
92
93
  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...
94
  extern int irq_select_affinity_usr(unsigned int irq, struct cpumask *mask);
f6d87f4bd   Thomas Gleixner   genirq: keep affi...
95

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

70aedd24d   Thomas Gleixner   genirq: Add buslo...
98
  /* Inline functions for support of irq chips on slow busses */
3876ec9ef   Thomas Gleixner   genirq: Provide c...
99
  static inline void chip_bus_lock(struct irq_desc *desc)
70aedd24d   Thomas Gleixner   genirq: Add buslo...
100
  {
3876ec9ef   Thomas Gleixner   genirq: Provide c...
101
102
  	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...
103
  }
3876ec9ef   Thomas Gleixner   genirq: Provide c...
104
  static inline void chip_bus_sync_unlock(struct irq_desc *desc)
70aedd24d   Thomas Gleixner   genirq: Add buslo...
105
  {
3876ec9ef   Thomas Gleixner   genirq: Provide c...
106
107
  	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...
108
  }
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
109
110
111
112
113
  #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...
114
  struct irq_desc *
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
115
116
  __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
  		    unsigned int check);
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
117
118
119
  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...
120
  irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int check)
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
121
  {
31d9d9b6d   Marc Zyngier   genirq: Add suppo...
122
  	return __irq_get_desc_lock(irq, flags, true, check);
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
123
124
125
126
127
128
129
130
131
  }
  
  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...
132
  irq_get_desc_lock(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, false, check);
d5eb4ad2d   Thomas Gleixner   genirq: Implement...
135
136
137
138
139
140
141
  }
  
  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...
142
  /*
f230b6d5c   Thomas Gleixner   genirq: Add IRQ_M...
143
144
145
146
147
   * 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...
148
149
150
151
152
  }
  
  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...
153
  }
a005677b3   Thomas Gleixner   genirq: Mirror IR...
154
155
156
157
158
159
160
161
162
163
  
  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_...
164
165
166
167
  static inline bool irqd_has_set(struct irq_data *d, unsigned int mask)
  {
  	return d->state_use_accessors & mask;
  }