interrupt.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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. * @secondary: pointer to secondary irqaction (force threading)
  98. * @thread_flags: flags related to @thread
  99. * @thread_mask: bitmask for keeping track of @thread activity
  100. * @dir: pointer to the proc/irq/NN/name entry
  101. */
  102. struct irqaction {
  103. irq_handler_t handler;
  104. void *dev_id;
  105. void __percpu *percpu_dev_id;
  106. struct irqaction *next;
  107. irq_handler_t thread_fn;
  108. struct task_struct *thread;
  109. struct irqaction *secondary;
  110. unsigned int irq;
  111. unsigned int flags;
  112. unsigned long thread_flags;
  113. unsigned long thread_mask;
  114. const char *name;
  115. struct proc_dir_entry *dir;
  116. } ____cacheline_internodealigned_in_smp;
  117. extern irqreturn_t no_action(int cpl, void *dev_id);
  118. /*
  119. * If a (PCI) device interrupt is not connected we set dev->irq to
  120. * IRQ_NOTCONNECTED. This causes request_irq() to fail with -ENOTCONN, so we
  121. * can distingiush that case from other error returns.
  122. *
  123. * 0x80000000 is guaranteed to be outside the available range of interrupts
  124. * and easy to distinguish from other possible incorrect values.
  125. */
  126. #define IRQ_NOTCONNECTED (1U << 31)
  127. extern int __must_check
  128. request_threaded_irq(unsigned int irq, irq_handler_t handler,
  129. irq_handler_t thread_fn,
  130. unsigned long flags, const char *name, void *dev);
  131. static inline int __must_check
  132. request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
  133. const char *name, void *dev)
  134. {
  135. return request_threaded_irq(irq, handler, NULL, flags, name, dev);
  136. }
  137. extern int __must_check
  138. request_any_context_irq(unsigned int irq, irq_handler_t handler,
  139. unsigned long flags, const char *name, void *dev_id);
  140. extern int __must_check
  141. request_percpu_irq(unsigned int irq, irq_handler_t handler,
  142. const char *devname, void __percpu *percpu_dev_id);
  143. extern void free_irq(unsigned int, void *);
  144. extern void free_percpu_irq(unsigned int, void __percpu *);
  145. struct device;
  146. extern int __must_check
  147. devm_request_threaded_irq(struct device *dev, unsigned int irq,
  148. irq_handler_t handler, irq_handler_t thread_fn,
  149. unsigned long irqflags, const char *devname,
  150. void *dev_id);
  151. static inline int __must_check
  152. devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
  153. unsigned long irqflags, const char *devname, void *dev_id)
  154. {
  155. return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
  156. devname, dev_id);
  157. }
  158. extern int __must_check
  159. devm_request_any_context_irq(struct device *dev, unsigned int irq,
  160. irq_handler_t handler, unsigned long irqflags,
  161. const char *devname, void *dev_id);
  162. extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
  163. /*
  164. * On lockdep we dont want to enable hardirqs in hardirq
  165. * context. Use local_irq_enable_in_hardirq() to annotate
  166. * kernel code that has to do this nevertheless (pretty much
  167. * the only valid case is for old/broken hardware that is
  168. * insanely slow).
  169. *
  170. * NOTE: in theory this might break fragile code that relies
  171. * on hardirq delivery - in practice we dont seem to have such
  172. * places left. So the only effect should be slightly increased
  173. * irqs-off latencies.
  174. */
  175. #ifdef CONFIG_LOCKDEP
  176. # define local_irq_enable_in_hardirq() do { } while (0)
  177. #else
  178. # define local_irq_enable_in_hardirq() local_irq_enable()
  179. #endif
  180. extern void disable_irq_nosync(unsigned int irq);
  181. extern bool disable_hardirq(unsigned int irq);
  182. extern void disable_irq(unsigned int irq);
  183. extern void disable_percpu_irq(unsigned int irq);
  184. extern void enable_irq(unsigned int irq);
  185. extern void enable_percpu_irq(unsigned int irq, unsigned int type);
  186. extern bool irq_percpu_is_enabled(unsigned int irq);
  187. extern void irq_wake_thread(unsigned int irq, void *dev_id);
  188. /* The following three functions are for the core kernel use only. */
  189. extern void suspend_device_irqs(void);
  190. extern void resume_device_irqs(void);
  191. /**
  192. * struct irq_affinity_notify - context for notification of IRQ affinity changes
  193. * @irq: Interrupt to which notification applies
  194. * @kref: Reference count, for internal use
  195. * @work: Work item, for internal use
  196. * @notify: Function to be called on change. This will be
  197. * called in process context.
  198. * @release: Function to be called on release. This will be
  199. * called in process context. Once registered, the
  200. * structure must only be freed when this function is
  201. * called or later.
  202. */
  203. struct irq_affinity_notify {
  204. unsigned int irq;
  205. struct kref kref;
  206. struct work_struct work;
  207. void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
  208. void (*release)(struct kref *ref);
  209. };
  210. #if defined(CONFIG_SMP)
  211. extern cpumask_var_t irq_default_affinity;
  212. /* Internal implementation. Use the helpers below */
  213. extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
  214. bool force);
  215. /**
  216. * irq_set_affinity - Set the irq affinity of a given irq
  217. * @irq: Interrupt to set affinity
  218. * @cpumask: cpumask
  219. *
  220. * Fails if cpumask does not contain an online CPU
  221. */
  222. static inline int
  223. irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
  224. {
  225. return __irq_set_affinity(irq, cpumask, false);
  226. }
  227. /**
  228. * irq_force_affinity - Force the irq affinity of a given irq
  229. * @irq: Interrupt to set affinity
  230. * @cpumask: cpumask
  231. *
  232. * Same as irq_set_affinity, but without checking the mask against
  233. * online cpus.
  234. *
  235. * Solely for low level cpu hotplug code, where we need to make per
  236. * cpu interrupts affine before the cpu becomes online.
  237. */
  238. static inline int
  239. irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
  240. {
  241. return __irq_set_affinity(irq, cpumask, true);
  242. }
  243. extern int irq_can_set_affinity(unsigned int irq);
  244. extern int irq_select_affinity(unsigned int irq);
  245. extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
  246. extern int
  247. irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
  248. struct cpumask *irq_create_affinity_masks(const struct cpumask *affinity, int nvec);
  249. int irq_calc_affinity_vectors(const struct cpumask *affinity, int maxvec);
  250. #else /* CONFIG_SMP */
  251. static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
  252. {
  253. return -EINVAL;
  254. }
  255. static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
  256. {
  257. return 0;
  258. }
  259. static inline int irq_can_set_affinity(unsigned int irq)
  260. {
  261. return 0;
  262. }
  263. static inline int irq_select_affinity(unsigned int irq) { return 0; }
  264. static inline int irq_set_affinity_hint(unsigned int irq,
  265. const struct cpumask *m)
  266. {
  267. return -EINVAL;
  268. }
  269. static inline int
  270. irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
  271. {
  272. return 0;
  273. }
  274. static inline struct cpumask *
  275. irq_create_affinity_masks(const struct cpumask *affinity, int nvec)
  276. {
  277. return NULL;
  278. }
  279. static inline int
  280. irq_calc_affinity_vectors(const struct cpumask *affinity, int maxvec)
  281. {
  282. return maxvec;
  283. }
  284. #endif /* CONFIG_SMP */
  285. /*
  286. * Special lockdep variants of irq disabling/enabling.
  287. * These should be used for locking constructs that
  288. * know that a particular irq context which is disabled,
  289. * and which is the only irq-context user of a lock,
  290. * that it's safe to take the lock in the irq-disabled
  291. * section without disabling hardirqs.
  292. *
  293. * On !CONFIG_LOCKDEP they are equivalent to the normal
  294. * irq disable/enable methods.
  295. */
  296. static inline void disable_irq_nosync_lockdep(unsigned int irq)
  297. {
  298. disable_irq_nosync(irq);
  299. #ifdef CONFIG_LOCKDEP
  300. local_irq_disable();
  301. #endif
  302. }
  303. static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags)
  304. {
  305. disable_irq_nosync(irq);
  306. #ifdef CONFIG_LOCKDEP
  307. local_irq_save(*flags);
  308. #endif
  309. }
  310. static inline void disable_irq_lockdep(unsigned int irq)
  311. {
  312. disable_irq(irq);
  313. #ifdef CONFIG_LOCKDEP
  314. local_irq_disable();
  315. #endif
  316. }
  317. static inline void enable_irq_lockdep(unsigned int irq)
  318. {
  319. #ifdef CONFIG_LOCKDEP
  320. local_irq_enable();
  321. #endif
  322. enable_irq(irq);
  323. }
  324. static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags)
  325. {
  326. #ifdef CONFIG_LOCKDEP
  327. local_irq_restore(*flags);
  328. #endif
  329. enable_irq(irq);
  330. }
  331. /* IRQ wakeup (PM) control: */
  332. extern int irq_set_irq_wake(unsigned int irq, unsigned int on);
  333. static inline int enable_irq_wake(unsigned int irq)
  334. {
  335. return irq_set_irq_wake(irq, 1);
  336. }
  337. static inline int disable_irq_wake(unsigned int irq)
  338. {
  339. return irq_set_irq_wake(irq, 0);
  340. }
  341. /*
  342. * irq_get_irqchip_state/irq_set_irqchip_state specific flags
  343. */
  344. enum irqchip_irq_state {
  345. IRQCHIP_STATE_PENDING, /* Is interrupt pending? */
  346. IRQCHIP_STATE_ACTIVE, /* Is interrupt in progress? */
  347. IRQCHIP_STATE_MASKED, /* Is interrupt masked? */
  348. IRQCHIP_STATE_LINE_LEVEL, /* Is IRQ line high? */
  349. };
  350. extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
  351. bool *state);
  352. extern int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
  353. bool state);
  354. #ifdef CONFIG_IRQ_FORCED_THREADING
  355. extern bool force_irqthreads;
  356. #else
  357. #define force_irqthreads (0)
  358. #endif
  359. #ifndef __ARCH_SET_SOFTIRQ_PENDING
  360. #define set_softirq_pending(x) (local_softirq_pending() = (x))
  361. #define or_softirq_pending(x) (local_softirq_pending() |= (x))
  362. #endif
  363. /* Some architectures might implement lazy enabling/disabling of
  364. * interrupts. In some cases, such as stop_machine, we might want
  365. * to ensure that after a local_irq_disable(), interrupts have
  366. * really been disabled in hardware. Such architectures need to
  367. * implement the following hook.
  368. */
  369. #ifndef hard_irq_disable
  370. #define hard_irq_disable() do { } while(0)
  371. #endif
  372. /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
  373. frequency threaded job scheduling. For almost all the purposes
  374. tasklets are more than enough. F.e. all serial device BHs et
  375. al. should be converted to tasklets, not to softirqs.
  376. */
  377. enum
  378. {
  379. HI_SOFTIRQ=0,
  380. TIMER_SOFTIRQ,
  381. NET_TX_SOFTIRQ,
  382. NET_RX_SOFTIRQ,
  383. BLOCK_SOFTIRQ,
  384. IRQ_POLL_SOFTIRQ,
  385. TASKLET_SOFTIRQ,
  386. SCHED_SOFTIRQ,
  387. HRTIMER_SOFTIRQ, /* Unused, but kept as tools rely on the
  388. numbering. Sigh! */
  389. RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
  390. NR_SOFTIRQS
  391. };
  392. #define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ))
  393. /* map softirq index to softirq name. update 'softirq_to_name' in
  394. * kernel/softirq.c when adding a new softirq.
  395. */
  396. extern const char * const softirq_to_name[NR_SOFTIRQS];
  397. /* softirq mask and active fields moved to irq_cpustat_t in
  398. * asm/hardirq.h to get better cache usage. KAO
  399. */
  400. struct softirq_action
  401. {
  402. void (*action)(struct softirq_action *);
  403. };
  404. asmlinkage void do_softirq(void);
  405. asmlinkage void __do_softirq(void);
  406. #ifdef __ARCH_HAS_DO_SOFTIRQ
  407. void do_softirq_own_stack(void);
  408. #else
  409. static inline void do_softirq_own_stack(void)
  410. {
  411. __do_softirq();
  412. }
  413. #endif
  414. extern void open_softirq(int nr, void (*action)(struct softirq_action *));
  415. extern void softirq_init(void);
  416. extern void __raise_softirq_irqoff(unsigned int nr);
  417. extern void raise_softirq_irqoff(unsigned int nr);
  418. extern void raise_softirq(unsigned int nr);
  419. DECLARE_PER_CPU(struct task_struct *, ksoftirqd);
  420. static inline struct task_struct *this_cpu_ksoftirqd(void)
  421. {
  422. return this_cpu_read(ksoftirqd);
  423. }
  424. /* Tasklets --- multithreaded analogue of BHs.
  425. Main feature differing them of generic softirqs: tasklet
  426. is running only on one CPU simultaneously.
  427. Main feature differing them of BHs: different tasklets
  428. may be run simultaneously on different CPUs.
  429. Properties:
  430. * If tasklet_schedule() is called, then tasklet is guaranteed
  431. to be executed on some cpu at least once after this.
  432. * If the tasklet is already scheduled, but its execution is still not
  433. started, it will be executed only once.
  434. * If this tasklet is already running on another CPU (or schedule is called
  435. from tasklet itself), it is rescheduled for later.
  436. * Tasklet is strictly serialized wrt itself, but not
  437. wrt another tasklets. If client needs some intertask synchronization,
  438. he makes it with spinlocks.
  439. */
  440. struct tasklet_struct
  441. {
  442. struct tasklet_struct *next;
  443. unsigned long state;
  444. atomic_t count;
  445. void (*func)(unsigned long);
  446. unsigned long data;
  447. };
  448. #define DECLARE_TASKLET(name, func, data) \
  449. struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
  450. #define DECLARE_TASKLET_DISABLED(name, func, data) \
  451. struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
  452. enum
  453. {
  454. TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
  455. TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
  456. };
  457. #ifdef CONFIG_SMP
  458. static inline int tasklet_trylock(struct tasklet_struct *t)
  459. {
  460. return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
  461. }
  462. static inline void tasklet_unlock(struct tasklet_struct *t)
  463. {
  464. smp_mb__before_atomic();
  465. clear_bit(TASKLET_STATE_RUN, &(t)->state);
  466. }
  467. static inline void tasklet_unlock_wait(struct tasklet_struct *t)
  468. {
  469. while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
  470. }
  471. #else
  472. #define tasklet_trylock(t) 1
  473. #define tasklet_unlock_wait(t) do { } while (0)
  474. #define tasklet_unlock(t) do { } while (0)
  475. #endif
  476. extern void __tasklet_schedule(struct tasklet_struct *t);
  477. static inline void tasklet_schedule(struct tasklet_struct *t)
  478. {
  479. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  480. __tasklet_schedule(t);
  481. }
  482. extern void __tasklet_hi_schedule(struct tasklet_struct *t);
  483. static inline void tasklet_hi_schedule(struct tasklet_struct *t)
  484. {
  485. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  486. __tasklet_hi_schedule(t);
  487. }
  488. extern void __tasklet_hi_schedule_first(struct tasklet_struct *t);
  489. /*
  490. * This version avoids touching any other tasklets. Needed for kmemcheck
  491. * in order not to take any page faults while enqueueing this tasklet;
  492. * consider VERY carefully whether you really need this or
  493. * tasklet_hi_schedule()...
  494. */
  495. static inline void tasklet_hi_schedule_first(struct tasklet_struct *t)
  496. {
  497. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  498. __tasklet_hi_schedule_first(t);
  499. }
  500. static inline void tasklet_disable_nosync(struct tasklet_struct *t)
  501. {
  502. atomic_inc(&t->count);
  503. smp_mb__after_atomic();
  504. }
  505. static inline void tasklet_disable(struct tasklet_struct *t)
  506. {
  507. tasklet_disable_nosync(t);
  508. tasklet_unlock_wait(t);
  509. smp_mb();
  510. }
  511. static inline void tasklet_enable(struct tasklet_struct *t)
  512. {
  513. smp_mb__before_atomic();
  514. atomic_dec(&t->count);
  515. }
  516. extern void tasklet_kill(struct tasklet_struct *t);
  517. extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
  518. extern void tasklet_init(struct tasklet_struct *t,
  519. void (*func)(unsigned long), unsigned long data);
  520. struct tasklet_hrtimer {
  521. struct hrtimer timer;
  522. struct tasklet_struct tasklet;
  523. enum hrtimer_restart (*function)(struct hrtimer *);
  524. };
  525. extern void
  526. tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer,
  527. enum hrtimer_restart (*function)(struct hrtimer *),
  528. clockid_t which_clock, enum hrtimer_mode mode);
  529. static inline
  530. void tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time,
  531. const enum hrtimer_mode mode)
  532. {
  533. hrtimer_start(&ttimer->timer, time, mode);
  534. }
  535. static inline
  536. void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer)
  537. {
  538. hrtimer_cancel(&ttimer->timer);
  539. tasklet_kill(&ttimer->tasklet);
  540. }
  541. /*
  542. * Autoprobing for irqs:
  543. *
  544. * probe_irq_on() and probe_irq_off() provide robust primitives
  545. * for accurate IRQ probing during kernel initialization. They are
  546. * reasonably simple to use, are not "fooled" by spurious interrupts,
  547. * and, unlike other attempts at IRQ probing, they do not get hung on
  548. * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
  549. *
  550. * For reasonably foolproof probing, use them as follows:
  551. *
  552. * 1. clear and/or mask the device's internal interrupt.
  553. * 2. sti();
  554. * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
  555. * 4. enable the device and cause it to trigger an interrupt.
  556. * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
  557. * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
  558. * 7. service the device to clear its pending interrupt.
  559. * 8. loop again if paranoia is required.
  560. *
  561. * probe_irq_on() returns a mask of allocated irq's.
  562. *
  563. * probe_irq_off() takes the mask as a parameter,
  564. * and returns the irq number which occurred,
  565. * or zero if none occurred, or a negative irq number
  566. * if more than one irq occurred.
  567. */
  568. #if !defined(CONFIG_GENERIC_IRQ_PROBE)
  569. static inline unsigned long probe_irq_on(void)
  570. {
  571. return 0;
  572. }
  573. static inline int probe_irq_off(unsigned long val)
  574. {
  575. return 0;
  576. }
  577. static inline unsigned int probe_irq_mask(unsigned long val)
  578. {
  579. return 0;
  580. }
  581. #else
  582. extern unsigned long probe_irq_on(void); /* returns 0 on failure */
  583. extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
  584. extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
  585. #endif
  586. #ifdef CONFIG_PROC_FS
  587. /* Initialize /proc/irq/ */
  588. extern void init_irq_proc(void);
  589. #else
  590. static inline void init_irq_proc(void)
  591. {
  592. }
  593. #endif
  594. struct seq_file;
  595. int show_interrupts(struct seq_file *p, void *v);
  596. int arch_show_interrupts(struct seq_file *p, int prec);
  597. extern int early_irq_init(void);
  598. extern int arch_probe_nr_irqs(void);
  599. extern int arch_early_irq_init(void);
  600. #if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
  601. /*
  602. * We want to know which function is an entrypoint of a hardirq or a softirq.
  603. */
  604. #define __irq_entry __attribute__((__section__(".irqentry.text")))
  605. #define __softirq_entry \
  606. __attribute__((__section__(".softirqentry.text")))
  607. /* Limits of hardirq entrypoints */
  608. extern char __irqentry_text_start[];
  609. extern char __irqentry_text_end[];
  610. /* Limits of softirq entrypoints */
  611. extern char __softirqentry_text_start[];
  612. extern char __softirqentry_text_end[];
  613. #else
  614. #define __irq_entry
  615. #define __softirq_entry
  616. #endif
  617. #endif