i915_scheduler.h (2878B)
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 16struct 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 24void i915_sched_node_init(struct i915_sched_node *node); 25void i915_sched_node_reinit(struct i915_sched_node *node); 26 27bool __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 32int i915_sched_node_add_dependency(struct i915_sched_node *node, 33 struct i915_sched_node *signal, 34 unsigned long flags); 35 36void i915_sched_node_fini(struct i915_sched_node *node); 37 38void i915_schedule(struct i915_request *request, 39 const struct i915_sched_attr *attr); 40 41struct list_head * 42i915_sched_lookup_priolist(struct i915_sched_engine *sched_engine, int prio); 43 44void __i915_priolist_free(struct i915_priolist *p); 45static inline void i915_priolist_free(struct i915_priolist *p) 46{ 47 if (p->priority != I915_PRIORITY_NORMAL) 48 __i915_priolist_free(p); 49} 50 51struct i915_sched_engine * 52i915_sched_engine_create(unsigned int subclass); 53 54static inline struct i915_sched_engine * 55i915_sched_engine_get(struct i915_sched_engine *sched_engine) 56{ 57 kref_get(&sched_engine->ref); 58 return sched_engine; 59} 60 61static inline void 62i915_sched_engine_put(struct i915_sched_engine *sched_engine) 63{ 64 kref_put(&sched_engine->ref, sched_engine->destroy); 65} 66 67static inline bool 68i915_sched_engine_is_empty(struct i915_sched_engine *sched_engine) 69{ 70 return RB_EMPTY_ROOT(&sched_engine->queue.rb_root); 71} 72 73static inline void 74i915_sched_engine_reset_on_empty(struct i915_sched_engine *sched_engine) 75{ 76 if (i915_sched_engine_is_empty(sched_engine)) 77 sched_engine->no_priolist = false; 78} 79 80static inline void 81i915_sched_engine_active_lock_bh(struct i915_sched_engine *sched_engine) 82{ 83 local_bh_disable(); /* prevent local softirq and lock recursion */ 84 tasklet_lock(&sched_engine->tasklet); 85} 86 87static inline void 88i915_sched_engine_active_unlock_bh(struct i915_sched_engine *sched_engine) 89{ 90 tasklet_unlock(&sched_engine->tasklet); 91 local_bh_enable(); /* restore softirq, and kick ksoftirqd! */ 92} 93 94void i915_request_show_with_schedule(struct drm_printer *m, 95 const struct i915_request *rq, 96 const char *prefix, 97 int indent); 98 99static inline bool 100i915_sched_engine_disabled(struct i915_sched_engine *sched_engine) 101{ 102 return sched_engine->disabled(sched_engine); 103} 104 105void i915_scheduler_module_exit(void); 106int i915_scheduler_module_init(void); 107 108#endif /* _I915_SCHEDULER_H_ */