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