interrupt.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /* interrupt.h */
  2. #ifndef _LINUX_INTERRUPT_H
  3. #define _LINUX_INTERRUPT_H
  4. #include <linux/kernel.h>
  5. #include <linux/linkage.h>
  6. #include <linux/bitops.h>
  7. #include <linux/preempt.h>
  8. #include <linux/cpumask.h>
  9. #include <linux/irqreturn.h>
  10. #include <linux/irqnr.h>
  11. #include <linux/hardirq.h>
  12. #include <linux/irqflags.h>
  13. #include <linux/smp.h>
  14. #include <linux/percpu.h>
  15. #include <linux/hrtimer.h>
  16. #include <linux/kref.h>
  17. #include <linux/workqueue.h>
  18. #include <linux/atomic.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/system.h>
  21. /*
  22. * These correspond to the IORESOURCE_IRQ_* defines in
  23. * linux/ioport.h to select the interrupt line behaviour. When
  24. * requesting an interrupt without specifying a IRQF_TRIGGER, the
  25. * setting should be assumed to be "as already configured", which
  26. * may be as per machine or firmware initialisation.
  27. */
  28. #define IRQF_TRIGGER_NONE 0x00000000
  29. #define IRQF_TRIGGER_RISING 0x00000001
  30. #define IRQF_TRIGGER_FALLING 0x00000002
  31. #define IRQF_TRIGGER_HIGH 0x00000004
  32. #define IRQF_TRIGGER_LOW 0x00000008
  33. #define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
  34. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
  35. #define IRQF_TRIGGER_PROBE 0x00000010
  36. /*
  37. * These flags used only by the kernel as part of the
  38. * irq handling routines.
  39. *
  40. * IRQF_DISABLED - keep irqs disabled when calling the action handler.
  41. * DEPRECATED. This flag is a NOOP and scheduled to be removed
  42. * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator
  43. * IRQF_SHARED - allow sharing the irq among several devices
  44. * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
  45. * IRQF_TIMER - Flag to mark this interrupt as timer interrupt
  46. * IRQF_PERCPU - Interrupt is per cpu
  47. * IRQF_NOBALANCING - Flag to exclude this interrupt from irq balancing
  48. * IRQF_IRQPOLL - Interrupt is used for polling (only the interrupt that is
  49. * registered first in an shared interrupt is considered for
  50. * performance reasons)
  51. * IRQF_ONESHOT - Interrupt is not reenabled after the hardirq handler finished.
  52. * Used by threaded interrupts which need to keep the
  53. * irq line disabled until the threaded handler has been run.
  54. * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend
  55. * IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
  56. * IRQF_NO_THREAD - Interrupt cannot be threaded
  57. * IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
  58. * resume time.
  59. */
  60. #define IRQF_DISABLED 0x00000020
  61. #define IRQF_SAMPLE_RANDOM 0x00000040
  62. #define IRQF_SHARED 0x00000080
  63. #define IRQF_PROBE_SHARED 0x00000100
  64. #define __IRQF_TIMER 0x00000200
  65. #define IRQF_PERCPU 0x00000400
  66. #define IRQF_NOBALANCING 0x00000800
  67. #define IRQF_IRQPOLL 0x00001000
  68. #define IRQF_ONESHOT 0x00002000
  69. #define IRQF_NO_SUSPEND 0x00004000
  70. #define IRQF_FORCE_RESUME 0x00008000
  71. #define IRQF_NO_THREAD 0x00010000
  72. #define IRQF_EARLY_RESUME 0x00020000
  73. #define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
  74. /*
  75. * These values can be returned by request_any_context_irq() and
  76. * describe the context the interrupt will be run in.
  77. *
  78. * IRQC_IS_HARDIRQ - interrupt runs in hardirq context
  79. * IRQC_IS_NESTED - interrupt runs in a nested threaded context
  80. */
  81. enum {
  82. IRQC_IS_HARDIRQ = 0,
  83. IRQC_IS_NESTED,
  84. };
  85. typedef irqreturn_t (*irq_handler_t)(int, void *);
  86. /**
  87. * struct irqaction - per interrupt action descriptor
  88. * @handler: interrupt handler function
  89. * @flags: flags (see IRQF_* above)
  90. * @name: name of the device
  91. * @dev_id: cookie to identify the device
  92. * @percpu_dev_id: cookie to identify the device
  93. * @next: pointer to the next irqaction for shared interrupts
  94. * @irq: interrupt number
  95. * @dir: pointer to the proc/irq/NN/name entry
  96. * @thread_fn: interrupt handler function for threaded interrupts
  97. * @thread: thread pointer for threaded interrupts
  98. * @thread_flags: flags related to @thread
  99. * @thread_mask: bitmask for keeping track of @thread activity
  100. */
  101. struct irqaction {
  102. irq_handler_t handler;
  103. unsigned long flags;
  104. void *dev_id;
  105. void __percpu *percpu_dev_id;
  106. struct irqaction *next;
  107. int irq;
  108. irq_handler_t thread_fn;
  109. struct task_struct *thread;
  110. unsigned long thread_flags;
  111. unsigned long thread_mask;
  112. const char *name;
  113. struct proc_dir_entry *dir;
  114. } ____cacheline_internodealigned_in_smp;
  115. extern irqreturn_t no_action(int cpl, void *dev_id);
  116. #ifdef CONFIG_GENERIC_HARDIRQS
  117. extern int __must_check
  118. request_threaded_irq(unsigned int irq, irq_handler_t handler,
  119. irq_handler_t thread_fn,
  120. unsigned long flags, const char *name, void *dev);
  121. static inline int __must_check
  122. request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
  123. const char *name, void *dev)
  124. {
  125. return request_threaded_irq(irq, handler, NULL, flags, name, dev);
  126. }
  127. extern int __must_check
  128. request_any_context_irq(unsigned int irq, irq_handler_t handler,
  129. unsigned long flags, const char *name, void *dev_id);
  130. extern int __must_check
  131. request_percpu_irq(unsigned int irq, irq_handler_t handler,
  132. const char *devname, void __percpu *percpu_dev_id);
  133. extern void exit_irq_thread(void);
  134. #else
  135. extern int __must_check
  136. request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
  137. const char *name, void *dev);
  138. /*
  139. * Special function to avoid ifdeffery in kernel/irq/devres.c which
  140. * gets magically built by GENERIC_HARDIRQS=n architectures (sparc,
  141. * m68k). I really love these $@%#!* obvious Makefile references:
  142. * ../../../kernel/irq/devres.o
  143. */
  144. static inline int __must_check
  145. request_threaded_irq(unsigned int irq, irq_handler_t handler,
  146. irq_handler_t thread_fn,
  147. unsigned long flags, const char *name, void *dev)
  148. {
  149. return request_irq(irq, handler, flags, name, dev);
  150. }
  151. static inline int __must_check
  152. request_any_context_irq(unsigned int irq, irq_handler_t handler,
  153. unsigned long flags, const char *name, void *dev_id)
  154. {
  155. return request_irq(irq, handler, flags, name, dev_id);
  156. }
  157. static inline int __must_check
  158. request_percpu_irq(unsigned int irq, irq_handler_t handler,
  159. const char *devname, void __percpu *percpu_dev_id)
  160. {
  161. return request_irq(irq, handler, 0, devname, percpu_dev_id);
  162. }
  163. static inline void exit_irq_thread(void) { }
  164. #endif
  165. extern void free_irq(unsigned int, void *);
  166. extern void free_percpu_irq(unsigned int, void __percpu *);
  167. struct device;
  168. extern int __must_check
  169. devm_request_threaded_irq(struct device *dev, unsigned int irq,
  170. irq_handler_t handler, irq_handler_t thread_fn,
  171. unsigned long irqflags, const char *devname,
  172. void *dev_id);
  173. static inline int __must_check
  174. devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
  175. unsigned long irqflags, const char *devname, void *dev_id)
  176. {
  177. return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
  178. devname, dev_id);
  179. }
  180. extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
  181. /*
  182. * On lockdep we dont want to enable hardirqs in hardirq
  183. * context. Use local_irq_enable_in_hardirq() to annotate
  184. * kernel code that has to do this nevertheless (pretty much
  185. * the only valid case is for old/broken hardware that is
  186. * insanely slow).
  187. *
  188. * NOTE: in theory this might break fragile code that relies
  189. * on hardirq delivery - in practice we dont seem to have such
  190. * places left. So the only effect should be slightly increased
  191. * irqs-off latencies.
  192. */
  193. #ifdef CONFIG_LOCKDEP
  194. # define local_irq_enable_in_hardirq() do { } while (0)
  195. #else
  196. # define local_irq_enable_in_hardirq() local_irq_enable()
  197. #endif
  198. extern void disable_irq_nosync(unsigned int irq);
  199. extern void disable_irq(unsigned int irq);
  200. extern void disable_percpu_irq(unsigned int irq);
  201. extern void enable_irq(unsigned int irq);
  202. extern void enable_percpu_irq(unsigned int irq, unsigned int type);
  203. /* The following three functions are for the core kernel use only. */
  204. #ifdef CONFIG_GENERIC_HARDIRQS
  205. extern void suspend_device_irqs(void);
  206. extern void resume_device_irqs(void);
  207. #ifdef CONFIG_PM_SLEEP
  208. extern int check_wakeup_irqs(void);
  209. #else
  210. static inline int check_wakeup_irqs(void) { return 0; }
  211. #endif
  212. #else
  213. static inline void suspend_device_irqs(void) { };
  214. static inline void resume_device_irqs(void) { };
  215. static inline int check_wakeup_irqs(void) { return 0; }
  216. #endif
  217. #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
  218. extern cpumask_var_t irq_default_affinity;
  219. extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
  220. extern int irq_can_set_affinity(unsigned int irq);
  221. extern int irq_select_affinity(unsigned int irq);
  222. extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
  223. /**
  224. * struct irq_affinity_notify - context for notification of IRQ affinity changes
  225. * @irq: Interrupt to which notification applies
  226. * @kref: Reference count, for internal use
  227. * @work: Work item, for internal use
  228. * @notify: Function to be called on change. This will be
  229. * called in process context.
  230. * @release: Function to be called on release. This will be
  231. * called in process context. Once registered, the
  232. * structure must only be freed when this function is
  233. * called or later.
  234. */
  235. struct irq_affinity_notify {
  236. unsigned int irq;
  237. struct kref kref;
  238. struct work_struct work;
  239. void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
  240. void (*release)(struct kref *ref);
  241. };
  242. extern int
  243. irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
  244. static inline void irq_run_affinity_notifiers(void)
  245. {
  246. flush_scheduled_work();
  247. }
  248. #else /* CONFIG_SMP */
  249. static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
  250. {
  251. return -EINVAL;
  252. }
  253. static inline int irq_can_set_affinity(unsigned int irq)
  254. {
  255. return 0;
  256. }
  257. static inline int irq_select_affinity(unsigned int irq) { return 0; }
  258. static inline int irq_set_affinity_hint(unsigned int irq,
  259. const struct cpumask *m)
  260. {
  261. return -EINVAL;
  262. }
  263. #endif /* CONFIG_SMP && CONFIG_GENERIC_HARDIRQS */
  264. #ifdef CONFIG_GENERIC_HARDIRQS
  265. /*
  266. * Special lockdep variants of irq disabling/enabling.
  267. * These should be used for locking constructs that
  268. * know that a particular irq context which is disabled,
  269. * and which is the only irq-context user of a lock,
  270. * that it's safe to take the lock in the irq-disabled
  271. * section without disabling hardirqs.
  272. *
  273. * On !CONFIG_LOCKDEP they are equivalent to the normal
  274. * irq disable/enable methods.
  275. */
  276. static inline void disable_irq_nosync_lockdep(unsigned int irq)
  277. {
  278. disable_irq_nosync(irq);
  279. #ifdef CONFIG_LOCKDEP
  280. local_irq_disable();
  281. #endif
  282. }
  283. static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags)
  284. {
  285. disable_irq_nosync(irq);
  286. #ifdef CONFIG_LOCKDEP
  287. local_irq_save(*flags);
  288. #endif
  289. }
  290. static inline void disable_irq_lockdep(unsigned int irq)
  291. {
  292. disable_irq(irq);
  293. #ifdef CONFIG_LOCKDEP
  294. local_irq_disable();
  295. #endif
  296. }
  297. static inline void enable_irq_lockdep(unsigned int irq)
  298. {
  299. #ifdef CONFIG_LOCKDEP
  300. local_irq_enable();
  301. #endif
  302. enable_irq(irq);
  303. }
  304. static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags)
  305. {
  306. #ifdef CONFIG_LOCKDEP
  307. local_irq_restore(*flags);
  308. #endif
  309. enable_irq(irq);
  310. }
  311. /* IRQ wakeup (PM) control: */
  312. extern int irq_set_irq_wake(unsigned int irq, unsigned int on);
  313. static inline int enable_irq_wake(unsigned int irq)
  314. {
  315. return irq_set_irq_wake(irq, 1);
  316. }
  317. static inline int disable_irq_wake(unsigned int irq)
  318. {
  319. return irq_set_irq_wake(irq, 0);
  320. }
  321. #else /* !CONFIG_GENERIC_HARDIRQS */
  322. /*
  323. * NOTE: non-genirq architectures, if they want to support the lock
  324. * validator need to define the methods below in their asm/irq.h
  325. * files, under an #ifdef CONFIG_LOCKDEP section.
  326. */
  327. #ifndef CONFIG_LOCKDEP
  328. # define disable_irq_nosync_lockdep(irq) disable_irq_nosync(irq)
  329. # define disable_irq_nosync_lockdep_irqsave(irq, flags) \
  330. disable_irq_nosync(irq)
  331. # define disable_irq_lockdep(irq) disable_irq(irq)
  332. # define enable_irq_lockdep(irq) enable_irq(irq)
  333. # define enable_irq_lockdep_irqrestore(irq, flags) \
  334. enable_irq(irq)
  335. # endif
  336. static inline int enable_irq_wake(unsigned int irq)
  337. {
  338. return 0;
  339. }
  340. static inline int disable_irq_wake(unsigned int irq)
  341. {
  342. return 0;
  343. }
  344. #endif /* CONFIG_GENERIC_HARDIRQS */
  345. #ifdef CONFIG_IRQ_FORCED_THREADING
  346. extern bool force_irqthreads;
  347. #else
  348. #define force_irqthreads (0)
  349. #endif
  350. #ifndef __ARCH_SET_SOFTIRQ_PENDING
  351. #define set_softirq_pending(x) (local_softirq_pending() = (x))
  352. #define or_softirq_pending(x) (local_softirq_pending() |= (x))
  353. #endif
  354. /* Some architectures might implement lazy enabling/disabling of
  355. * interrupts. In some cases, such as stop_machine, we might want
  356. * to ensure that after a local_irq_disable(), interrupts have
  357. * really been disabled in hardware. Such architectures need to
  358. * implement the following hook.
  359. */
  360. #ifndef hard_irq_disable
  361. #define hard_irq_disable() do { } while(0)
  362. #endif
  363. /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
  364. frequency threaded job scheduling. For almost all the purposes
  365. tasklets are more than enough. F.e. all serial device BHs et
  366. al. should be converted to tasklets, not to softirqs.
  367. */
  368. enum
  369. {
  370. HI_SOFTIRQ=0,
  371. TIMER_SOFTIRQ,
  372. NET_TX_SOFTIRQ,
  373. NET_RX_SOFTIRQ,
  374. BLOCK_SOFTIRQ,
  375. BLOCK_IOPOLL_SOFTIRQ,
  376. TASKLET_SOFTIRQ,
  377. SCHED_SOFTIRQ,
  378. HRTIMER_SOFTIRQ,
  379. RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
  380. NR_SOFTIRQS
  381. };
  382. /* map softirq index to softirq name. update 'softirq_to_name' in
  383. * kernel/softirq.c when adding a new softirq.
  384. */
  385. extern char *softirq_to_name[NR_SOFTIRQS];
  386. /* softirq mask and active fields moved to irq_cpustat_t in
  387. * asm/hardirq.h to get better cache usage. KAO
  388. */
  389. struct softirq_action
  390. {
  391. void (*action)(struct softirq_action *);
  392. };
  393. asmlinkage void do_softirq(void);
  394. asmlinkage void __do_softirq(void);
  395. extern void open_softirq(int nr, void (*action)(struct softirq_action *));
  396. extern void softirq_init(void);
  397. extern void __raise_softirq_irqoff(unsigned int nr);
  398. extern void raise_softirq_irqoff(unsigned int nr);
  399. extern void raise_softirq(unsigned int nr);
  400. /* This is the worklist that queues up per-cpu softirq work.
  401. *
  402. * send_remote_sendirq() adds work to these lists, and
  403. * the softirq handler itself dequeues from them. The queues
  404. * are protected by disabling local cpu interrupts and they must
  405. * only be accessed by the local cpu that they are for.
  406. */
  407. DECLARE_PER_CPU(struct list_head [NR_SOFTIRQS], softirq_work_list);
  408. DECLARE_PER_CPU(struct task_struct *, ksoftirqd);
  409. static inline struct task_struct *this_cpu_ksoftirqd(void)
  410. {
  411. return this_cpu_read(ksoftirqd);
  412. }
  413. /* Try to send a softirq to a remote cpu. If this cannot be done, the
  414. * work will be queued to the local cpu.
  415. */
  416. extern void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq);
  417. /* Like send_remote_softirq(), but the caller must disable local cpu interrupts
  418. * and compute the current cpu, passed in as 'this_cpu'.
  419. */
  420. extern void __send_remote_softirq(struct call_single_data *cp, int cpu,
  421. int this_cpu, int softirq);
  422. /* Tasklets --- multithreaded analogue of BHs.
  423. Main feature differing them of generic softirqs: tasklet
  424. is running only on one CPU simultaneously.
  425. Main feature differing them of BHs: different tasklets
  426. may be run simultaneously on different CPUs.
  427. Properties:
  428. * If tasklet_schedule() is called, then tasklet is guaranteed
  429. to be executed on some cpu at least once after this.
  430. * If the tasklet is already scheduled, but its execution is still not
  431. started, it will be executed only once.
  432. * If this tasklet is already running on another CPU (or schedule is called
  433. from tasklet itself), it is rescheduled for later.
  434. * Tasklet is strictly serialized wrt itself, but not
  435. wrt another tasklets. If client needs some intertask synchronization,
  436. he makes it with spinlocks.
  437. */
  438. struct tasklet_struct
  439. {
  440. struct tasklet_struct *next;
  441. unsigned long state;
  442. atomic_t count;
  443. void (*func)(unsigned long);
  444. unsigned long data;
  445. };
  446. #define DECLARE_TASKLET(name, func, data) \
  447. struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
  448. #define DECLARE_TASKLET_DISABLED(name, func, data) \
  449. struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
  450. enum
  451. {
  452. TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
  453. TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
  454. };
  455. #ifdef CONFIG_SMP
  456. static inline int tasklet_trylock(struct tasklet_struct *t)
  457. {
  458. return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
  459. }
  460. static inline void tasklet_unlock(struct tasklet_struct *t)
  461. {
  462. smp_mb__before_clear_bit();
  463. clear_bit(TASKLET_STATE_RUN, &(t)->state);
  464. }
  465. static inline void tasklet_unlock_wait(struct tasklet_struct *t)
  466. {
  467. while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
  468. }
  469. #else
  470. #define tasklet_trylock(t) 1
  471. #define tasklet_unlock_wait(t) do { } while (0)
  472. #define tasklet_unlock(t) do { } while (0)
  473. #endif
  474. extern void __tasklet_schedule(struct tasklet_struct *t);
  475. static inline void tasklet_schedule(struct tasklet_struct *t)
  476. {
  477. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  478. __tasklet_schedule(t);
  479. }
  480. extern void __tasklet_hi_schedule(struct tasklet_struct *t);
  481. static inline void tasklet_hi_schedule(struct tasklet_struct *t)
  482. {
  483. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  484. __tasklet_hi_schedule(t);
  485. }
  486. extern void __tasklet_hi_schedule_first(struct tasklet_struct *t);
  487. /*
  488. * This version avoids touching any other tasklets. Needed for kmemcheck
  489. * in order not to take any page faults while enqueueing this tasklet;
  490. * consider VERY carefully whether you really need this or
  491. * tasklet_hi_schedule()...
  492. */
  493. static inline void tasklet_hi_schedule_first(struct tasklet_struct *t)
  494. {
  495. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  496. __tasklet_hi_schedule_first(t);
  497. }
  498. static inline void tasklet_disable_nosync(struct tasklet_struct *t)
  499. {
  500. atomic_inc(&t->count);
  501. smp_mb__after_atomic_inc();
  502. }
  503. static inline void tasklet_disable(struct tasklet_struct *t)
  504. {
  505. tasklet_disable_nosync(t);
  506. tasklet_unlock_wait(t);
  507. smp_mb();
  508. }
  509. static inline void tasklet_enable(struct tasklet_struct *t)
  510. {
  511. smp_mb__before_atomic_dec();
  512. atomic_dec(&t->count);
  513. }
  514. static inline void tasklet_hi_enable(struct tasklet_struct *t)
  515. {
  516. smp_mb__before_atomic_dec();
  517. atomic_dec(&t->count);
  518. }
  519. extern void tasklet_kill(struct tasklet_struct *t);
  520. extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
  521. extern void tasklet_init(struct tasklet_struct *t,
  522. void (*func)(unsigned long), unsigned long data);
  523. struct tasklet_hrtimer {
  524. struct hrtimer timer;
  525. struct tasklet_struct tasklet;
  526. enum hrtimer_restart (*function)(struct hrtimer *);
  527. };
  528. extern void
  529. tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer,
  530. enum hrtimer_restart (*function)(struct hrtimer *),
  531. clockid_t which_clock, enum hrtimer_mode mode);
  532. static inline
  533. int tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time,
  534. const enum hrtimer_mode mode)
  535. {
  536. return hrtimer_start(&ttimer->timer, time, mode);
  537. }
  538. static inline
  539. void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer)
  540. {
  541. hrtimer_cancel(&ttimer->timer);
  542. tasklet_kill(&ttimer->tasklet);
  543. }
  544. /*
  545. * Autoprobing for irqs:
  546. *
  547. * probe_irq_on() and probe_irq_off() provide robust primitives
  548. * for accurate IRQ probing during kernel initialization. They are
  549. * reasonably simple to use, are not "fooled" by spurious interrupts,
  550. * and, unlike other attempts at IRQ probing, they do not get hung on
  551. * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
  552. *
  553. * For reasonably foolproof probing, use them as follows:
  554. *
  555. * 1. clear and/or mask the device's internal interrupt.
  556. * 2. sti();
  557. * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
  558. * 4. enable the device and cause it to trigger an interrupt.
  559. * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
  560. * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
  561. * 7. service the device to clear its pending interrupt.
  562. * 8. loop again if paranoia is required.
  563. *
  564. * probe_irq_on() returns a mask of allocated irq's.
  565. *
  566. * probe_irq_off() takes the mask as a parameter,
  567. * and returns the irq number which occurred,
  568. * or zero if none occurred, or a negative irq number
  569. * if more than one irq occurred.
  570. */
  571. #if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE)
  572. static inline unsigned long probe_irq_on(void)
  573. {
  574. return 0;
  575. }
  576. static inline int probe_irq_off(unsigned long val)
  577. {
  578. return 0;
  579. }
  580. static inline unsigned int probe_irq_mask(unsigned long val)
  581. {
  582. return 0;
  583. }
  584. #else
  585. extern unsigned long probe_irq_on(void); /* returns 0 on failure */
  586. extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
  587. extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
  588. #endif
  589. #ifdef CONFIG_PROC_FS
  590. /* Initialize /proc/irq/ */
  591. extern void init_irq_proc(void);
  592. #else
  593. static inline void init_irq_proc(void)
  594. {
  595. }
  596. #endif
  597. struct seq_file;
  598. int show_interrupts(struct seq_file *p, void *v);
  599. int arch_show_interrupts(struct seq_file *p, int prec);
  600. extern int early_irq_init(void);
  601. extern int arch_probe_nr_irqs(void);
  602. extern int arch_early_irq_init(void);
  603. #endif