xref: /linux/drivers/gpu/drm/xe/xe_gpu_scheduler.h (revision 24b10e5f8e0d2bee1a10fc67011ea5d936c1a389)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef _XE_GPU_SCHEDULER_H_
7 #define _XE_GPU_SCHEDULER_H_
8 
9 #include "xe_gpu_scheduler_types.h"
10 #include "xe_sched_job_types.h"
11 
12 int xe_sched_init(struct xe_gpu_scheduler *sched,
13 		  const struct drm_sched_backend_ops *ops,
14 		  const struct xe_sched_backend_ops *xe_ops,
15 		  struct workqueue_struct *submit_wq,
16 		  uint32_t hw_submission, unsigned hang_limit,
17 		  long timeout, struct workqueue_struct *timeout_wq,
18 		  atomic_t *score, const char *name,
19 		  struct device *dev);
20 void xe_sched_fini(struct xe_gpu_scheduler *sched);
21 
22 void xe_sched_submission_start(struct xe_gpu_scheduler *sched);
23 void xe_sched_submission_stop(struct xe_gpu_scheduler *sched);
24 
25 void xe_sched_add_msg(struct xe_gpu_scheduler *sched,
26 		      struct xe_sched_msg *msg);
27 
28 static inline void xe_sched_stop(struct xe_gpu_scheduler *sched)
29 {
30 	drm_sched_stop(&sched->base, NULL);
31 }
32 
33 static inline void xe_sched_tdr_queue_imm(struct xe_gpu_scheduler *sched)
34 {
35 	drm_sched_tdr_queue_imm(&sched->base);
36 }
37 
38 static inline void xe_sched_resubmit_jobs(struct xe_gpu_scheduler *sched)
39 {
40 	drm_sched_resubmit_jobs(&sched->base);
41 }
42 
43 static inline bool
44 xe_sched_invalidate_job(struct xe_sched_job *job, int threshold)
45 {
46 	return drm_sched_invalidate_job(&job->drm, threshold);
47 }
48 
49 static inline void xe_sched_add_pending_job(struct xe_gpu_scheduler *sched,
50 					    struct xe_sched_job *job)
51 {
52 	list_add(&job->drm.list, &sched->base.pending_list);
53 }
54 
55 static inline
56 struct xe_sched_job *xe_sched_first_pending_job(struct xe_gpu_scheduler *sched)
57 {
58 	return list_first_entry_or_null(&sched->base.pending_list,
59 					struct xe_sched_job, drm.list);
60 }
61 
62 static inline int
63 xe_sched_entity_init(struct xe_sched_entity *entity,
64 		     struct xe_gpu_scheduler *sched)
65 {
66 	return drm_sched_entity_init(entity, 0,
67 				     (struct drm_gpu_scheduler **)&sched,
68 				     1, NULL);
69 }
70 
71 #define xe_sched_entity_fini drm_sched_entity_fini
72 
73 #endif
74