irq.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. #ifndef _LINUX_IRQ_H
  2. #define _LINUX_IRQ_H
  3. /*
  4. * Please do not include this file in generic code. There is currently
  5. * no requirement for any architecture to implement anything held
  6. * within this file.
  7. *
  8. * Thanks. --rmk
  9. */
  10. #include <linux/smp.h>
  11. #ifndef CONFIG_S390
  12. #include <linux/linkage.h>
  13. #include <linux/cache.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/cpumask.h>
  16. #include <linux/gfp.h>
  17. #include <linux/irqreturn.h>
  18. #include <linux/irqnr.h>
  19. #include <linux/errno.h>
  20. #include <linux/topology.h>
  21. #include <linux/wait.h>
  22. #include <asm/irq.h>
  23. #include <asm/ptrace.h>
  24. #include <asm/irq_regs.h>
  25. struct irq_desc;
  26. typedef void (*irq_flow_handler_t)(unsigned int irq,
  27. struct irq_desc *desc);
  28. /*
  29. * IRQ line status.
  30. *
  31. * Bits 0-7 are reserved for the IRQF_* bits in linux/interrupt.h
  32. *
  33. * IRQ types
  34. */
  35. #define IRQ_TYPE_NONE 0x00000000 /* Default, unspecified type */
  36. #define IRQ_TYPE_EDGE_RISING 0x00000001 /* Edge rising type */
  37. #define IRQ_TYPE_EDGE_FALLING 0x00000002 /* Edge falling type */
  38. #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
  39. #define IRQ_TYPE_LEVEL_HIGH 0x00000004 /* Level high type */
  40. #define IRQ_TYPE_LEVEL_LOW 0x00000008 /* Level low type */
  41. #define IRQ_TYPE_SENSE_MASK 0x0000000f /* Mask of the above */
  42. #define IRQ_TYPE_PROBE 0x00000010 /* Probing in progress */
  43. /* Internal flags */
  44. #define IRQ_INPROGRESS 0x00000100 /* IRQ handler active - do not enter! */
  45. #define IRQ_DISABLED 0x00000200 /* IRQ disabled - do not enter! */
  46. #define IRQ_PENDING 0x00000400 /* IRQ pending - replay on enable */
  47. #define IRQ_REPLAY 0x00000800 /* IRQ has been replayed but not acked yet */
  48. #define IRQ_AUTODETECT 0x00001000 /* IRQ is being autodetected */
  49. #define IRQ_WAITING 0x00002000 /* IRQ not yet seen - for autodetection */
  50. #define IRQ_LEVEL 0x00004000 /* IRQ level triggered */
  51. #define IRQ_MASKED 0x00008000 /* IRQ masked - shouldn't be seen again */
  52. #define IRQ_PER_CPU 0x00010000 /* IRQ is per CPU */
  53. #define IRQ_NOPROBE 0x00020000 /* IRQ is not valid for probing */
  54. #define IRQ_NOREQUEST 0x00040000 /* IRQ cannot be requested */
  55. #define IRQ_NOAUTOEN 0x00080000 /* IRQ will not be enabled on request irq */
  56. #define IRQ_WAKEUP 0x00100000 /* IRQ triggers system wakeup */
  57. #define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */
  58. #define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */
  59. #define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */
  60. #define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */
  61. #define IRQ_AFFINITY_SET 0x02000000 /* IRQ affinity was set from userspace*/
  62. #define IRQ_SUSPENDED 0x04000000 /* IRQ has gone through suspend sequence */
  63. #define IRQ_ONESHOT 0x08000000 /* IRQ is not unmasked after hardirq */
  64. #define IRQ_NESTED_THREAD 0x10000000 /* IRQ is nested into another, no own handler thread */
  65. #ifdef CONFIG_IRQ_PER_CPU
  66. # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
  67. # define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)
  68. #else
  69. # define CHECK_IRQ_PER_CPU(var) 0
  70. # define IRQ_NO_BALANCING_MASK IRQ_NO_BALANCING
  71. #endif
  72. struct proc_dir_entry;
  73. struct msi_desc;
  74. /**
  75. * struct irq_data - per irq and irq chip data passed down to chip functions
  76. * @irq: interrupt number
  77. * @node: node index useful for balancing
  78. * @chip: low level interrupt hardware access
  79. * @handler_data: per-IRQ data for the irq_chip methods
  80. * @chip_data: platform-specific per-chip private data for the chip
  81. * methods, to allow shared chip implementations
  82. * @msi_desc: MSI descriptor
  83. * @affinity: IRQ affinity on SMP
  84. * @irq_2_iommu: iommu with this irq
  85. *
  86. * The fields here need to overlay the ones in irq_desc until we
  87. * cleaned up the direct references and switched everything over to
  88. * irq_data.
  89. */
  90. struct irq_data {
  91. unsigned int irq;
  92. unsigned int node;
  93. struct irq_chip *chip;
  94. void *handler_data;
  95. void *chip_data;
  96. struct msi_desc *msi_desc;
  97. #ifdef CONFIG_SMP
  98. cpumask_var_t affinity;
  99. #endif
  100. #ifdef CONFIG_INTR_REMAP
  101. struct irq_2_iommu *irq_2_iommu;
  102. #endif
  103. };
  104. /**
  105. * struct irq_chip - hardware interrupt chip descriptor
  106. *
  107. * @name: name for /proc/interrupts
  108. * @startup: deprecated, replaced by irq_startup
  109. * @shutdown: deprecated, replaced by irq_shutdown
  110. * @enable: deprecated, replaced by irq_enable
  111. * @disable: deprecated, replaced by irq_disable
  112. * @ack: deprecated, replaced by irq_ack
  113. * @mask: deprecated, replaced by irq_mask
  114. * @mask_ack: deprecated, replaced by irq_mask_ack
  115. * @unmask: deprecated, replaced by irq_unmask
  116. * @eoi: deprecated, replaced by irq_eoi
  117. * @end: deprecated, will go away with __do_IRQ()
  118. * @set_affinity: deprecated, replaced by irq_set_affinity
  119. * @retrigger: deprecated, replaced by irq_retrigger
  120. * @set_type: deprecated, replaced by irq_set_type
  121. * @set_wake: deprecated, replaced by irq_wake
  122. * @bus_lock: deprecated, replaced by irq_bus_lock
  123. * @bus_sync_unlock: deprecated, replaced by irq_bus_sync_unlock
  124. *
  125. * @irq_startup: start up the interrupt (defaults to ->enable if NULL)
  126. * @irq_shutdown: shut down the interrupt (defaults to ->disable if NULL)
  127. * @irq_enable: enable the interrupt (defaults to chip->unmask if NULL)
  128. * @irq_disable: disable the interrupt
  129. * @irq_ack: start of a new interrupt
  130. * @irq_mask: mask an interrupt source
  131. * @irq_mask_ack: ack and mask an interrupt source
  132. * @irq_unmask: unmask an interrupt source
  133. * @irq_eoi: end of interrupt
  134. * @irq_set_affinity: set the CPU affinity on SMP machines
  135. * @irq_retrigger: resend an IRQ to the CPU
  136. * @irq_set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
  137. * @irq_set_wake: enable/disable power-management wake-on of an IRQ
  138. * @irq_bus_lock: function to lock access to slow bus (i2c) chips
  139. * @irq_bus_sync_unlock:function to sync and unlock slow bus (i2c) chips
  140. *
  141. * @release: release function solely used by UML
  142. */
  143. struct irq_chip {
  144. const char *name;
  145. #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
  146. unsigned int (*startup)(unsigned int irq);
  147. void (*shutdown)(unsigned int irq);
  148. void (*enable)(unsigned int irq);
  149. void (*disable)(unsigned int irq);
  150. void (*ack)(unsigned int irq);
  151. void (*mask)(unsigned int irq);
  152. void (*mask_ack)(unsigned int irq);
  153. void (*unmask)(unsigned int irq);
  154. void (*eoi)(unsigned int irq);
  155. void (*end)(unsigned int irq);
  156. int (*set_affinity)(unsigned int irq,
  157. const struct cpumask *dest);
  158. int (*retrigger)(unsigned int irq);
  159. int (*set_type)(unsigned int irq, unsigned int flow_type);
  160. int (*set_wake)(unsigned int irq, unsigned int on);
  161. void (*bus_lock)(unsigned int irq);
  162. void (*bus_sync_unlock)(unsigned int irq);
  163. #endif
  164. unsigned int (*irq_startup)(struct irq_data *data);
  165. void (*irq_shutdown)(struct irq_data *data);
  166. void (*irq_enable)(struct irq_data *data);
  167. void (*irq_disable)(struct irq_data *data);
  168. void (*irq_ack)(struct irq_data *data);
  169. void (*irq_mask)(struct irq_data *data);
  170. void (*irq_mask_ack)(struct irq_data *data);
  171. void (*irq_unmask)(struct irq_data *data);
  172. void (*irq_eoi)(struct irq_data *data);
  173. int (*irq_set_affinity)(struct irq_data *data, const struct cpumask *dest, bool force);
  174. int (*irq_retrigger)(struct irq_data *data);
  175. int (*irq_set_type)(struct irq_data *data, unsigned int flow_type);
  176. int (*irq_set_wake)(struct irq_data *data, unsigned int on);
  177. void (*irq_bus_lock)(struct irq_data *data);
  178. void (*irq_bus_sync_unlock)(struct irq_data *data);
  179. /* Currently used only by UML, might disappear one day.*/
  180. #ifdef CONFIG_IRQ_RELEASE_METHOD
  181. void (*release)(unsigned int irq, void *dev_id);
  182. #endif
  183. };
  184. struct timer_rand_state;
  185. struct irq_2_iommu;
  186. /**
  187. * struct irq_desc - interrupt descriptor
  188. * @irq_data: per irq and chip data passed down to chip functions
  189. * @timer_rand_state: pointer to timer rand state struct
  190. * @kstat_irqs: irq stats per cpu
  191. * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
  192. * @action: the irq action chain
  193. * @status: status information
  194. * @depth: disable-depth, for nested irq_disable() calls
  195. * @wake_depth: enable depth, for multiple set_irq_wake() callers
  196. * @irq_count: stats field to detect stalled irqs
  197. * @last_unhandled: aging timer for unhandled count
  198. * @irqs_unhandled: stats field for spurious unhandled interrupts
  199. * @lock: locking for SMP
  200. * @pending_mask: pending rebalanced interrupts
  201. * @threads_active: number of irqaction threads currently running
  202. * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
  203. * @dir: /proc/irq/ procfs entry
  204. * @name: flow handler name for /proc/interrupts output
  205. */
  206. struct irq_desc {
  207. #ifdef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
  208. struct irq_data irq_data;
  209. #else
  210. /*
  211. * This union will go away, once we fixed the direct access to
  212. * irq_desc all over the place. The direct fields are a 1:1
  213. * overlay of irq_data.
  214. */
  215. union {
  216. struct irq_data irq_data;
  217. struct {
  218. unsigned int irq;
  219. unsigned int node;
  220. struct irq_chip *chip;
  221. void *handler_data;
  222. void *chip_data;
  223. struct msi_desc *msi_desc;
  224. #ifdef CONFIG_SMP
  225. cpumask_var_t affinity;
  226. #endif
  227. #ifdef CONFIG_INTR_REMAP
  228. struct irq_2_iommu *irq_2_iommu;
  229. #endif
  230. };
  231. };
  232. #endif
  233. struct timer_rand_state *timer_rand_state;
  234. unsigned int *kstat_irqs;
  235. irq_flow_handler_t handle_irq;
  236. struct irqaction *action; /* IRQ action list */
  237. unsigned int status; /* IRQ status */
  238. unsigned int depth; /* nested irq disables */
  239. unsigned int wake_depth; /* nested wake enables */
  240. unsigned int irq_count; /* For detecting broken IRQs */
  241. unsigned long last_unhandled; /* Aging timer for unhandled count */
  242. unsigned int irqs_unhandled;
  243. raw_spinlock_t lock;
  244. #ifdef CONFIG_SMP
  245. const struct cpumask *affinity_hint;
  246. #ifdef CONFIG_GENERIC_PENDING_IRQ
  247. cpumask_var_t pending_mask;
  248. #endif
  249. #endif
  250. atomic_t threads_active;
  251. wait_queue_head_t wait_for_threads;
  252. #ifdef CONFIG_PROC_FS
  253. struct proc_dir_entry *dir;
  254. #endif
  255. const char *name;
  256. } ____cacheline_internodealigned_in_smp;
  257. extern void arch_init_copy_chip_data(struct irq_desc *old_desc,
  258. struct irq_desc *desc, int node);
  259. extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc);
  260. #ifndef CONFIG_SPARSE_IRQ
  261. extern struct irq_desc irq_desc[NR_IRQS];
  262. #endif
  263. #ifdef CONFIG_NUMA_IRQ_DESC
  264. extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int node);
  265. #else
  266. static inline struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
  267. {
  268. return desc;
  269. }
  270. #endif
  271. extern struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node);
  272. /*
  273. * Pick up the arch-dependent methods:
  274. */
  275. #include <asm/hw_irq.h>
  276. extern int setup_irq(unsigned int irq, struct irqaction *new);
  277. extern void remove_irq(unsigned int irq, struct irqaction *act);
  278. #ifdef CONFIG_GENERIC_HARDIRQS
  279. #ifdef CONFIG_SMP
  280. #ifdef CONFIG_GENERIC_PENDING_IRQ
  281. void move_native_irq(int irq);
  282. void move_masked_irq(int irq);
  283. #else /* CONFIG_GENERIC_PENDING_IRQ */
  284. static inline void move_irq(int irq)
  285. {
  286. }
  287. static inline void move_native_irq(int irq)
  288. {
  289. }
  290. static inline void move_masked_irq(int irq)
  291. {
  292. }
  293. #endif /* CONFIG_GENERIC_PENDING_IRQ */
  294. #else /* CONFIG_SMP */
  295. #define move_native_irq(x)
  296. #define move_masked_irq(x)
  297. #endif /* CONFIG_SMP */
  298. extern int no_irq_affinity;
  299. static inline int irq_balancing_disabled(unsigned int irq)
  300. {
  301. struct irq_desc *desc;
  302. desc = irq_to_desc(irq);
  303. return desc->status & IRQ_NO_BALANCING_MASK;
  304. }
  305. /* Handle irq action chains: */
  306. extern irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action);
  307. /*
  308. * Built-in IRQ handlers for various IRQ types,
  309. * callable via desc->handle_irq()
  310. */
  311. extern void handle_level_irq(unsigned int irq, struct irq_desc *desc);
  312. extern void handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc);
  313. extern void handle_edge_irq(unsigned int irq, struct irq_desc *desc);
  314. extern void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
  315. extern void handle_percpu_irq(unsigned int irq, struct irq_desc *desc);
  316. extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
  317. extern void handle_nested_irq(unsigned int irq);
  318. /*
  319. * Monolithic do_IRQ implementation.
  320. */
  321. #ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
  322. extern unsigned int __do_IRQ(unsigned int irq);
  323. #endif
  324. /*
  325. * Architectures call this to let the generic IRQ layer
  326. * handle an interrupt. If the descriptor is attached to an
  327. * irqchip-style controller then we call the ->handle_irq() handler,
  328. * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
  329. */
  330. static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
  331. {
  332. #ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
  333. desc->handle_irq(irq, desc);
  334. #else
  335. if (likely(desc->handle_irq))
  336. desc->handle_irq(irq, desc);
  337. else
  338. __do_IRQ(irq);
  339. #endif
  340. }
  341. static inline void generic_handle_irq(unsigned int irq)
  342. {
  343. generic_handle_irq_desc(irq, irq_to_desc(irq));
  344. }
  345. /* Handling of unhandled and spurious interrupts: */
  346. extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
  347. irqreturn_t action_ret);
  348. /* Resending of interrupts :*/
  349. void check_irq_resend(struct irq_desc *desc, unsigned int irq);
  350. /* Enable/disable irq debugging output: */
  351. extern int noirqdebug_setup(char *str);
  352. /* Checks whether the interrupt can be requested by request_irq(): */
  353. extern int can_request_irq(unsigned int irq, unsigned long irqflags);
  354. /* Dummy irq-chip implementations: */
  355. extern struct irq_chip no_irq_chip;
  356. extern struct irq_chip dummy_irq_chip;
  357. extern void
  358. set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
  359. irq_flow_handler_t handle);
  360. extern void
  361. set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
  362. irq_flow_handler_t handle, const char *name);
  363. extern void
  364. __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
  365. const char *name);
  366. /* caller has locked the irq_desc and both params are valid */
  367. static inline void __set_irq_handler_unlocked(int irq,
  368. irq_flow_handler_t handler)
  369. {
  370. struct irq_desc *desc;
  371. desc = irq_to_desc(irq);
  372. desc->handle_irq = handler;
  373. }
  374. /*
  375. * Set a highlevel flow handler for a given IRQ:
  376. */
  377. static inline void
  378. set_irq_handler(unsigned int irq, irq_flow_handler_t handle)
  379. {
  380. __set_irq_handler(irq, handle, 0, NULL);
  381. }
  382. /*
  383. * Set a highlevel chained flow handler for a given IRQ.
  384. * (a chained handler is automatically enabled and set to
  385. * IRQ_NOREQUEST and IRQ_NOPROBE)
  386. */
  387. static inline void
  388. set_irq_chained_handler(unsigned int irq,
  389. irq_flow_handler_t handle)
  390. {
  391. __set_irq_handler(irq, handle, 1, NULL);
  392. }
  393. extern void set_irq_nested_thread(unsigned int irq, int nest);
  394. extern void set_irq_noprobe(unsigned int irq);
  395. extern void set_irq_probe(unsigned int irq);
  396. /* Handle dynamic irq creation and destruction */
  397. extern unsigned int create_irq_nr(unsigned int irq_want, int node);
  398. extern int create_irq(void);
  399. extern void destroy_irq(unsigned int irq);
  400. /* Test to see if a driver has successfully requested an irq */
  401. static inline int irq_has_action(unsigned int irq)
  402. {
  403. struct irq_desc *desc = irq_to_desc(irq);
  404. return desc->action != NULL;
  405. }
  406. /* Dynamic irq helper functions */
  407. extern void dynamic_irq_init(unsigned int irq);
  408. void dynamic_irq_init_keep_chip_data(unsigned int irq);
  409. extern void dynamic_irq_cleanup(unsigned int irq);
  410. void dynamic_irq_cleanup_keep_chip_data(unsigned int irq);
  411. /* Set/get chip/data for an IRQ: */
  412. extern int set_irq_chip(unsigned int irq, struct irq_chip *chip);
  413. extern int set_irq_data(unsigned int irq, void *data);
  414. extern int set_irq_chip_data(unsigned int irq, void *data);
  415. extern int set_irq_type(unsigned int irq, unsigned int type);
  416. extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
  417. #define get_irq_chip(irq) (irq_to_desc(irq)->irq_data.chip)
  418. #define get_irq_chip_data(irq) (irq_to_desc(irq)->irq_data.chip_data)
  419. #define get_irq_data(irq) (irq_to_desc(irq)->irq_data.handler_data)
  420. #define get_irq_msi(irq) (irq_to_desc(irq)->irq_data.msi_desc)
  421. #define get_irq_desc_chip(desc) ((desc)->irq_data.chip)
  422. #define get_irq_desc_chip_data(desc) ((desc)->irq_data.chip_data)
  423. #define get_irq_desc_data(desc) ((desc)->irq_data.handler_data)
  424. #define get_irq_desc_msi(desc) ((desc)->irq_data.msi_desc)
  425. #endif /* CONFIG_GENERIC_HARDIRQS */
  426. #endif /* !CONFIG_S390 */
  427. #ifdef CONFIG_SMP
  428. /**
  429. * alloc_desc_masks - allocate cpumasks for irq_desc
  430. * @desc: pointer to irq_desc struct
  431. * @node: node which will be handling the cpumasks
  432. * @boot: true if need bootmem
  433. *
  434. * Allocates affinity and pending_mask cpumask if required.
  435. * Returns true if successful (or not required).
  436. */
  437. static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
  438. bool boot)
  439. {
  440. gfp_t gfp = GFP_ATOMIC;
  441. if (boot)
  442. gfp = GFP_NOWAIT;
  443. #ifdef CONFIG_CPUMASK_OFFSTACK
  444. if (!alloc_cpumask_var_node(&desc->irq_data.affinity, gfp, node))
  445. return false;
  446. #ifdef CONFIG_GENERIC_PENDING_IRQ
  447. if (!alloc_cpumask_var_node(&desc->pending_mask, gfp, node)) {
  448. free_cpumask_var(desc->irq_data.affinity);
  449. return false;
  450. }
  451. #endif
  452. #endif
  453. return true;
  454. }
  455. static inline void init_desc_masks(struct irq_desc *desc)
  456. {
  457. cpumask_setall(desc->irq_data.affinity);
  458. #ifdef CONFIG_GENERIC_PENDING_IRQ
  459. cpumask_clear(desc->pending_mask);
  460. #endif
  461. }
  462. /**
  463. * init_copy_desc_masks - copy cpumasks for irq_desc
  464. * @old_desc: pointer to old irq_desc struct
  465. * @new_desc: pointer to new irq_desc struct
  466. *
  467. * Insures affinity and pending_masks are copied to new irq_desc.
  468. * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the
  469. * irq_desc struct so the copy is redundant.
  470. */
  471. static inline void init_copy_desc_masks(struct irq_desc *old_desc,
  472. struct irq_desc *new_desc)
  473. {
  474. #ifdef CONFIG_CPUMASK_OFFSTACK
  475. cpumask_copy(new_desc->irq_data.affinity, old_desc->irq_data.affinity);
  476. #ifdef CONFIG_GENERIC_PENDING_IRQ
  477. cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);
  478. #endif
  479. #endif
  480. }
  481. static inline void free_desc_masks(struct irq_desc *old_desc,
  482. struct irq_desc *new_desc)
  483. {
  484. free_cpumask_var(old_desc->irq_data.affinity);
  485. #ifdef CONFIG_GENERIC_PENDING_IRQ
  486. free_cpumask_var(old_desc->pending_mask);
  487. #endif
  488. }
  489. #else /* !CONFIG_SMP */
  490. static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
  491. bool boot)
  492. {
  493. return true;
  494. }
  495. static inline void init_desc_masks(struct irq_desc *desc)
  496. {
  497. }
  498. static inline void init_copy_desc_masks(struct irq_desc *old_desc,
  499. struct irq_desc *new_desc)
  500. {
  501. }
  502. static inline void free_desc_masks(struct irq_desc *old_desc,
  503. struct irq_desc *new_desc)
  504. {
  505. }
  506. #endif /* CONFIG_SMP */
  507. #endif /* _LINUX_IRQ_H */