0001
0002
0003
0004
0005
0006
0007 #ifndef I915_SW_FENCE_WORK_H
0008 #define I915_SW_FENCE_WORK_H
0009
0010 #include <linux/dma-fence.h>
0011 #include <linux/spinlock.h>
0012 #include <linux/workqueue.h>
0013
0014 #include "i915_sw_fence.h"
0015
0016 struct dma_fence_work;
0017
0018 struct dma_fence_work_ops {
0019 const char *name;
0020 void (*work)(struct dma_fence_work *f);
0021 void (*release)(struct dma_fence_work *f);
0022 };
0023
0024 struct dma_fence_work {
0025 struct dma_fence dma;
0026 spinlock_t lock;
0027
0028 struct i915_sw_fence chain;
0029 struct i915_sw_dma_fence_cb cb;
0030
0031 struct work_struct work;
0032 const struct dma_fence_work_ops *ops;
0033 };
0034
0035 enum {
0036 DMA_FENCE_WORK_IMM = DMA_FENCE_FLAG_USER_BITS,
0037 };
0038
0039 void dma_fence_work_init(struct dma_fence_work *f,
0040 const struct dma_fence_work_ops *ops);
0041 int dma_fence_work_chain(struct dma_fence_work *f, struct dma_fence *signal);
0042
0043 static inline void dma_fence_work_commit(struct dma_fence_work *f)
0044 {
0045 i915_sw_fence_commit(&f->chain);
0046 }
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 static inline void dma_fence_work_commit_imm(struct dma_fence_work *f)
0060 {
0061 if (atomic_read(&f->chain.pending) <= 1)
0062 __set_bit(DMA_FENCE_WORK_IMM, &f->dma.flags);
0063
0064 dma_fence_work_commit(f);
0065 }
0066
0067 #endif