xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence_work.h (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: i915_sw_fence_work.h,v 1.2 2021/12/18 23:45:28 riastradh Exp $	*/
2 
3 /* SPDX-License-Identifier: MIT */
4 
5 /*
6  * Copyright © 2019 Intel Corporation
7  */
8 
9 #ifndef I915_SW_FENCE_WORK_H
10 #define I915_SW_FENCE_WORK_H
11 
12 #include <linux/dma-fence.h>
13 #include <linux/spinlock.h>
14 #include <linux/workqueue.h>
15 
16 #include "i915_sw_fence.h"
17 
18 struct dma_fence_work;
19 
20 struct dma_fence_work_ops {
21 	const char *name;
22 	int (*work)(struct dma_fence_work *f);
23 	void (*release)(struct dma_fence_work *f);
24 };
25 
26 struct dma_fence_work {
27 	struct dma_fence dma;
28 	spinlock_t lock;
29 
30 	struct i915_sw_fence chain;
31 	struct i915_sw_dma_fence_cb cb;
32 
33 	struct work_struct work;
34 	const struct dma_fence_work_ops *ops;
35 };
36 
37 void dma_fence_work_init(struct dma_fence_work *f,
38 			 const struct dma_fence_work_ops *ops);
39 int dma_fence_work_chain(struct dma_fence_work *f, struct dma_fence *signal);
40 
dma_fence_work_commit(struct dma_fence_work * f)41 static inline void dma_fence_work_commit(struct dma_fence_work *f)
42 {
43 	i915_sw_fence_commit(&f->chain);
44 }
45 
46 #endif /* I915_SW_FENCE_WORK_H */
47