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