| #ifndef _LINUX_INTERRUPT_H |
| #define _LINUX_INTERRUPT_H |
| |
| #include <linux/kernel.h> |
| #include <linux/linkage.h> |
| #include <linux/bitops.h> |
| #include <linux/preempt.h> |
| #include <linux/cpumask.h> |
| #include <linux/irqreturn.h> |
| #include <linux/irqnr.h> |
| #include <linux/hardirq.h> |
| #include <linux/irqflags.h> |
| #include <linux/smp.h> |
| #include <linux/percpu.h> |
| #include <linux/hrtimer.h> |
| #include <linux/kref.h> |
| #include <linux/workqueue.h> |
| |
| #include <linux/atomic.h> |
| #include <asm/ptrace.h> |
| |
| #define IRQF_TRIGGER_NONE 0x00000000 |
| #define IRQF_TRIGGER_RISING 0x00000001 |
| #define IRQF_TRIGGER_FALLING 0x00000002 |
| #define IRQF_TRIGGER_HIGH 0x00000004 |
| #define IRQF_TRIGGER_LOW 0x00000008 |
| #define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \ |
| IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING) |
| #define IRQF_TRIGGER_PROBE 0x00000010 |
| |
| #define IRQF_DISABLED 0x00000020 |
| #define IRQF_SAMPLE_RANDOM 0x00000040 |
| #define IRQF_SHARED 0x00000080 |
| #define IRQF_PROBE_SHARED 0x00000100 |
| #define __IRQF_TIMER 0x00000200 |
| #define IRQF_PERCPU 0x00000400 |
| #define IRQF_NOBALANCING 0x00000800 |
| #define IRQF_IRQPOLL 0x00001000 |
| #define IRQF_ONESHOT 0x00002000 |
| #define IRQF_NO_SUSPEND 0x00004000 |
| #define IRQF_FORCE_RESUME 0x00008000 |
| #define IRQF_NO_THREAD 0x00010000 |
| #define IRQF_EARLY_RESUME 0x00020000 |
| |
| #define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD) |
| |
| enum { |
| IRQC_IS_HARDIRQ = 0, |
| IRQC_IS_NESTED, |
| }; |
| |
| typedef irqreturn_t (*irq_handler_t)(int, void *); |
| |
| struct irqaction { |
| irq_handler_t handler; |
| unsigned long flags; |
| void *dev_id; |
| void __percpu *percpu_dev_id; |
| struct irqaction *next; |
| int irq; |
| irq_handler_t thread_fn; |
| struct task_struct *thread; |
| unsigned long thread_flags; |
| unsigned long thread_mask; |
| const char *name; |
| struct proc_dir_entry *dir; |
| } ____cacheline_internodealigned_in_smp; |
| |
| extern irqreturn_t no_action(int cpl, void *dev_id); |
| |
| #ifdef CONFIG_GENERIC_HARDIRQS |
| extern int __must_check |
| request_threaded_irq(unsigned int irq, irq_handler_t handler, |
| irq_handler_t thread_fn, |
| unsigned long flags, const char *name, void *dev); |
| |
| static inline int __must_check |
| request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, |
| const char *name, void *dev) |
| { |
| return request_threaded_irq(irq, handler, NULL, flags, name, dev); |
| } |
| |
| extern int __must_check |
| request_any_context_irq(unsigned int irq, irq_handler_t handler, |
| unsigned long flags, const char *name, void *dev_id); |
| |
| extern int __must_check |
| request_percpu_irq(unsigned int irq, irq_handler_t handler, |
| const char *devname, void __percpu *percpu_dev_id); |
| |
| extern void exit_irq_thread(void); |
| #else |
| |
| extern int __must_check |
| request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, |
| const char *name, void *dev); |
| |
| static inline int __must_check |
| request_threaded_irq(unsigned int irq, irq_handler_t handler, |
| irq_handler_t thread_fn, |
| unsigned long flags, const char *name, void *dev) |
| { |
| return request_irq(irq, handler, flags, name, dev); |
| } |
| |
| static inline int __must_check |
| request_any_context_irq(unsigned int irq, irq_handler_t handler, |
| unsigned long flags, const char *name, void *dev_id) |
| { |
| return request_irq(irq, handler, flags, name, dev_id); |
| } |
| |
| static inline int __must_check |
| request_percpu_irq(unsigned int irq, irq_handler_t handler, |
| const char *devname, void __percpu *percpu_dev_id) |
| { |
| return request_irq(irq, handler, 0, devname, percpu_dev_id); |
| } |
| |
| static inline void exit_irq_thread(void) { } |
| #endif |
| |
| extern void free_irq(unsigned int, void *); |
| extern void free_percpu_irq(unsigned int, void __percpu *); |
| |
| struct device; |
| |
| extern int __must_check |
| devm_request_threaded_irq(struct device *dev, unsigned int irq, |
| irq_handler_t handler, irq_handler_t thread_fn, |
| unsigned long irqflags, const char *devname, |
| void *dev_id); |
| |
| static inline int __must_check |
| devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler, |
| unsigned long irqflags, const char *devname, void *dev_id) |
| { |
| return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags, |
| devname, dev_id); |
| } |
| |
| extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id); |
| |
| #ifdef CONFIG_LOCKDEP |
| # define local_irq_enable_in_hardirq() do { } while (0) |
| #else |
| # define local_irq_enable_in_hardirq() local_irq_enable() |
| #endif |
| |
| extern void disable_irq_nosync(unsigned int irq); |
| extern void disable_irq(unsigned int irq); |
| extern void disable_percpu_irq(unsigned int irq); |
| extern void enable_irq(unsigned int irq); |
| extern void enable_percpu_irq(unsigned int irq, unsigned int type); |
| |
| #ifdef CONFIG_GENERIC_HARDIRQS |
| extern void suspend_device_irqs(void); |
| extern void resume_device_irqs(void); |
| #ifdef CONFIG_PM_SLEEP |
| extern int check_wakeup_irqs(void); |
| #else |
| static inline int check_wakeup_irqs(void) { return 0; } |
| #endif |
| #else |
| static inline void suspend_device_irqs(void) { }; |
| static inline void resume_device_irqs(void) { }; |
| static inline int check_wakeup_irqs(void) { return 0; } |
| #endif |
| |
| #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS) |
| |
| extern cpumask_var_t irq_default_affinity; |
| |
| extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); |
| extern int irq_can_set_affinity(unsigned int irq); |
| extern int irq_select_affinity(unsigned int irq); |
| |
| extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m); |
| |
| struct irq_affinity_notify { |
| unsigned int irq; |
| struct kref kref; |
| struct work_struct work; |
| void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask); |
| void (*release)(struct kref *ref); |
| }; |
| |
| extern int |
| irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify); |
| |
| static inline void irq_run_affinity_notifiers(void) |
| { |
| flush_scheduled_work(); |
| } |
| |
| #else |
| |
| static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m) |
| { |
| return -EINVAL; |
| } |
| |
| static inline int irq_can_set_affinity(unsigned int irq) |
| { |
| return 0; |
| } |
| |
| static inline int irq_select_affinity(unsigned int irq) { return 0; } |
| |
| static inline int irq_set_affinity_hint(unsigned int irq, |
| const struct cpumask *m) |
| { |
| return -EINVAL; |
| } |
| #endif |
| |
| #ifdef CONFIG_GENERIC_HARDIRQS |
| static inline void disable_irq_nosync_lockdep(unsigned int irq) |
| { |
| disable_irq_nosync(irq); |
| #ifdef CONFIG_LOCKDEP |
| local_irq_disable(); |
| #endif |
| } |
| |
| static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags) |
| { |
| disable_irq_nosync(irq); |
| #ifdef CONFIG_LOCKDEP |
| local_irq_save(*flags); |
| #endif |
| } |
| |
| static inline void disable_irq_lockdep(unsigned int irq) |
| { |
| disable_irq(irq); |
| #ifdef CONFIG_LOCKDEP |
| local_irq_disable(); |
| #endif |
| } |
| |
| static inline void enable_irq_lockdep(unsigned int irq) |
| { |
| #ifdef CONFIG_LOCKDEP |
| local_irq_enable(); |
| #endif |
| enable_irq(irq); |
| } |
| |
| static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags) |
| { |
| #ifdef CONFIG_LOCKDEP |
| local_irq_restore(*flags); |
| #endif |
| enable_irq(irq); |
| } |
| |
| extern int irq_set_irq_wake(unsigned int irq, unsigned int on); |
| extern int irq_read_line(unsigned int irq); |
| |
| static inline int enable_irq_wake(unsigned int irq) |
| { |
| return irq_set_irq_wake(irq, 1); |
| } |
| |
| static inline int disable_irq_wake(unsigned int irq) |
| { |
| return irq_set_irq_wake(irq, 0); |
| } |
| |
| #else |
| #ifndef CONFIG_LOCKDEP |
| # define disable_irq_nosync_lockdep(irq) disable_irq_nosync(irq) |
| # define disable_irq_nosync_lockdep_irqsave(irq, flags) \ |
| disable_irq_nosync(irq) |
| # define disable_irq_lockdep(irq) disable_irq(irq) |
| # define enable_irq_lockdep(irq) enable_irq(irq) |
| # define enable_irq_lockdep_irqrestore(irq, flags) \ |
| enable_irq(irq) |
| # endif |
| |
| static inline int enable_irq_wake(unsigned int irq) |
| { |
| return 0; |
| } |
| |
| static inline int disable_irq_wake(unsigned int irq) |
| { |
| return 0; |
| } |
| #endif |
| |
| |
| #ifdef CONFIG_IRQ_FORCED_THREADING |
| extern bool force_irqthreads; |
| #else |
| #define force_irqthreads (0) |
| #endif |
| |
| #ifndef __ARCH_SET_SOFTIRQ_PENDING |
| #define set_softirq_pending(x) (local_softirq_pending() = (x)) |
| #define or_softirq_pending(x) (local_softirq_pending() |= (x)) |
| #endif |
| |
| #ifndef hard_irq_disable |
| #define hard_irq_disable() do { } while(0) |
| #endif |
| |
| |
| enum |
| { |
| HI_SOFTIRQ=0, |
| TIMER_SOFTIRQ, |
| NET_TX_SOFTIRQ, |
| NET_RX_SOFTIRQ, |
| BLOCK_SOFTIRQ, |
| BLOCK_IOPOLL_SOFTIRQ, |
| TASKLET_SOFTIRQ, |
| SCHED_SOFTIRQ, |
| HRTIMER_SOFTIRQ, |
| RCU_SOFTIRQ, |
| |
| NR_SOFTIRQS |
| }; |
| |
| extern char *softirq_to_name[NR_SOFTIRQS]; |
| |
| |
| struct softirq_action |
| { |
| void (*action)(struct softirq_action *); |
| }; |
| |
| asmlinkage void do_softirq(void); |
| asmlinkage void __do_softirq(void); |
| extern void open_softirq(int nr, void (*action)(struct softirq_action *)); |
| extern void softirq_init(void); |
| extern void __raise_softirq_irqoff(unsigned int nr); |
| |
| extern void raise_softirq_irqoff(unsigned int nr); |
| extern void raise_softirq(unsigned int nr); |
| |
| DECLARE_PER_CPU(struct list_head [NR_SOFTIRQS], softirq_work_list); |
| |
| DECLARE_PER_CPU(struct task_struct *, ksoftirqd); |
| |
| static inline struct task_struct *this_cpu_ksoftirqd(void) |
| { |
| return this_cpu_read(ksoftirqd); |
| } |
| |
| extern void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq); |
| |
| extern void __send_remote_softirq(struct call_single_data *cp, int cpu, |
| int this_cpu, int softirq); |
| |
| |
| struct tasklet_struct |
| { |
| struct tasklet_struct *next; |
| unsigned long state; |
| atomic_t count; |
| void (*func)(unsigned long); |
| unsigned long data; |
| }; |
| |
| #define DECLARE_TASKLET(name, func, data) \ |
| struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data } |
| |
| #define DECLARE_TASKLET_DISABLED(name, func, data) \ |
| struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data } |
| |
| |
| enum |
| { |
| TASKLET_STATE_SCHED, |
| TASKLET_STATE_RUN |
| }; |
| |
| #ifdef CONFIG_SMP |
| static inline int tasklet_trylock(struct tasklet_struct *t) |
| { |
| return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state); |
| } |
| |
| static inline void tasklet_unlock(struct tasklet_struct *t) |
| { |
| smp_mb__before_clear_bit(); |
| clear_bit(TASKLET_STATE_RUN, &(t)->state); |
| } |
| |
| static inline void tasklet_unlock_wait(struct tasklet_struct *t) |
| { |
| while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); } |
| } |
| #else |
| #define tasklet_trylock(t) 1 |
| #define tasklet_unlock_wait(t) do { } while (0) |
| #define tasklet_unlock(t) do { } while (0) |
| #endif |
| |
| extern void __tasklet_schedule(struct tasklet_struct *t); |
| |
| static inline void tasklet_schedule(struct tasklet_struct *t) |
| { |
| if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) |
| __tasklet_schedule(t); |
| } |
| |
| extern void __tasklet_hi_schedule(struct tasklet_struct *t); |
| |
| static inline void tasklet_hi_schedule(struct tasklet_struct *t) |
| { |
| if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) |
| __tasklet_hi_schedule(t); |
| } |
| |
| extern void __tasklet_hi_schedule_first(struct tasklet_struct *t); |
| |
| static inline void tasklet_hi_schedule_first(struct tasklet_struct *t) |
| { |
| if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) |
| __tasklet_hi_schedule_first(t); |
| } |
| |
| |
| static inline void tasklet_disable_nosync(struct tasklet_struct *t) |
| { |
| atomic_inc(&t->count); |
| smp_mb__after_atomic_inc(); |
| } |
| |
| static inline void tasklet_disable(struct tasklet_struct *t) |
| { |
| tasklet_disable_nosync(t); |
| tasklet_unlock_wait(t); |
| smp_mb(); |
| } |
| |
| static inline void tasklet_enable(struct tasklet_struct *t) |
| { |
| smp_mb__before_atomic_dec(); |
| atomic_dec(&t->count); |
| } |
| |
| static inline void tasklet_hi_enable(struct tasklet_struct *t) |
| { |
| smp_mb__before_atomic_dec(); |
| atomic_dec(&t->count); |
| } |
| |
| extern void tasklet_kill(struct tasklet_struct *t); |
| extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu); |
| extern void tasklet_init(struct tasklet_struct *t, |
| void (*func)(unsigned long), unsigned long data); |
| |
| struct tasklet_hrtimer { |
| struct hrtimer timer; |
| struct tasklet_struct tasklet; |
| enum hrtimer_restart (*function)(struct hrtimer *); |
| }; |
| |
| extern void |
| tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer, |
| enum hrtimer_restart (*function)(struct hrtimer *), |
| clockid_t which_clock, enum hrtimer_mode mode); |
| |
| static inline |
| int tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time, |
| const enum hrtimer_mode mode) |
| { |
| return hrtimer_start(&ttimer->timer, time, mode); |
| } |
| |
| static inline |
| void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer) |
| { |
| hrtimer_cancel(&ttimer->timer); |
| tasklet_kill(&ttimer->tasklet); |
| } |
| |
| |
| #if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE) |
| static inline unsigned long probe_irq_on(void) |
| { |
| return 0; |
| } |
| static inline int probe_irq_off(unsigned long val) |
| { |
| return 0; |
| } |
| static inline unsigned int probe_irq_mask(unsigned long val) |
| { |
| return 0; |
| } |
| #else |
| extern unsigned long probe_irq_on(void); |
| extern int probe_irq_off(unsigned long); |
| extern unsigned int probe_irq_mask(unsigned long); |
| #endif |
| |
| #ifdef CONFIG_PROC_FS |
| extern void init_irq_proc(void); |
| #else |
| static inline void init_irq_proc(void) |
| { |
| } |
| #endif |
| |
| struct seq_file; |
| int show_interrupts(struct seq_file *p, void *v); |
| int arch_show_interrupts(struct seq_file *p, int prec); |
| |
| extern int early_irq_init(void); |
| extern int arch_probe_nr_irqs(void); |
| extern int arch_early_irq_init(void); |
| extern void irq_set_pending(unsigned int irq); |
| #endif |