interrupt.h 20 KB

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