xref: /openbsd/sys/dev/pci/drm/i915/i915_deps.h (revision 1bb76ff1)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2021 Intel Corporation
4  */
5 
6 #ifndef _I915_DEPS_H_
7 #define _I915_DEPS_H_
8 
9 #include <linux/types.h>
10 
11 struct ttm_operation_ctx;
12 struct dma_fence;
13 struct dma_resv;
14 
15 /**
16  * struct i915_deps - Collect dependencies into a single dma-fence
17  * @single: Storage for pointer if the collection is a single fence.
18  * @fences: Allocated array of fence pointers if more than a single fence;
19  * otherwise points to the address of @single.
20  * @num_deps: Current number of dependency fences.
21  * @fences_size: Size of the @fences array in number of pointers.
22  * @gfp: Allocation mode.
23  */
24 struct i915_deps {
25 	struct dma_fence *single;
26 	struct dma_fence **fences;
27 	unsigned int num_deps;
28 	unsigned int fences_size;
29 	gfp_t gfp;
30 };
31 
32 void i915_deps_init(struct i915_deps *deps, gfp_t gfp);
33 
34 void i915_deps_fini(struct i915_deps *deps);
35 
36 int i915_deps_add_dependency(struct i915_deps *deps,
37 			     struct dma_fence *fence,
38 			     const struct ttm_operation_ctx *ctx);
39 
40 int i915_deps_add_resv(struct i915_deps *deps, struct dma_resv *resv,
41 		       const struct ttm_operation_ctx *ctx);
42 
43 int i915_deps_sync(const struct i915_deps *deps,
44 		   const struct ttm_operation_ctx *ctx);
45 #endif
46