at master 2.0 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _LINUX_IRQ_WORK_H 3#define _LINUX_IRQ_WORK_H 4 5#include <linux/irq_work_types.h> 6#include <linux/rcuwait.h> 7#include <linux/smp_types.h> 8 9/* 10 * An entry can be in one of four states: 11 * 12 * free NULL, 0 -> {claimed} : free to be used 13 * claimed NULL, 3 -> {pending} : claimed to be enqueued 14 * pending next, 3 -> {busy} : queued, pending callback 15 * busy NULL, 2 -> {free, claimed} : callback in progress, can be claimed 16 */ 17 18#define __IRQ_WORK_INIT(_func, _flags) (struct irq_work){ \ 19 .node = { .u_flags = (_flags), }, \ 20 .func = (_func), \ 21 .irqwait = __RCUWAIT_INITIALIZER(irqwait), \ 22} 23 24#define IRQ_WORK_INIT(_func) __IRQ_WORK_INIT(_func, 0) 25#define IRQ_WORK_INIT_LAZY(_func) __IRQ_WORK_INIT(_func, IRQ_WORK_LAZY) 26#define IRQ_WORK_INIT_HARD(_func) __IRQ_WORK_INIT(_func, IRQ_WORK_HARD_IRQ) 27 28#define DEFINE_IRQ_WORK(name, _f) \ 29 struct irq_work name = IRQ_WORK_INIT(_f) 30 31static inline 32void init_irq_work(struct irq_work *work, void (*func)(struct irq_work *)) 33{ 34 *work = IRQ_WORK_INIT(func); 35} 36 37static inline bool irq_work_is_pending(struct irq_work *work) 38{ 39 return atomic_read(&work->node.a_flags) & IRQ_WORK_PENDING; 40} 41 42static inline bool irq_work_is_busy(struct irq_work *work) 43{ 44 return atomic_read(&work->node.a_flags) & IRQ_WORK_BUSY; 45} 46 47static inline bool irq_work_is_hard(struct irq_work *work) 48{ 49 return atomic_read(&work->node.a_flags) & IRQ_WORK_HARD_IRQ; 50} 51 52bool irq_work_queue(struct irq_work *work); 53bool irq_work_queue_on(struct irq_work *work, int cpu); 54 55void irq_work_tick(void); 56void irq_work_sync(struct irq_work *work); 57 58#ifdef CONFIG_IRQ_WORK 59#include <asm/irq_work.h> 60 61void irq_work_run(void); 62bool irq_work_needs_cpu(void); 63void irq_work_single(void *arg); 64 65void arch_irq_work_raise(void); 66 67#else 68static inline bool irq_work_needs_cpu(void) { return false; } 69static inline void irq_work_run(void) { } 70static inline void irq_work_single(void *arg) { } 71#endif 72 73#endif /* _LINUX_IRQ_WORK_H */