irq_work.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef _LINUX_IRQ_WORK_H
  2. #define _LINUX_IRQ_WORK_H
  3. #include <linux/llist.h>
  4. /*
  5. * An entry can be in one of four states:
  6. *
  7. * free NULL, 0 -> {claimed} : free to be used
  8. * claimed NULL, 3 -> {pending} : claimed to be enqueued
  9. * pending next, 3 -> {busy} : queued, pending callback
  10. * busy NULL, 2 -> {free, claimed} : callback in progress, can be claimed
  11. */
  12. #define IRQ_WORK_PENDING 1UL
  13. #define IRQ_WORK_BUSY 2UL
  14. #define IRQ_WORK_FLAGS 3UL
  15. #define IRQ_WORK_LAZY 4UL /* Doesn't want IPI, wait for tick */
  16. struct irq_work {
  17. unsigned long flags;
  18. struct llist_node llnode;
  19. void (*func)(struct irq_work *);
  20. };
  21. static inline
  22. void init_irq_work(struct irq_work *work, void (*func)(struct irq_work *))
  23. {
  24. work->flags = 0;
  25. work->func = func;
  26. }
  27. #define DEFINE_IRQ_WORK(name, _f) struct irq_work name = { .func = (_f), }
  28. bool irq_work_queue(struct irq_work *work);
  29. #ifdef CONFIG_SMP
  30. bool irq_work_queue_on(struct irq_work *work, int cpu);
  31. #endif
  32. void irq_work_tick(void);
  33. void irq_work_sync(struct irq_work *work);
  34. #ifdef CONFIG_IRQ_WORK
  35. #include <asm/irq_work.h>
  36. void irq_work_run(void);
  37. bool irq_work_needs_cpu(void);
  38. #else
  39. static inline bool irq_work_needs_cpu(void) { return false; }
  40. static inline void irq_work_run(void) { }
  41. #endif
  42. #endif /* _LINUX_IRQ_WORK_H */