xref: /linux/drivers/gpu/drm/nouveau/nouveau_exec.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1 /* SPDX-License-Identifier: MIT */
2 
3 #ifndef __NOUVEAU_EXEC_H__
4 #define __NOUVEAU_EXEC_H__
5 
6 #include "nouveau_drv.h"
7 #include "nouveau_sched.h"
8 
9 struct nouveau_exec_job_args {
10 	struct drm_file *file_priv;
11 	struct nouveau_sched *sched;
12 	struct nouveau_channel *chan;
13 
14 	struct {
15 		struct drm_nouveau_sync *s;
16 		u32 count;
17 	} in_sync;
18 
19 	struct {
20 		struct drm_nouveau_sync *s;
21 		u32 count;
22 	} out_sync;
23 
24 	struct {
25 		struct drm_nouveau_exec_push *s;
26 		u32 count;
27 	} push;
28 };
29 
30 struct nouveau_exec_job {
31 	struct nouveau_job base;
32 	struct nouveau_fence *fence;
33 	struct nouveau_channel *chan;
34 
35 	struct {
36 		struct drm_nouveau_exec_push *s;
37 		u32 count;
38 	} push;
39 };
40 
41 #define to_nouveau_exec_job(job)		\
42 		container_of((job), struct nouveau_exec_job, base)
43 
44 int nouveau_exec_job_init(struct nouveau_exec_job **job,
45 			  struct nouveau_exec_job_args *args);
46 
47 int nouveau_exec_ioctl_exec(struct drm_device *dev, void *data,
48 			    struct drm_file *file_priv);
49 
50 static inline unsigned int
nouveau_exec_push_max_from_ib_max(int ib_max)51 nouveau_exec_push_max_from_ib_max(int ib_max)
52 {
53 	/* Limit the number of IBs per job to half the size of the ring in order
54 	 * to avoid the ring running dry between submissions and preserve one
55 	 * more slot for the job's HW fence.
56 	 */
57 	return ib_max > 1 ? ib_max / 2 - 1 : 0;
58 }
59 
60 #endif
61