irq_work.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. void irq_work_queue(struct irq_work *work);
  28. void irq_work_run(void);
  29. void irq_work_sync(struct irq_work *work);
  30. #ifdef CONFIG_IRQ_WORK
  31. bool irq_work_needs_cpu(void);
  32. #else
  33. static bool irq_work_needs_cpu(void) { return false; }
  34. #endif
  35. #endif /* _LINUX_IRQ_WORK_H */