1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright © 2018 Intel Corporation
5  */
6 
7 #ifndef _I915_SCHEDULER_H_
8 #define _I915_SCHEDULER_H_
9 
10 #include <linux/bitops.h>
11 #include <linux/list.h>
12 #include <linux/kernel.h>
13 
14 #include "i915_scheduler_types.h"
15 
16 struct drm_printer;
17 
18 #define priolist_for_each_request(it, plist) \
19 	list_for_each_entry(it, &(plist)->requests, sched.link)
20 
21 #define priolist_for_each_request_consume(it, n, plist) \
22 	list_for_each_entry_safe(it, n, &(plist)->requests, sched.link)
23 
24 void i915_sched_node_init(struct i915_sched_node *node);
25 void i915_sched_node_reinit(struct i915_sched_node *node);
26 
27 bool __i915_sched_node_add_dependency(struct i915_sched_node *node,
28 				      struct i915_sched_node *signal,
29 				      struct i915_dependency *dep,
30 				      unsigned long flags);
31 
32 int i915_sched_node_add_dependency(struct i915_sched_node *node,
33 				   struct i915_sched_node *signal,
34 				   unsigned long flags);
35 
36 void i915_sched_node_fini(struct i915_sched_node *node);
37 
38 void i915_schedule(struct i915_request *request,
39 		   const struct i915_sched_attr *attr);
40 
41 struct list_head *
42 i915_sched_lookup_priolist(struct intel_engine_cs *engine, int prio);
43 
44 void __i915_priolist_free(struct i915_priolist *p);
45 static inline void i915_priolist_free(struct i915_priolist *p)
46 {
47 	if (p->priority != I915_PRIORITY_NORMAL)
48 		__i915_priolist_free(p);
49 }
50 
51 void i915_request_show_with_schedule(struct drm_printer *m,
52 				     const struct i915_request *rq,
53 				     const char *prefix,
54 				     int indent);
55 
56 #endif /* _I915_SCHEDULER_H_ */
57