xref: /linux/drivers/gpu/drm/imagination/pvr_sync.h (revision fe33c0fbed75dd464747c0faaedf94c7d8eb4101)
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2 /* Copyright (c) 2023 Imagination Technologies Ltd. */
3 
4 #ifndef PVR_SYNC_H
5 #define PVR_SYNC_H
6 
7 #include <uapi/drm/pvr_drm.h>
8 
9 /* Forward declaration from <linux/xarray.h>. */
10 struct xarray;
11 
12 /* Forward declaration from <drm/drm_file.h>. */
13 struct drm_file;
14 
15 /* Forward declaration from <drm/gpu_scheduler.h>. */
16 struct drm_sched_job;
17 
18 /* Forward declaration from "pvr_device.h". */
19 struct pvr_file;
20 
21 /**
22  * struct pvr_sync_signal - Object encoding a syncobj signal operation
23  *
24  * The job submission logic collects all signal operations in an array of
25  * pvr_sync_signal objects. This array also serves as a cache to get the
26  * latest dma_fence when multiple jobs are submitted at once, and one job
27  * signals a syncobj point that's later waited on by a subsequent job.
28  */
29 struct pvr_sync_signal {
30 	/** @handle: Handle of the syncobj to signal. */
31 	u32 handle;
32 
33 	/**
34 	 * @point: Point to signal in the syncobj.
35 	 *
36 	 * Only relevant for timeline syncobjs.
37 	 */
38 	u64 point;
39 
40 	/** @syncobj: Syncobj retrieved from the handle. */
41 	struct drm_syncobj *syncobj;
42 
43 	/**
44 	 * @chain: Chain object used to link the new fence with the
45 	 *	   existing timeline syncobj.
46 	 *
47 	 * Should be zero when manipulating a regular syncobj.
48 	 */
49 	struct dma_fence_chain *chain;
50 
51 	/**
52 	 * @fence: New fence object to attach to the syncobj.
53 	 *
54 	 * This pointer starts with the current fence bound to
55 	 * the <handle,point> pair.
56 	 */
57 	struct dma_fence *fence;
58 };
59 
60 void
61 pvr_sync_signal_array_cleanup(struct xarray *array);
62 
63 int
64 pvr_sync_signal_array_collect_ops(struct xarray *array,
65 				  struct drm_file *file,
66 				  u32 sync_op_count,
67 				  const struct drm_pvr_sync_op *sync_ops);
68 
69 int
70 pvr_sync_signal_array_update_fences(struct xarray *array,
71 				    u32 sync_op_count,
72 				    const struct drm_pvr_sync_op *sync_ops,
73 				    struct dma_fence *done_fence);
74 
75 void
76 pvr_sync_signal_array_push_fences(struct xarray *array);
77 
78 int
79 pvr_sync_add_deps_to_job(struct pvr_file *pvr_file, struct drm_sched_job *job,
80 			 u32 sync_op_count,
81 			 const struct drm_pvr_sync_op *sync_ops,
82 			 struct xarray *signal_array);
83 
84 #endif /* PVR_SYNC_H */
85