Skip to content

Commit 1f18122

Browse files
committed
drm/i915/execlists: Keep request->priority for its lifetime
With preemption, we will want to "unsubmit" a request, taking it back from the hw and returning it to the priority sorted execution list. In order to know where to insert it into that list, we need to remember its adjust priority (which may change even as it was being executed). This also affects reset for execlists as we are now unsubmitting the requests following the reset (rather than directly writing the ELSP for the inflight contexts). This turns reset into an accidental preemption point, as after the reset we may choose a different pair of contexts to submit to hw. GuC is not updated as this series doesn't add preemption to the GuC submission, and so it can keep benefiting from the early pruning of the DFS inside execlists_schedule() for a little longer. We also need to find a way of reducing the cost of that DFS... v2: Include priority in error-state Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171003203453.15692-6-chris@chris-wilson.co.uk
1 parent 3ad7b52 commit 1f18122

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ struct i915_gpu_state {
982982
pid_t pid;
983983
u32 handle;
984984
u32 hw_id;
985+
int priority;
985986
int ban_score;
986987
int active;
987988
int guilty;
@@ -1004,6 +1005,7 @@ struct i915_gpu_state {
10041005
long jiffies;
10051006
pid_t pid;
10061007
u32 context;
1008+
int priority;
10071009
int ban_score;
10081010
u32 seqno;
10091011
u32 head;

drivers/gpu/drm/i915/i915_gpu_error.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ static void error_print_request(struct drm_i915_error_state_buf *m,
377377
if (!erq->seqno)
378378
return;
379379

380-
err_printf(m, "%s pid %d, ban score %d, seqno %8x:%08x, emitted %dms ago, head %08x, tail %08x\n",
380+
err_printf(m, "%s pid %d, ban score %d, seqno %8x:%08x, prio %d, emitted %dms ago, head %08x, tail %08x\n",
381381
prefix, erq->pid, erq->ban_score,
382-
erq->context, erq->seqno,
382+
erq->context, erq->seqno, erq->priority,
383383
jiffies_to_msecs(jiffies - erq->jiffies),
384384
erq->head, erq->tail);
385385
}
@@ -388,9 +388,9 @@ static void error_print_context(struct drm_i915_error_state_buf *m,
388388
const char *header,
389389
const struct drm_i915_error_context *ctx)
390390
{
391-
err_printf(m, "%s%s[%d] user_handle %d hw_id %d, ban score %d guilty %d active %d\n",
391+
err_printf(m, "%s%s[%d] user_handle %d hw_id %d, prio %d, ban score %d guilty %d active %d\n",
392392
header, ctx->comm, ctx->pid, ctx->handle, ctx->hw_id,
393-
ctx->ban_score, ctx->guilty, ctx->active);
393+
ctx->priority, ctx->ban_score, ctx->guilty, ctx->active);
394394
}
395395

396396
static void error_print_engine(struct drm_i915_error_state_buf *m,
@@ -1271,6 +1271,7 @@ static void record_request(struct drm_i915_gem_request *request,
12711271
struct drm_i915_error_request *erq)
12721272
{
12731273
erq->context = request->ctx->hw_id;
1274+
erq->priority = request->priotree.priority;
12741275
erq->ban_score = atomic_read(&request->ctx->ban_score);
12751276
erq->seqno = request->global_seqno;
12761277
erq->jiffies = request->emitted_jiffies;
@@ -1364,6 +1365,7 @@ static void record_context(struct drm_i915_error_context *e,
13641365

13651366
e->handle = ctx->user_handle;
13661367
e->hw_id = ctx->hw_id;
1368+
e->priority = ctx->priority;
13671369
e->ban_score = atomic_read(&ctx->ban_score);
13681370
e->guilty = atomic_read(&ctx->guilty_count);
13691371
e->active = atomic_read(&ctx->active_count);

drivers/gpu/drm/i915/intel_lrc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
584584
}
585585

586586
INIT_LIST_HEAD(&rq->priotree.link);
587-
rq->priotree.priority = INT_MAX;
588-
589587
__i915_gem_request_submit(rq);
590588
trace_i915_gem_request_in(rq, port_index(port, execlists));
591589
last = rq;
@@ -793,6 +791,7 @@ static void intel_lrc_irq_handler(unsigned long data)
793791
execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
794792

795793
trace_i915_gem_request_out(rq);
794+
rq->priotree.priority = INT_MAX;
796795
i915_gem_request_put(rq);
797796

798797
execlists_port_complete(execlists, port);
@@ -845,11 +844,15 @@ static void execlists_submit_request(struct drm_i915_gem_request *request)
845844
spin_unlock_irqrestore(&engine->timeline->lock, flags);
846845
}
847846

847+
static struct drm_i915_gem_request *pt_to_request(struct i915_priotree *pt)
848+
{
849+
return container_of(pt, struct drm_i915_gem_request, priotree);
850+
}
851+
848852
static struct intel_engine_cs *
849853
pt_lock_engine(struct i915_priotree *pt, struct intel_engine_cs *locked)
850854
{
851-
struct intel_engine_cs *engine =
852-
container_of(pt, struct drm_i915_gem_request, priotree)->engine;
855+
struct intel_engine_cs *engine = pt_to_request(pt)->engine;
853856

854857
GEM_BUG_ON(!locked);
855858

@@ -905,6 +908,9 @@ static void execlists_schedule(struct drm_i915_gem_request *request, int prio)
905908
* engines.
906909
*/
907910
list_for_each_entry(p, &pt->signalers_list, signal_link) {
911+
if (i915_gem_request_completed(pt_to_request(p->signaler)))
912+
continue;
913+
908914
GEM_BUG_ON(p->signaler->priority < pt->priority);
909915
if (prio > READ_ONCE(p->signaler->priority))
910916
list_move_tail(&p->dfs_link, &dfs);

0 commit comments

Comments
 (0)