Skip to content

Commit

Permalink
drm/i915: Rename priotree to sched
Browse files Browse the repository at this point in the history
Having moved the priotree struct into i915_scheduler.h, identify it as
the scheduling element and rebrand into i915_sched. This becomes more
useful as we start attaching more information we require to propagate
through the scheduler.

v2: Use i915_sched_node for future distinctiveness

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180418184052.7129-2-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Apr 18, 2018
1 parent 98ff5c7 commit 0c7112a
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 82 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/i915_gpu_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ static void record_request(struct i915_request *request,
struct drm_i915_error_request *erq)
{
erq->context = request->ctx->hw_id;
erq->priority = request->priotree.priority;
erq->priority = request->sched.priority;
erq->ban_score = atomic_read(&request->ctx->ban_score);
erq->seqno = request->global_seqno;
erq->jiffies = request->emitted_jiffies;
Expand Down
66 changes: 34 additions & 32 deletions drivers/gpu/drm/i915/i915_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,48 +125,50 @@ i915_dependency_free(struct drm_i915_private *i915,
}

static void
__i915_priotree_add_dependency(struct i915_priotree *pt,
struct i915_priotree *signal,
struct i915_dependency *dep,
unsigned long flags)
__i915_sched_node_add_dependency(struct i915_sched_node *node,
struct i915_sched_node *signal,
struct i915_dependency *dep,
unsigned long flags)
{
INIT_LIST_HEAD(&dep->dfs_link);
list_add(&dep->wait_link, &signal->waiters_list);
list_add(&dep->signal_link, &pt->signalers_list);
list_add(&dep->signal_link, &node->signalers_list);
dep->signaler = signal;
dep->flags = flags;
}

static int
i915_priotree_add_dependency(struct drm_i915_private *i915,
struct i915_priotree *pt,
struct i915_priotree *signal)
i915_sched_node_add_dependency(struct drm_i915_private *i915,
struct i915_sched_node *node,
struct i915_sched_node *signal)
{
struct i915_dependency *dep;

dep = i915_dependency_alloc(i915);
if (!dep)
return -ENOMEM;

__i915_priotree_add_dependency(pt, signal, dep, I915_DEPENDENCY_ALLOC);
__i915_sched_node_add_dependency(node, signal, dep,
I915_DEPENDENCY_ALLOC);
return 0;
}

static void
i915_priotree_fini(struct drm_i915_private *i915, struct i915_priotree *pt)
i915_sched_node_fini(struct drm_i915_private *i915,
struct i915_sched_node *node)
{
struct i915_dependency *dep, *next;
struct i915_dependency *dep, *tmp;

GEM_BUG_ON(!list_empty(&pt->link));
GEM_BUG_ON(!list_empty(&node->link));

/*
* Everyone we depended upon (the fences we wait to be signaled)
* should retire before us and remove themselves from our list.
* However, retirement is run independently on each timeline and
* so we may be called out-of-order.
*/
list_for_each_entry_safe(dep, next, &pt->signalers_list, signal_link) {
GEM_BUG_ON(!i915_priotree_signaled(dep->signaler));
list_for_each_entry_safe(dep, tmp, &node->signalers_list, signal_link) {
GEM_BUG_ON(!i915_sched_node_signaled(dep->signaler));
GEM_BUG_ON(!list_empty(&dep->dfs_link));

list_del(&dep->wait_link);
Expand All @@ -175,8 +177,8 @@ i915_priotree_fini(struct drm_i915_private *i915, struct i915_priotree *pt)
}

/* Remove ourselves from everyone who depends upon us */
list_for_each_entry_safe(dep, next, &pt->waiters_list, wait_link) {
GEM_BUG_ON(dep->signaler != pt);
list_for_each_entry_safe(dep, tmp, &node->waiters_list, wait_link) {
GEM_BUG_ON(dep->signaler != node);
GEM_BUG_ON(!list_empty(&dep->dfs_link));

list_del(&dep->signal_link);
Expand All @@ -186,12 +188,12 @@ i915_priotree_fini(struct drm_i915_private *i915, struct i915_priotree *pt)
}

static void
i915_priotree_init(struct i915_priotree *pt)
i915_sched_node_init(struct i915_sched_node *node)
{
INIT_LIST_HEAD(&pt->signalers_list);
INIT_LIST_HEAD(&pt->waiters_list);
INIT_LIST_HEAD(&pt->link);
pt->priority = I915_PRIORITY_INVALID;
INIT_LIST_HEAD(&node->signalers_list);
INIT_LIST_HEAD(&node->waiters_list);
INIT_LIST_HEAD(&node->link);
node->priority = I915_PRIORITY_INVALID;
}

static int reset_all_global_seqno(struct drm_i915_private *i915, u32 seqno)
Expand Down Expand Up @@ -422,7 +424,7 @@ static void i915_request_retire(struct i915_request *request)
}
spin_unlock_irq(&request->lock);

i915_priotree_fini(request->i915, &request->priotree);
i915_sched_node_fini(request->i915, &request->sched);
i915_request_put(request);
}

Expand Down Expand Up @@ -725,7 +727,7 @@ i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
i915_sw_fence_init(&i915_request_get(rq)->submit, submit_notify);
init_waitqueue_head(&rq->execute);

i915_priotree_init(&rq->priotree);
i915_sched_node_init(&rq->sched);

INIT_LIST_HEAD(&rq->active_list);
rq->i915 = i915;
Expand Down Expand Up @@ -777,8 +779,8 @@ i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)

/* Make sure we didn't add ourselves to external state before freeing */
GEM_BUG_ON(!list_empty(&rq->active_list));
GEM_BUG_ON(!list_empty(&rq->priotree.signalers_list));
GEM_BUG_ON(!list_empty(&rq->priotree.waiters_list));
GEM_BUG_ON(!list_empty(&rq->sched.signalers_list));
GEM_BUG_ON(!list_empty(&rq->sched.waiters_list));

kmem_cache_free(i915->requests, rq);
err_unreserve:
Expand All @@ -800,9 +802,9 @@ i915_request_await_request(struct i915_request *to, struct i915_request *from)
return 0;

if (to->engine->schedule) {
ret = i915_priotree_add_dependency(to->i915,
&to->priotree,
&from->priotree);
ret = i915_sched_node_add_dependency(to->i915,
&to->sched,
&from->sched);
if (ret < 0)
return ret;
}
Expand Down Expand Up @@ -1033,10 +1035,10 @@ void __i915_request_add(struct i915_request *request, bool flush_caches)
i915_sw_fence_await_sw_fence(&request->submit, &prev->submit,
&request->submitq);
if (engine->schedule)
__i915_priotree_add_dependency(&request->priotree,
&prev->priotree,
&request->dep,
0);
__i915_sched_node_add_dependency(&request->sched,
&prev->sched,
&request->dep,
0);
}

spin_lock_irq(&timeline->lock);
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/i915/i915_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct i915_request {
* to retirement), i.e. bidirectional dependency information for the
* request not tied to individual fences.
*/
struct i915_priotree priotree;
struct i915_sched_node sched;
struct i915_dependency dep;

/**
Expand Down Expand Up @@ -306,10 +306,10 @@ static inline bool i915_request_started(const struct i915_request *rq)
seqno - 1);
}

static inline bool i915_priotree_signaled(const struct i915_priotree *pt)
static inline bool i915_sched_node_signaled(const struct i915_sched_node *node)
{
const struct i915_request *rq =
container_of(pt, const struct i915_request, priotree);
container_of(node, const struct i915_request, sched);

return i915_request_completed(rq);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/i915_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ enum {
* is ready, and are able to reorder its portion of the graph to accommodate
* dynamic priority changes.
*/
struct i915_priotree {
struct i915_sched_node {
struct list_head signalers_list; /* those before us, we depend upon */
struct list_head waiters_list; /* those after us, they depend upon us */
struct list_head link;
int priority;
};

struct i915_dependency {
struct i915_priotree *signaler;
struct i915_sched_node *signaler;
struct list_head signal_link;
struct list_head wait_link;
struct list_head dfs_link;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/intel_engine_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ static void print_request(struct drm_printer *m,
rq->global_seqno,
i915_request_completed(rq) ? "!" : "",
rq->fence.context, rq->fence.seqno,
rq->priotree.priority,
rq->sched.priority,
jiffies_to_msecs(jiffies - rq->emitted_jiffies),
name);
}
Expand Down Expand Up @@ -1367,7 +1367,7 @@ void intel_engine_dump(struct intel_engine_cs *engine,
struct i915_priolist *p =
rb_entry(rb, typeof(*p), node);

list_for_each_entry(rq, &p->requests, priotree.link)
list_for_each_entry(rq, &p->requests, sched.link)
print_request(m, rq, "\t\tQ ");
}
spin_unlock_irq(&engine->timeline->lock);
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/drm/i915/intel_guc_submission.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static void port_assign(struct execlist_port *port, struct i915_request *rq)

static inline int rq_prio(const struct i915_request *rq)
{
return rq->priotree.priority;
return rq->sched.priority;
}

static inline int port_prio(const struct execlist_port *port)
Expand Down Expand Up @@ -706,11 +706,11 @@ static void guc_dequeue(struct intel_engine_cs *engine)
struct i915_priolist *p = to_priolist(rb);
struct i915_request *rq, *rn;

list_for_each_entry_safe(rq, rn, &p->requests, priotree.link) {
list_for_each_entry_safe(rq, rn, &p->requests, sched.link) {
if (last && rq->ctx != last->ctx) {
if (port == last_port) {
__list_del_many(&p->requests,
&rq->priotree.link);
&rq->sched.link);
goto done;
}

Expand All @@ -719,7 +719,7 @@ static void guc_dequeue(struct intel_engine_cs *engine)
port++;
}

INIT_LIST_HEAD(&rq->priotree.link);
INIT_LIST_HEAD(&rq->sched.link);

__i915_request_submit(rq);
trace_i915_request_in(rq, port_index(port, execlists));
Expand Down
Loading

0 comments on commit 0c7112a

Please sign in to comment.