Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / i915_scheduler.h
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, idx) \
19         for (idx = 0; idx < ARRAY_SIZE((plist)->requests); idx++) \
20                 list_for_each_entry(it, &(plist)->requests[idx], sched.link)
21
22 #define priolist_for_each_request_consume(it, n, plist, idx) \
23         for (; \
24              (plist)->used ? (idx = __ffs((plist)->used)), 1 : 0; \
25              (plist)->used &= ~BIT(idx)) \
26                 list_for_each_entry_safe(it, n, \
27                                          &(plist)->requests[idx], \
28                                          sched.link)
29
30 void i915_sched_node_init(struct i915_sched_node *node);
31 void i915_sched_node_reinit(struct i915_sched_node *node);
32
33 bool __i915_sched_node_add_dependency(struct i915_sched_node *node,
34                                       struct i915_sched_node *signal,
35                                       struct i915_dependency *dep,
36                                       unsigned long flags);
37
38 int i915_sched_node_add_dependency(struct i915_sched_node *node,
39                                    struct i915_sched_node *signal,
40                                    unsigned long flags);
41
42 void i915_sched_node_fini(struct i915_sched_node *node);
43
44 void i915_schedule(struct i915_request *request,
45                    const struct i915_sched_attr *attr);
46
47 void i915_schedule_bump_priority(struct i915_request *rq, unsigned int bump);
48
49 struct list_head *
50 i915_sched_lookup_priolist(struct intel_engine_cs *engine, int prio);
51
52 void __i915_priolist_free(struct i915_priolist *p);
53 static inline void i915_priolist_free(struct i915_priolist *p)
54 {
55         if (p->priority != I915_PRIORITY_NORMAL)
56                 __i915_priolist_free(p);
57 }
58
59 void i915_request_show_with_schedule(struct drm_printer *m,
60                                      const struct i915_request *rq,
61                                      const char *prefix,
62                                      int indent);
63
64 #endif /* _I915_SCHEDULER_H_ */