xref: /linux-6.15/include/linux/interrupt.h (revision b525903c)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /* interrupt.h */
31da177e4SLinus Torvalds #ifndef _LINUX_INTERRUPT_H
41da177e4SLinus Torvalds #define _LINUX_INTERRUPT_H
51da177e4SLinus Torvalds 
61da177e4SLinus Torvalds #include <linux/kernel.h>
71da177e4SLinus Torvalds #include <linux/bitops.h>
81da177e4SLinus Torvalds #include <linux/cpumask.h>
9908dcecdSJan Beulich #include <linux/irqreturn.h>
10dd3a1db9SThomas Gleixner #include <linux/irqnr.h>
111da177e4SLinus Torvalds #include <linux/hardirq.h>
12de30a2b3SIngo Molnar #include <linux/irqflags.h>
139ba5f005SPeter Zijlstra #include <linux/hrtimer.h>
14cd7eab44SBen Hutchings #include <linux/kref.h>
15cd7eab44SBen Hutchings #include <linux/workqueue.h>
160ebb26e7SIngo Molnar 
1760063497SArun Sharma #include <linux/atomic.h>
181da177e4SLinus Torvalds #include <asm/ptrace.h>
197d65f4a6SFrederic Weisbecker #include <asm/irq.h>
20229a7186SMasami Hiramatsu #include <asm/sections.h>
211da177e4SLinus Torvalds 
226e213616SThomas Gleixner /*
236e213616SThomas Gleixner  * These correspond to the IORESOURCE_IRQ_* defines in
246e213616SThomas Gleixner  * linux/ioport.h to select the interrupt line behaviour.  When
256e213616SThomas Gleixner  * requesting an interrupt without specifying a IRQF_TRIGGER, the
266e213616SThomas Gleixner  * setting should be assumed to be "as already configured", which
276e213616SThomas Gleixner  * may be as per machine or firmware initialisation.
286e213616SThomas Gleixner  */
296e213616SThomas Gleixner #define IRQF_TRIGGER_NONE	0x00000000
306e213616SThomas Gleixner #define IRQF_TRIGGER_RISING	0x00000001
316e213616SThomas Gleixner #define IRQF_TRIGGER_FALLING	0x00000002
326e213616SThomas Gleixner #define IRQF_TRIGGER_HIGH	0x00000004
336e213616SThomas Gleixner #define IRQF_TRIGGER_LOW	0x00000008
346e213616SThomas Gleixner #define IRQF_TRIGGER_MASK	(IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
356e213616SThomas Gleixner 				 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
366e213616SThomas Gleixner #define IRQF_TRIGGER_PROBE	0x00000010
376e213616SThomas Gleixner 
386e213616SThomas Gleixner /*
396e213616SThomas Gleixner  * These flags used only by the kernel as part of the
406e213616SThomas Gleixner  * irq handling routines.
416e213616SThomas Gleixner  *
426e213616SThomas Gleixner  * IRQF_SHARED - allow sharing the irq among several devices
436e213616SThomas Gleixner  * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
446e213616SThomas Gleixner  * IRQF_TIMER - Flag to mark this interrupt as timer interrupt
45950f4427SThomas Gleixner  * IRQF_PERCPU - Interrupt is per cpu
46950f4427SThomas Gleixner  * IRQF_NOBALANCING - Flag to exclude this interrupt from irq balancing
47d85a60d8SBernhard Walle  * IRQF_IRQPOLL - Interrupt is used for polling (only the interrupt that is
48b8d62f33SGeert Uytterhoeven  *                registered first in a shared interrupt is considered for
49d85a60d8SBernhard Walle  *                performance reasons)
50b25c340cSThomas Gleixner  * IRQF_ONESHOT - Interrupt is not reenabled after the hardirq handler finished.
51b25c340cSThomas Gleixner  *                Used by threaded interrupts which need to keep the
52b25c340cSThomas Gleixner  *                irq line disabled until the threaded handler has been run.
53737eb030SMark Rutland  * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend.  Does not guarantee
54737eb030SMark Rutland  *                   that this interrupt will wake the system from a suspended
55737eb030SMark Rutland  *                   state.  See Documentation/power/suspend-and-interrupts.txt
56dc5f219eSThomas Gleixner  * IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
570c4602ffSThomas Gleixner  * IRQF_NO_THREAD - Interrupt cannot be threaded
589bab0b7fSIan Campbell  * IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
599bab0b7fSIan Campbell  *                resume time.
6017f48034SRafael J. Wysocki  * IRQF_COND_SUSPEND - If the IRQ is shared with a NO_SUSPEND user, execute this
6117f48034SRafael J. Wysocki  *                interrupt handler after suspending interrupts. For system
6217f48034SRafael J. Wysocki  *                wakeup devices users need to implement wakeup detection in
6317f48034SRafael J. Wysocki  *                their interrupt handlers.
646e213616SThomas Gleixner  */
656e213616SThomas Gleixner #define IRQF_SHARED		0x00000080
666e213616SThomas Gleixner #define IRQF_PROBE_SHARED	0x00000100
67685fd0b4SIan Campbell #define __IRQF_TIMER		0x00000200
68284c6680SThomas Gleixner #define IRQF_PERCPU		0x00000400
69950f4427SThomas Gleixner #define IRQF_NOBALANCING	0x00000800
70d85a60d8SBernhard Walle #define IRQF_IRQPOLL		0x00001000
71b25c340cSThomas Gleixner #define IRQF_ONESHOT		0x00002000
72685fd0b4SIan Campbell #define IRQF_NO_SUSPEND		0x00004000
73dc5f219eSThomas Gleixner #define IRQF_FORCE_RESUME	0x00008000
740c4602ffSThomas Gleixner #define IRQF_NO_THREAD		0x00010000
759bab0b7fSIan Campbell #define IRQF_EARLY_RESUME	0x00020000
7617f48034SRafael J. Wysocki #define IRQF_COND_SUSPEND	0x00040000
77685fd0b4SIan Campbell 
780c4602ffSThomas Gleixner #define IRQF_TIMER		(__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
793aa551c9SThomas Gleixner 
80b4e6b097SRandy Dunlap /*
81ae731f8dSMarc Zyngier  * These values can be returned by request_any_context_irq() and
82ae731f8dSMarc Zyngier  * describe the context the interrupt will be run in.
83ae731f8dSMarc Zyngier  *
84ae731f8dSMarc Zyngier  * IRQC_IS_HARDIRQ - interrupt runs in hardirq context
85ae731f8dSMarc Zyngier  * IRQC_IS_NESTED - interrupt runs in a nested threaded context
86ae731f8dSMarc Zyngier  */
87ae731f8dSMarc Zyngier enum {
88ae731f8dSMarc Zyngier 	IRQC_IS_HARDIRQ	= 0,
89ae731f8dSMarc Zyngier 	IRQC_IS_NESTED,
90ae731f8dSMarc Zyngier };
91ae731f8dSMarc Zyngier 
927d12e780SDavid Howells typedef irqreturn_t (*irq_handler_t)(int, void *);
93da482792SDavid Howells 
94a9d0a1a3SThomas Gleixner /**
95a9d0a1a3SThomas Gleixner  * struct irqaction - per interrupt action descriptor
96a9d0a1a3SThomas Gleixner  * @handler:	interrupt handler function
97a9d0a1a3SThomas Gleixner  * @name:	name of the device
98a9d0a1a3SThomas Gleixner  * @dev_id:	cookie to identify the device
9931d9d9b6SMarc Zyngier  * @percpu_dev_id:	cookie to identify the device
100a9d0a1a3SThomas Gleixner  * @next:	pointer to the next irqaction for shared interrupts
101a9d0a1a3SThomas Gleixner  * @irq:	interrupt number
102c0ecaa06SThomas Gleixner  * @flags:	flags (see IRQF_* above)
10325985edcSLucas De Marchi  * @thread_fn:	interrupt handler function for threaded interrupts
1043aa551c9SThomas Gleixner  * @thread:	thread pointer for threaded interrupts
1052a1d3ab8SThomas Gleixner  * @secondary:	pointer to secondary irqaction (force threading)
1063aa551c9SThomas Gleixner  * @thread_flags:	flags related to @thread
107b5faba21SThomas Gleixner  * @thread_mask:	bitmask for keeping track of @thread activity
108c0ecaa06SThomas Gleixner  * @dir:	pointer to the proc/irq/NN/name entry
109a9d0a1a3SThomas Gleixner  */
1101da177e4SLinus Torvalds struct irqaction {
111da482792SDavid Howells 	irq_handler_t		handler;
1121da177e4SLinus Torvalds 	void			*dev_id;
11331d9d9b6SMarc Zyngier 	void __percpu		*percpu_dev_id;
1141da177e4SLinus Torvalds 	struct irqaction	*next;
1153aa551c9SThomas Gleixner 	irq_handler_t		thread_fn;
1163aa551c9SThomas Gleixner 	struct task_struct	*thread;
1172a1d3ab8SThomas Gleixner 	struct irqaction	*secondary;
118c0ecaa06SThomas Gleixner 	unsigned int		irq;
119c0ecaa06SThomas Gleixner 	unsigned int		flags;
1203aa551c9SThomas Gleixner 	unsigned long		thread_flags;
121b5faba21SThomas Gleixner 	unsigned long		thread_mask;
122f6cd2477SEric Dumazet 	const char		*name;
123f6cd2477SEric Dumazet 	struct proc_dir_entry	*dir;
124f6cd2477SEric Dumazet } ____cacheline_internodealigned_in_smp;
1251da177e4SLinus Torvalds 
1267d12e780SDavid Howells extern irqreturn_t no_action(int cpl, void *dev_id);
1273aa551c9SThomas Gleixner 
128e237a551SChen Fan /*
129e237a551SChen Fan  * If a (PCI) device interrupt is not connected we set dev->irq to
130e237a551SChen Fan  * IRQ_NOTCONNECTED. This causes request_irq() to fail with -ENOTCONN, so we
131e237a551SChen Fan  * can distingiush that case from other error returns.
132e237a551SChen Fan  *
133e237a551SChen Fan  * 0x80000000 is guaranteed to be outside the available range of interrupts
134e237a551SChen Fan  * and easy to distinguish from other possible incorrect values.
135e237a551SChen Fan  */
136e237a551SChen Fan #define IRQ_NOTCONNECTED	(1U << 31)
137e237a551SChen Fan 
1383aa551c9SThomas Gleixner extern int __must_check
1393aa551c9SThomas Gleixner request_threaded_irq(unsigned int irq, irq_handler_t handler,
1403aa551c9SThomas Gleixner 		     irq_handler_t thread_fn,
1413aa551c9SThomas Gleixner 		     unsigned long flags, const char *name, void *dev);
1423aa551c9SThomas Gleixner 
1433aa551c9SThomas Gleixner static inline int __must_check
1443aa551c9SThomas Gleixner request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
1453aa551c9SThomas Gleixner 	    const char *name, void *dev)
1463aa551c9SThomas Gleixner {
1473aa551c9SThomas Gleixner 	return request_threaded_irq(irq, handler, NULL, flags, name, dev);
1483aa551c9SThomas Gleixner }
1493aa551c9SThomas Gleixner 
150ae731f8dSMarc Zyngier extern int __must_check
151ae731f8dSMarc Zyngier request_any_context_irq(unsigned int irq, irq_handler_t handler,
152ae731f8dSMarc Zyngier 			unsigned long flags, const char *name, void *dev_id);
153ae731f8dSMarc Zyngier 
15431d9d9b6SMarc Zyngier extern int __must_check
155c80081b9SDaniel Lezcano __request_percpu_irq(unsigned int irq, irq_handler_t handler,
156c80081b9SDaniel Lezcano 		     unsigned long flags, const char *devname,
157c80081b9SDaniel Lezcano 		     void __percpu *percpu_dev_id);
158c80081b9SDaniel Lezcano 
159*b525903cSJulien Thierry extern int __must_check
160*b525903cSJulien Thierry request_nmi(unsigned int irq, irq_handler_t handler, unsigned long flags,
161*b525903cSJulien Thierry 	    const char *name, void *dev);
162*b525903cSJulien Thierry 
163c80081b9SDaniel Lezcano static inline int __must_check
16431d9d9b6SMarc Zyngier request_percpu_irq(unsigned int irq, irq_handler_t handler,
165c80081b9SDaniel Lezcano 		   const char *devname, void __percpu *percpu_dev_id)
166c80081b9SDaniel Lezcano {
167c80081b9SDaniel Lezcano 	return __request_percpu_irq(irq, handler, 0,
168c80081b9SDaniel Lezcano 				    devname, percpu_dev_id);
169c80081b9SDaniel Lezcano }
1703aa551c9SThomas Gleixner 
17125ce4be7SChristoph Hellwig extern const void *free_irq(unsigned int, void *);
17231d9d9b6SMarc Zyngier extern void free_percpu_irq(unsigned int, void __percpu *);
1731da177e4SLinus Torvalds 
174*b525903cSJulien Thierry extern const void *free_nmi(unsigned int irq, void *dev_id);
175*b525903cSJulien Thierry 
1760af3678fSAl Viro struct device;
1770af3678fSAl Viro 
178935bd5b9SArjan van de Ven extern int __must_check
179935bd5b9SArjan van de Ven devm_request_threaded_irq(struct device *dev, unsigned int irq,
180935bd5b9SArjan van de Ven 			  irq_handler_t handler, irq_handler_t thread_fn,
181935bd5b9SArjan van de Ven 			  unsigned long irqflags, const char *devname,
182935bd5b9SArjan van de Ven 			  void *dev_id);
183935bd5b9SArjan van de Ven 
184935bd5b9SArjan van de Ven static inline int __must_check
185935bd5b9SArjan van de Ven devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
186935bd5b9SArjan van de Ven 		 unsigned long irqflags, const char *devname, void *dev_id)
187935bd5b9SArjan van de Ven {
188935bd5b9SArjan van de Ven 	return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
189935bd5b9SArjan van de Ven 					 devname, dev_id);
190935bd5b9SArjan van de Ven }
191935bd5b9SArjan van de Ven 
1920668d306SStephen Boyd extern int __must_check
1930668d306SStephen Boyd devm_request_any_context_irq(struct device *dev, unsigned int irq,
1940668d306SStephen Boyd 		 irq_handler_t handler, unsigned long irqflags,
1950668d306SStephen Boyd 		 const char *devname, void *dev_id);
1960668d306SStephen Boyd 
1979ac7849eSTejun Heo extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
1989ac7849eSTejun Heo 
199d7e9629dSIngo Molnar /*
200d7e9629dSIngo Molnar  * On lockdep we dont want to enable hardirqs in hardirq
201d7e9629dSIngo Molnar  * context. Use local_irq_enable_in_hardirq() to annotate
202d7e9629dSIngo Molnar  * kernel code that has to do this nevertheless (pretty much
203d7e9629dSIngo Molnar  * the only valid case is for old/broken hardware that is
204d7e9629dSIngo Molnar  * insanely slow).
205d7e9629dSIngo Molnar  *
206d7e9629dSIngo Molnar  * NOTE: in theory this might break fragile code that relies
207d7e9629dSIngo Molnar  * on hardirq delivery - in practice we dont seem to have such
208d7e9629dSIngo Molnar  * places left. So the only effect should be slightly increased
209d7e9629dSIngo Molnar  * irqs-off latencies.
210d7e9629dSIngo Molnar  */
211d7e9629dSIngo Molnar #ifdef CONFIG_LOCKDEP
212d7e9629dSIngo Molnar # define local_irq_enable_in_hardirq()	do { } while (0)
213d7e9629dSIngo Molnar #else
214d7e9629dSIngo Molnar # define local_irq_enable_in_hardirq()	local_irq_enable()
215d7e9629dSIngo Molnar #endif
2161da177e4SLinus Torvalds 
2171da177e4SLinus Torvalds extern void disable_irq_nosync(unsigned int irq);
21802cea395SPeter Zijlstra extern bool disable_hardirq(unsigned int irq);
2191da177e4SLinus Torvalds extern void disable_irq(unsigned int irq);
22031d9d9b6SMarc Zyngier extern void disable_percpu_irq(unsigned int irq);
2211da177e4SLinus Torvalds extern void enable_irq(unsigned int irq);
2221e7c5fd2SMarc Zyngier extern void enable_percpu_irq(unsigned int irq, unsigned int type);
223f0cb3220SThomas Petazzoni extern bool irq_percpu_is_enabled(unsigned int irq);
224a92444c6SThomas Gleixner extern void irq_wake_thread(unsigned int irq, void *dev_id);
225ba9a2331SThomas Gleixner 
226*b525903cSJulien Thierry extern void disable_nmi_nosync(unsigned int irq);
227*b525903cSJulien Thierry extern void enable_nmi(unsigned int irq);
228*b525903cSJulien Thierry 
2290a0c5168SRafael J. Wysocki /* The following three functions are for the core kernel use only. */
2300a0c5168SRafael J. Wysocki extern void suspend_device_irqs(void);
2310a0c5168SRafael J. Wysocki extern void resume_device_irqs(void);
2320a0c5168SRafael J. Wysocki 
233f0ba3d05SEyal Perry /**
234f0ba3d05SEyal Perry  * struct irq_affinity_notify - context for notification of IRQ affinity changes
235f0ba3d05SEyal Perry  * @irq:		Interrupt to which notification applies
236f0ba3d05SEyal Perry  * @kref:		Reference count, for internal use
237f0ba3d05SEyal Perry  * @work:		Work item, for internal use
238f0ba3d05SEyal Perry  * @notify:		Function to be called on change.  This will be
239f0ba3d05SEyal Perry  *			called in process context.
240f0ba3d05SEyal Perry  * @release:		Function to be called on release.  This will be
241f0ba3d05SEyal Perry  *			called in process context.  Once registered, the
242f0ba3d05SEyal Perry  *			structure must only be freed when this function is
243f0ba3d05SEyal Perry  *			called or later.
244f0ba3d05SEyal Perry  */
245f0ba3d05SEyal Perry struct irq_affinity_notify {
246f0ba3d05SEyal Perry 	unsigned int irq;
247f0ba3d05SEyal Perry 	struct kref kref;
248f0ba3d05SEyal Perry 	struct work_struct work;
249f0ba3d05SEyal Perry 	void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
250f0ba3d05SEyal Perry 	void (*release)(struct kref *ref);
251f0ba3d05SEyal Perry };
252f0ba3d05SEyal Perry 
25320e407e1SChristoph Hellwig /**
25420e407e1SChristoph Hellwig  * struct irq_affinity - Description for automatic irq affinity assignements
25520e407e1SChristoph Hellwig  * @pre_vectors:	Don't apply affinity to @pre_vectors at beginning of
25620e407e1SChristoph Hellwig  *			the MSI(-X) vector space
25720e407e1SChristoph Hellwig  * @post_vectors:	Don't apply affinity to @post_vectors at end of
25820e407e1SChristoph Hellwig  *			the MSI(-X) vector space
2596da4b3abSJens Axboe  * @nr_sets:		Length of passed in *sets array
2606da4b3abSJens Axboe  * @sets:		Number of affinitized sets
26120e407e1SChristoph Hellwig  */
26220e407e1SChristoph Hellwig struct irq_affinity {
26320e407e1SChristoph Hellwig 	int	pre_vectors;
26420e407e1SChristoph Hellwig 	int	post_vectors;
2656da4b3abSJens Axboe 	int	nr_sets;
2666da4b3abSJens Axboe 	int	*sets;
26720e407e1SChristoph Hellwig };
26820e407e1SChristoph Hellwig 
269bec04037SDou Liyang /**
270bec04037SDou Liyang  * struct irq_affinity_desc - Interrupt affinity descriptor
271bec04037SDou Liyang  * @mask:	cpumask to hold the affinity assignment
272bec04037SDou Liyang  */
273bec04037SDou Liyang struct irq_affinity_desc {
274bec04037SDou Liyang 	struct cpumask	mask;
275c410abbbSDou Liyang 	unsigned int	is_managed : 1;
276bec04037SDou Liyang };
277bec04037SDou Liyang 
2780244ad00SMartin Schwidefsky #if defined(CONFIG_SMP)
279d7b90689SRussell King 
280d036e67bSRusty Russell extern cpumask_var_t irq_default_affinity;
28118404756SMax Krasnyansky 
28201f8fa4fSThomas Gleixner /* Internal implementation. Use the helpers below */
28301f8fa4fSThomas Gleixner extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
28401f8fa4fSThomas Gleixner 			      bool force);
28501f8fa4fSThomas Gleixner 
28601f8fa4fSThomas Gleixner /**
28701f8fa4fSThomas Gleixner  * irq_set_affinity - Set the irq affinity of a given irq
28801f8fa4fSThomas Gleixner  * @irq:	Interrupt to set affinity
289def5f127SRandy Dunlap  * @cpumask:	cpumask
29001f8fa4fSThomas Gleixner  *
29101f8fa4fSThomas Gleixner  * Fails if cpumask does not contain an online CPU
29201f8fa4fSThomas Gleixner  */
29301f8fa4fSThomas Gleixner static inline int
29401f8fa4fSThomas Gleixner irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
29501f8fa4fSThomas Gleixner {
29601f8fa4fSThomas Gleixner 	return __irq_set_affinity(irq, cpumask, false);
29701f8fa4fSThomas Gleixner }
29801f8fa4fSThomas Gleixner 
29901f8fa4fSThomas Gleixner /**
30001f8fa4fSThomas Gleixner  * irq_force_affinity - Force the irq affinity of a given irq
30101f8fa4fSThomas Gleixner  * @irq:	Interrupt to set affinity
302def5f127SRandy Dunlap  * @cpumask:	cpumask
30301f8fa4fSThomas Gleixner  *
30401f8fa4fSThomas Gleixner  * Same as irq_set_affinity, but without checking the mask against
30501f8fa4fSThomas Gleixner  * online cpus.
30601f8fa4fSThomas Gleixner  *
30701f8fa4fSThomas Gleixner  * Solely for low level cpu hotplug code, where we need to make per
30801f8fa4fSThomas Gleixner  * cpu interrupts affine before the cpu becomes online.
30901f8fa4fSThomas Gleixner  */
31001f8fa4fSThomas Gleixner static inline int
31101f8fa4fSThomas Gleixner irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
31201f8fa4fSThomas Gleixner {
31301f8fa4fSThomas Gleixner 	return __irq_set_affinity(irq, cpumask, true);
31401f8fa4fSThomas Gleixner }
31501f8fa4fSThomas Gleixner 
316d7b90689SRussell King extern int irq_can_set_affinity(unsigned int irq);
31718404756SMax Krasnyansky extern int irq_select_affinity(unsigned int irq);
318d7b90689SRussell King 
319e7a297b0SPeter P Waskiewicz Jr extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
320cd7eab44SBen Hutchings 
321cd7eab44SBen Hutchings extern int
322cd7eab44SBen Hutchings irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
323cd7eab44SBen Hutchings 
324bec04037SDou Liyang struct irq_affinity_desc *
325bec04037SDou Liyang irq_create_affinity_masks(int nvec, const struct irq_affinity *affd);
326bec04037SDou Liyang 
3276f9a22bcSMichael Hernandez int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity *affd);
3285e385a6eSChristoph Hellwig 
329d7b90689SRussell King #else /* CONFIG_SMP */
330d7b90689SRussell King 
3310de26520SRusty Russell static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
332d7b90689SRussell King {
333d7b90689SRussell King 	return -EINVAL;
334d7b90689SRussell King }
335d7b90689SRussell King 
3364c88d7f9SArnd Bergmann static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
3374c88d7f9SArnd Bergmann {
3384c88d7f9SArnd Bergmann 	return 0;
3394c88d7f9SArnd Bergmann }
3404c88d7f9SArnd Bergmann 
341d7b90689SRussell King static inline int irq_can_set_affinity(unsigned int irq)
342d7b90689SRussell King {
343d7b90689SRussell King 	return 0;
344d7b90689SRussell King }
345d7b90689SRussell King 
34618404756SMax Krasnyansky static inline int irq_select_affinity(unsigned int irq)  { return 0; }
34718404756SMax Krasnyansky 
348e7a297b0SPeter P Waskiewicz Jr static inline int irq_set_affinity_hint(unsigned int irq,
349e7a297b0SPeter P Waskiewicz Jr 					const struct cpumask *m)
350e7a297b0SPeter P Waskiewicz Jr {
351e7a297b0SPeter P Waskiewicz Jr 	return -EINVAL;
352e7a297b0SPeter P Waskiewicz Jr }
353f0ba3d05SEyal Perry 
354f0ba3d05SEyal Perry static inline int
355f0ba3d05SEyal Perry irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
356f0ba3d05SEyal Perry {
357f0ba3d05SEyal Perry 	return 0;
358f0ba3d05SEyal Perry }
3595e385a6eSChristoph Hellwig 
360bec04037SDou Liyang static inline struct irq_affinity_desc *
36167c93c21SChristoph Hellwig irq_create_affinity_masks(int nvec, const struct irq_affinity *affd)
36234c3d981SThomas Gleixner {
36334c3d981SThomas Gleixner 	return NULL;
36434c3d981SThomas Gleixner }
36534c3d981SThomas Gleixner 
36634c3d981SThomas Gleixner static inline int
3676f9a22bcSMichael Hernandez irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity *affd)
36834c3d981SThomas Gleixner {
36934c3d981SThomas Gleixner 	return maxvec;
37034c3d981SThomas Gleixner }
37134c3d981SThomas Gleixner 
3720244ad00SMartin Schwidefsky #endif /* CONFIG_SMP */
373d7b90689SRussell King 
374c01d403bSIngo Molnar /*
375c01d403bSIngo Molnar  * Special lockdep variants of irq disabling/enabling.
376c01d403bSIngo Molnar  * These should be used for locking constructs that
377c01d403bSIngo Molnar  * know that a particular irq context which is disabled,
378c01d403bSIngo Molnar  * and which is the only irq-context user of a lock,
379c01d403bSIngo Molnar  * that it's safe to take the lock in the irq-disabled
380c01d403bSIngo Molnar  * section without disabling hardirqs.
381c01d403bSIngo Molnar  *
382c01d403bSIngo Molnar  * On !CONFIG_LOCKDEP they are equivalent to the normal
383c01d403bSIngo Molnar  * irq disable/enable methods.
384c01d403bSIngo Molnar  */
385c01d403bSIngo Molnar static inline void disable_irq_nosync_lockdep(unsigned int irq)
386c01d403bSIngo Molnar {
387c01d403bSIngo Molnar 	disable_irq_nosync(irq);
388c01d403bSIngo Molnar #ifdef CONFIG_LOCKDEP
389c01d403bSIngo Molnar 	local_irq_disable();
390c01d403bSIngo Molnar #endif
391c01d403bSIngo Molnar }
392c01d403bSIngo Molnar 
393e8106b94SArjan van de Ven static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags)
394e8106b94SArjan van de Ven {
395e8106b94SArjan van de Ven 	disable_irq_nosync(irq);
396e8106b94SArjan van de Ven #ifdef CONFIG_LOCKDEP
397e8106b94SArjan van de Ven 	local_irq_save(*flags);
398e8106b94SArjan van de Ven #endif
399e8106b94SArjan van de Ven }
400e8106b94SArjan van de Ven 
401c01d403bSIngo Molnar static inline void disable_irq_lockdep(unsigned int irq)
402c01d403bSIngo Molnar {
403c01d403bSIngo Molnar 	disable_irq(irq);
404c01d403bSIngo Molnar #ifdef CONFIG_LOCKDEP
405c01d403bSIngo Molnar 	local_irq_disable();
406c01d403bSIngo Molnar #endif
407c01d403bSIngo Molnar }
408c01d403bSIngo Molnar 
409c01d403bSIngo Molnar static inline void enable_irq_lockdep(unsigned int irq)
410c01d403bSIngo Molnar {
411c01d403bSIngo Molnar #ifdef CONFIG_LOCKDEP
412c01d403bSIngo Molnar 	local_irq_enable();
413c01d403bSIngo Molnar #endif
414c01d403bSIngo Molnar 	enable_irq(irq);
415c01d403bSIngo Molnar }
416c01d403bSIngo Molnar 
417e8106b94SArjan van de Ven static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags)
418e8106b94SArjan van de Ven {
419e8106b94SArjan van de Ven #ifdef CONFIG_LOCKDEP
420e8106b94SArjan van de Ven 	local_irq_restore(*flags);
421e8106b94SArjan van de Ven #endif
422e8106b94SArjan van de Ven 	enable_irq(irq);
423e8106b94SArjan van de Ven }
424e8106b94SArjan van de Ven 
425ba9a2331SThomas Gleixner /* IRQ wakeup (PM) control: */
426a0cd9ca2SThomas Gleixner extern int irq_set_irq_wake(unsigned int irq, unsigned int on);
427a0cd9ca2SThomas Gleixner 
428ba9a2331SThomas Gleixner static inline int enable_irq_wake(unsigned int irq)
429ba9a2331SThomas Gleixner {
430a0cd9ca2SThomas Gleixner 	return irq_set_irq_wake(irq, 1);
431ba9a2331SThomas Gleixner }
432ba9a2331SThomas Gleixner 
433ba9a2331SThomas Gleixner static inline int disable_irq_wake(unsigned int irq)
434ba9a2331SThomas Gleixner {
435a0cd9ca2SThomas Gleixner 	return irq_set_irq_wake(irq, 0);
436ba9a2331SThomas Gleixner }
437ba9a2331SThomas Gleixner 
4381b7047edSMarc Zyngier /*
4391b7047edSMarc Zyngier  * irq_get_irqchip_state/irq_set_irqchip_state specific flags
4401b7047edSMarc Zyngier  */
4411b7047edSMarc Zyngier enum irqchip_irq_state {
4421b7047edSMarc Zyngier 	IRQCHIP_STATE_PENDING,		/* Is interrupt pending? */
4431b7047edSMarc Zyngier 	IRQCHIP_STATE_ACTIVE,		/* Is interrupt in progress? */
4441b7047edSMarc Zyngier 	IRQCHIP_STATE_MASKED,		/* Is interrupt masked? */
4451b7047edSMarc Zyngier 	IRQCHIP_STATE_LINE_LEVEL,	/* Is IRQ line high? */
4461b7047edSMarc Zyngier };
4471b7047edSMarc Zyngier 
4481b7047edSMarc Zyngier extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
4491b7047edSMarc Zyngier 				 bool *state);
4501b7047edSMarc Zyngier extern int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
4511b7047edSMarc Zyngier 				 bool state);
4528d32a307SThomas Gleixner 
4538d32a307SThomas Gleixner #ifdef CONFIG_IRQ_FORCED_THREADING
4548d32a307SThomas Gleixner extern bool force_irqthreads;
4558d32a307SThomas Gleixner #else
4568d32a307SThomas Gleixner #define force_irqthreads	(0)
4578d32a307SThomas Gleixner #endif
4588d32a307SThomas Gleixner 
4590fd7d862SFrederic Weisbecker #ifndef local_softirq_pending
4600fd7d862SFrederic Weisbecker 
4610fd7d862SFrederic Weisbecker #ifndef local_softirq_pending_ref
4620fd7d862SFrederic Weisbecker #define local_softirq_pending_ref irq_stat.__softirq_pending
4630fd7d862SFrederic Weisbecker #endif
4640fd7d862SFrederic Weisbecker 
4650fd7d862SFrederic Weisbecker #define local_softirq_pending()	(__this_cpu_read(local_softirq_pending_ref))
4660fd7d862SFrederic Weisbecker #define set_softirq_pending(x)	(__this_cpu_write(local_softirq_pending_ref, (x)))
4670fd7d862SFrederic Weisbecker #define or_softirq_pending(x)	(__this_cpu_or(local_softirq_pending_ref, (x)))
4680fd7d862SFrederic Weisbecker 
4690fd7d862SFrederic Weisbecker #endif /* local_softirq_pending */
4700fd7d862SFrederic Weisbecker 
4712d3fbbb3SBenjamin Herrenschmidt /* Some architectures might implement lazy enabling/disabling of
4722d3fbbb3SBenjamin Herrenschmidt  * interrupts. In some cases, such as stop_machine, we might want
4732d3fbbb3SBenjamin Herrenschmidt  * to ensure that after a local_irq_disable(), interrupts have
4742d3fbbb3SBenjamin Herrenschmidt  * really been disabled in hardware. Such architectures need to
4752d3fbbb3SBenjamin Herrenschmidt  * implement the following hook.
4762d3fbbb3SBenjamin Herrenschmidt  */
4772d3fbbb3SBenjamin Herrenschmidt #ifndef hard_irq_disable
4782d3fbbb3SBenjamin Herrenschmidt #define hard_irq_disable()	do { } while(0)
4792d3fbbb3SBenjamin Herrenschmidt #endif
4802d3fbbb3SBenjamin Herrenschmidt 
4811da177e4SLinus Torvalds /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
4821da177e4SLinus Torvalds    frequency threaded job scheduling. For almost all the purposes
4831da177e4SLinus Torvalds    tasklets are more than enough. F.e. all serial device BHs et
4841da177e4SLinus Torvalds    al. should be converted to tasklets, not to softirqs.
4851da177e4SLinus Torvalds  */
4861da177e4SLinus Torvalds 
4871da177e4SLinus Torvalds enum
4881da177e4SLinus Torvalds {
4891da177e4SLinus Torvalds 	HI_SOFTIRQ=0,
4901da177e4SLinus Torvalds 	TIMER_SOFTIRQ,
4911da177e4SLinus Torvalds 	NET_TX_SOFTIRQ,
4921da177e4SLinus Torvalds 	NET_RX_SOFTIRQ,
493ff856badSJens Axboe 	BLOCK_SOFTIRQ,
494511cbce2SChristoph Hellwig 	IRQ_POLL_SOFTIRQ,
495c9819f45SChristoph Lameter 	TASKLET_SOFTIRQ,
496c9819f45SChristoph Lameter 	SCHED_SOFTIRQ,
497c6eb3f70SThomas Gleixner 	HRTIMER_SOFTIRQ, /* Unused, but kept as tools rely on the
498c6eb3f70SThomas Gleixner 			    numbering. Sigh! */
49909223371SShaohua Li 	RCU_SOFTIRQ,    /* Preferable RCU should always be the last softirq */
500978b0116SAlexey Dobriyan 
501978b0116SAlexey Dobriyan 	NR_SOFTIRQS
5021da177e4SLinus Torvalds };
5031da177e4SLinus Torvalds 
504803b0ebaSPaul E. McKenney #define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ))
505803b0ebaSPaul E. McKenney 
5065d592b44SJason Baron /* map softirq index to softirq name. update 'softirq_to_name' in
5075d592b44SJason Baron  * kernel/softirq.c when adding a new softirq.
5085d592b44SJason Baron  */
509ce85b4f2SJoe Perches extern const char * const softirq_to_name[NR_SOFTIRQS];
5105d592b44SJason Baron 
5111da177e4SLinus Torvalds /* softirq mask and active fields moved to irq_cpustat_t in
5121da177e4SLinus Torvalds  * asm/hardirq.h to get better cache usage.  KAO
5131da177e4SLinus Torvalds  */
5141da177e4SLinus Torvalds 
5151da177e4SLinus Torvalds struct softirq_action
5161da177e4SLinus Torvalds {
5171da177e4SLinus Torvalds 	void	(*action)(struct softirq_action *);
5181da177e4SLinus Torvalds };
5191da177e4SLinus Torvalds 
5201da177e4SLinus Torvalds asmlinkage void do_softirq(void);
521eb0f1c44SAdrian Bunk asmlinkage void __do_softirq(void);
5227d65f4a6SFrederic Weisbecker 
5237d65f4a6SFrederic Weisbecker #ifdef __ARCH_HAS_DO_SOFTIRQ
5247d65f4a6SFrederic Weisbecker void do_softirq_own_stack(void);
5257d65f4a6SFrederic Weisbecker #else
5267d65f4a6SFrederic Weisbecker static inline void do_softirq_own_stack(void)
5277d65f4a6SFrederic Weisbecker {
5287d65f4a6SFrederic Weisbecker 	__do_softirq();
5297d65f4a6SFrederic Weisbecker }
5307d65f4a6SFrederic Weisbecker #endif
5317d65f4a6SFrederic Weisbecker 
532962cf36cSCarlos R. Mafra extern void open_softirq(int nr, void (*action)(struct softirq_action *));
5331da177e4SLinus Torvalds extern void softirq_init(void);
534f069686eSSteven Rostedt extern void __raise_softirq_irqoff(unsigned int nr);
5352bf2160dSLai Jiangshan 
536b3c97528SHarvey Harrison extern void raise_softirq_irqoff(unsigned int nr);
537b3c97528SHarvey Harrison extern void raise_softirq(unsigned int nr);
5381da177e4SLinus Torvalds 
5394dd53d89SVenkatesh Pallipadi DECLARE_PER_CPU(struct task_struct *, ksoftirqd);
5404dd53d89SVenkatesh Pallipadi 
5414dd53d89SVenkatesh Pallipadi static inline struct task_struct *this_cpu_ksoftirqd(void)
5424dd53d89SVenkatesh Pallipadi {
5434dd53d89SVenkatesh Pallipadi 	return this_cpu_read(ksoftirqd);
5444dd53d89SVenkatesh Pallipadi }
5454dd53d89SVenkatesh Pallipadi 
5461da177e4SLinus Torvalds /* Tasklets --- multithreaded analogue of BHs.
5471da177e4SLinus Torvalds 
5481da177e4SLinus Torvalds    Main feature differing them of generic softirqs: tasklet
5491da177e4SLinus Torvalds    is running only on one CPU simultaneously.
5501da177e4SLinus Torvalds 
5511da177e4SLinus Torvalds    Main feature differing them of BHs: different tasklets
5521da177e4SLinus Torvalds    may be run simultaneously on different CPUs.
5531da177e4SLinus Torvalds 
5541da177e4SLinus Torvalds    Properties:
5551da177e4SLinus Torvalds    * If tasklet_schedule() is called, then tasklet is guaranteed
5561da177e4SLinus Torvalds      to be executed on some cpu at least once after this.
55725985edcSLucas De Marchi    * If the tasklet is already scheduled, but its execution is still not
5581da177e4SLinus Torvalds      started, it will be executed only once.
5591da177e4SLinus Torvalds    * If this tasklet is already running on another CPU (or schedule is called
5601da177e4SLinus Torvalds      from tasklet itself), it is rescheduled for later.
5611da177e4SLinus Torvalds    * Tasklet is strictly serialized wrt itself, but not
5621da177e4SLinus Torvalds      wrt another tasklets. If client needs some intertask synchronization,
5631da177e4SLinus Torvalds      he makes it with spinlocks.
5641da177e4SLinus Torvalds  */
5651da177e4SLinus Torvalds 
5661da177e4SLinus Torvalds struct tasklet_struct
5671da177e4SLinus Torvalds {
5681da177e4SLinus Torvalds 	struct tasklet_struct *next;
5691da177e4SLinus Torvalds 	unsigned long state;
5701da177e4SLinus Torvalds 	atomic_t count;
5711da177e4SLinus Torvalds 	void (*func)(unsigned long);
5721da177e4SLinus Torvalds 	unsigned long data;
5731da177e4SLinus Torvalds };
5741da177e4SLinus Torvalds 
5751da177e4SLinus Torvalds #define DECLARE_TASKLET(name, func, data) \
5761da177e4SLinus Torvalds struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
5771da177e4SLinus Torvalds 
5781da177e4SLinus Torvalds #define DECLARE_TASKLET_DISABLED(name, func, data) \
5791da177e4SLinus Torvalds struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
5801da177e4SLinus Torvalds 
5811da177e4SLinus Torvalds 
5821da177e4SLinus Torvalds enum
5831da177e4SLinus Torvalds {
5841da177e4SLinus Torvalds 	TASKLET_STATE_SCHED,	/* Tasklet is scheduled for execution */
5851da177e4SLinus Torvalds 	TASKLET_STATE_RUN	/* Tasklet is running (SMP only) */
5861da177e4SLinus Torvalds };
5871da177e4SLinus Torvalds 
5881da177e4SLinus Torvalds #ifdef CONFIG_SMP
5891da177e4SLinus Torvalds static inline int tasklet_trylock(struct tasklet_struct *t)
5901da177e4SLinus Torvalds {
5911da177e4SLinus Torvalds 	return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
5921da177e4SLinus Torvalds }
5931da177e4SLinus Torvalds 
5941da177e4SLinus Torvalds static inline void tasklet_unlock(struct tasklet_struct *t)
5951da177e4SLinus Torvalds {
5964e857c58SPeter Zijlstra 	smp_mb__before_atomic();
5971da177e4SLinus Torvalds 	clear_bit(TASKLET_STATE_RUN, &(t)->state);
5981da177e4SLinus Torvalds }
5991da177e4SLinus Torvalds 
6001da177e4SLinus Torvalds static inline void tasklet_unlock_wait(struct tasklet_struct *t)
6011da177e4SLinus Torvalds {
6021da177e4SLinus Torvalds 	while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
6031da177e4SLinus Torvalds }
6041da177e4SLinus Torvalds #else
6051da177e4SLinus Torvalds #define tasklet_trylock(t) 1
6061da177e4SLinus Torvalds #define tasklet_unlock_wait(t) do { } while (0)
6071da177e4SLinus Torvalds #define tasklet_unlock(t) do { } while (0)
6081da177e4SLinus Torvalds #endif
6091da177e4SLinus Torvalds 
610b3c97528SHarvey Harrison extern void __tasklet_schedule(struct tasklet_struct *t);
6111da177e4SLinus Torvalds 
6121da177e4SLinus Torvalds static inline void tasklet_schedule(struct tasklet_struct *t)
6131da177e4SLinus Torvalds {
6141da177e4SLinus Torvalds 	if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
6151da177e4SLinus Torvalds 		__tasklet_schedule(t);
6161da177e4SLinus Torvalds }
6171da177e4SLinus Torvalds 
618b3c97528SHarvey Harrison extern void __tasklet_hi_schedule(struct tasklet_struct *t);
6191da177e4SLinus Torvalds 
6201da177e4SLinus Torvalds static inline void tasklet_hi_schedule(struct tasklet_struct *t)
6211da177e4SLinus Torvalds {
6221da177e4SLinus Torvalds 	if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
6231da177e4SLinus Torvalds 		__tasklet_hi_schedule(t);
6241da177e4SLinus Torvalds }
6251da177e4SLinus Torvalds 
6261da177e4SLinus Torvalds static inline void tasklet_disable_nosync(struct tasklet_struct *t)
6271da177e4SLinus Torvalds {
6281da177e4SLinus Torvalds 	atomic_inc(&t->count);
6294e857c58SPeter Zijlstra 	smp_mb__after_atomic();
6301da177e4SLinus Torvalds }
6311da177e4SLinus Torvalds 
6321da177e4SLinus Torvalds static inline void tasklet_disable(struct tasklet_struct *t)
6331da177e4SLinus Torvalds {
6341da177e4SLinus Torvalds 	tasklet_disable_nosync(t);
6351da177e4SLinus Torvalds 	tasklet_unlock_wait(t);
6361da177e4SLinus Torvalds 	smp_mb();
6371da177e4SLinus Torvalds }
6381da177e4SLinus Torvalds 
6391da177e4SLinus Torvalds static inline void tasklet_enable(struct tasklet_struct *t)
6401da177e4SLinus Torvalds {
6414e857c58SPeter Zijlstra 	smp_mb__before_atomic();
6421da177e4SLinus Torvalds 	atomic_dec(&t->count);
6431da177e4SLinus Torvalds }
6441da177e4SLinus Torvalds 
6451da177e4SLinus Torvalds extern void tasklet_kill(struct tasklet_struct *t);
6461da177e4SLinus Torvalds extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
6471da177e4SLinus Torvalds extern void tasklet_init(struct tasklet_struct *t,
6481da177e4SLinus Torvalds 			 void (*func)(unsigned long), unsigned long data);
6491da177e4SLinus Torvalds 
6509ba5f005SPeter Zijlstra struct tasklet_hrtimer {
6519ba5f005SPeter Zijlstra 	struct hrtimer		timer;
6529ba5f005SPeter Zijlstra 	struct tasklet_struct	tasklet;
6539ba5f005SPeter Zijlstra 	enum hrtimer_restart	(*function)(struct hrtimer *);
6549ba5f005SPeter Zijlstra };
6559ba5f005SPeter Zijlstra 
6569ba5f005SPeter Zijlstra extern void
6579ba5f005SPeter Zijlstra tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer,
6589ba5f005SPeter Zijlstra 		     enum hrtimer_restart (*function)(struct hrtimer *),
6599ba5f005SPeter Zijlstra 		     clockid_t which_clock, enum hrtimer_mode mode);
6609ba5f005SPeter Zijlstra 
6619ba5f005SPeter Zijlstra static inline
66261699e13SThomas Gleixner void tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time,
6639ba5f005SPeter Zijlstra 			   const enum hrtimer_mode mode)
6649ba5f005SPeter Zijlstra {
66561699e13SThomas Gleixner 	hrtimer_start(&ttimer->timer, time, mode);
6669ba5f005SPeter Zijlstra }
6679ba5f005SPeter Zijlstra 
6689ba5f005SPeter Zijlstra static inline
6699ba5f005SPeter Zijlstra void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer)
6709ba5f005SPeter Zijlstra {
6719ba5f005SPeter Zijlstra 	hrtimer_cancel(&ttimer->timer);
6729ba5f005SPeter Zijlstra 	tasklet_kill(&ttimer->tasklet);
6739ba5f005SPeter Zijlstra }
6749ba5f005SPeter Zijlstra 
6751da177e4SLinus Torvalds /*
6761da177e4SLinus Torvalds  * Autoprobing for irqs:
6771da177e4SLinus Torvalds  *
6781da177e4SLinus Torvalds  * probe_irq_on() and probe_irq_off() provide robust primitives
6791da177e4SLinus Torvalds  * for accurate IRQ probing during kernel initialization.  They are
6801da177e4SLinus Torvalds  * reasonably simple to use, are not "fooled" by spurious interrupts,
6811da177e4SLinus Torvalds  * and, unlike other attempts at IRQ probing, they do not get hung on
6821da177e4SLinus Torvalds  * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
6831da177e4SLinus Torvalds  *
6841da177e4SLinus Torvalds  * For reasonably foolproof probing, use them as follows:
6851da177e4SLinus Torvalds  *
6861da177e4SLinus Torvalds  * 1. clear and/or mask the device's internal interrupt.
6871da177e4SLinus Torvalds  * 2. sti();
6881da177e4SLinus Torvalds  * 3. irqs = probe_irq_on();      // "take over" all unassigned idle IRQs
6891da177e4SLinus Torvalds  * 4. enable the device and cause it to trigger an interrupt.
6901da177e4SLinus Torvalds  * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
6911da177e4SLinus Torvalds  * 6. irq = probe_irq_off(irqs);  // get IRQ number, 0=none, negative=multiple
6921da177e4SLinus Torvalds  * 7. service the device to clear its pending interrupt.
6931da177e4SLinus Torvalds  * 8. loop again if paranoia is required.
6941da177e4SLinus Torvalds  *
6951da177e4SLinus Torvalds  * probe_irq_on() returns a mask of allocated irq's.
6961da177e4SLinus Torvalds  *
6971da177e4SLinus Torvalds  * probe_irq_off() takes the mask as a parameter,
6981da177e4SLinus Torvalds  * and returns the irq number which occurred,
6991da177e4SLinus Torvalds  * or zero if none occurred, or a negative irq number
7001da177e4SLinus Torvalds  * if more than one irq occurred.
7011da177e4SLinus Torvalds  */
7021da177e4SLinus Torvalds 
7030244ad00SMartin Schwidefsky #if !defined(CONFIG_GENERIC_IRQ_PROBE)
7041da177e4SLinus Torvalds static inline unsigned long probe_irq_on(void)
7051da177e4SLinus Torvalds {
7061da177e4SLinus Torvalds 	return 0;
7071da177e4SLinus Torvalds }
7081da177e4SLinus Torvalds static inline int probe_irq_off(unsigned long val)
7091da177e4SLinus Torvalds {
7101da177e4SLinus Torvalds 	return 0;
7111da177e4SLinus Torvalds }
7121da177e4SLinus Torvalds static inline unsigned int probe_irq_mask(unsigned long val)
7131da177e4SLinus Torvalds {
7141da177e4SLinus Torvalds 	return 0;
7151da177e4SLinus Torvalds }
7161da177e4SLinus Torvalds #else
7171da177e4SLinus Torvalds extern unsigned long probe_irq_on(void);	/* returns 0 on failure */
7181da177e4SLinus Torvalds extern int probe_irq_off(unsigned long);	/* returns 0 or negative on failure */
7191da177e4SLinus Torvalds extern unsigned int probe_irq_mask(unsigned long);	/* returns mask of ISA interrupts */
7201da177e4SLinus Torvalds #endif
7211da177e4SLinus Torvalds 
7226168a702SAndrew Morton #ifdef CONFIG_PROC_FS
7236168a702SAndrew Morton /* Initialize /proc/irq/ */
7246168a702SAndrew Morton extern void init_irq_proc(void);
7256168a702SAndrew Morton #else
7266168a702SAndrew Morton static inline void init_irq_proc(void)
7276168a702SAndrew Morton {
7286168a702SAndrew Morton }
7296168a702SAndrew Morton #endif
7306168a702SAndrew Morton 
731b2d3d61aSDaniel Lezcano #ifdef CONFIG_IRQ_TIMINGS
732b2d3d61aSDaniel Lezcano void irq_timings_enable(void);
733b2d3d61aSDaniel Lezcano void irq_timings_disable(void);
734e1c92149SDaniel Lezcano u64 irq_timings_next_event(u64 now);
735b2d3d61aSDaniel Lezcano #endif
736b2d3d61aSDaniel Lezcano 
737d43c36dcSAlexey Dobriyan struct seq_file;
738f74596d0SAdrian Bunk int show_interrupts(struct seq_file *p, void *v);
739c78b9b65SThomas Gleixner int arch_show_interrupts(struct seq_file *p, int prec);
740f74596d0SAdrian Bunk 
74143a25632SYinghai Lu extern int early_irq_init(void);
7424a046d17SYinghai Lu extern int arch_probe_nr_irqs(void);
74343a25632SYinghai Lu extern int arch_early_irq_init(void);
74443a25632SYinghai Lu 
745be7635e7SAlexander Potapenko /*
746be7635e7SAlexander Potapenko  * We want to know which function is an entrypoint of a hardirq or a softirq.
747be7635e7SAlexander Potapenko  */
748be7635e7SAlexander Potapenko #define __irq_entry		 __attribute__((__section__(".irqentry.text")))
749be7635e7SAlexander Potapenko #define __softirq_entry  \
750be7635e7SAlexander Potapenko 	__attribute__((__section__(".softirqentry.text")))
751be7635e7SAlexander Potapenko 
7521da177e4SLinus Torvalds #endif
753