Skip to content

Commit

Permalink
drm/i915: Replace engine->timeline with a plain list
Browse files Browse the repository at this point in the history
To continue the onslaught of removing the assumption of a global
execution ordering, another casualty is the engine->timeline. Without an
actual timeline to track, it is overkill and we can replace it with a
much less grand plain list. We still need a list of requests inflight,
for the simple purpose of finding inflight requests (for retiring,
resetting, preemption etc).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190614164606.15633-3-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Jun 14, 2019
1 parent 9db0c5c commit 422d7df
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 188 deletions.
6 changes: 6 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,10 @@ static inline bool inject_preempt_hang(struct intel_engine_execlists *execlists)

#endif

void intel_engine_init_active(struct intel_engine_cs *engine,
unsigned int subclass);
#define ENGINE_PHYSICAL 0
#define ENGINE_MOCK 1
#define ENGINE_VIRTUAL 2

#endif /* _INTEL_RINGBUFFER_H_ */
62 changes: 31 additions & 31 deletions drivers/gpu/drm/i915/gt/intel_engine_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,7 @@ static int intel_engine_setup_common(struct intel_engine_cs *engine)
if (err)
return err;

err = i915_timeline_init(engine->i915,
&engine->timeline,
engine->status_page.vma);
if (err)
goto err_hwsp;

i915_timeline_set_subclass(&engine->timeline, TIMELINE_ENGINE);

intel_engine_init_active(engine, ENGINE_PHYSICAL);
intel_engine_init_breadcrumbs(engine);
intel_engine_init_execlists(engine);
intel_engine_init_hangcheck(engine);
Expand All @@ -637,10 +630,6 @@ static int intel_engine_setup_common(struct intel_engine_cs *engine)
intel_sseu_from_device_info(&RUNTIME_INFO(engine->i915)->sseu);

return 0;

err_hwsp:
cleanup_status_page(engine);
return err;
}

/**
Expand Down Expand Up @@ -797,6 +786,27 @@ static int pin_context(struct i915_gem_context *ctx,
return 0;
}

void
intel_engine_init_active(struct intel_engine_cs *engine, unsigned int subclass)
{
INIT_LIST_HEAD(&engine->active.requests);

spin_lock_init(&engine->active.lock);
lockdep_set_subclass(&engine->active.lock, subclass);

/*
* Due to an interesting quirk in lockdep's internal debug tracking,
* after setting a subclass we must ensure the lock is used. Otherwise,
* nr_unused_locks is incremented once too often.
*/
#ifdef CONFIG_DEBUG_LOCK_ALLOC
local_irq_disable();
lock_map_acquire(&engine->active.lock.dep_map);
lock_map_release(&engine->active.lock.dep_map);
local_irq_enable();
#endif
}

/**
* intel_engines_init_common - initialize cengine state which might require hw access
* @engine: Engine to initialize.
Expand Down Expand Up @@ -860,6 +870,8 @@ int intel_engine_init_common(struct intel_engine_cs *engine)
*/
void intel_engine_cleanup_common(struct intel_engine_cs *engine)
{
GEM_BUG_ON(!list_empty(&engine->active.requests));

cleanup_status_page(engine);

intel_engine_fini_breadcrumbs(engine);
Expand All @@ -874,8 +886,6 @@ void intel_engine_cleanup_common(struct intel_engine_cs *engine)
intel_context_unpin(engine->kernel_context);
GEM_BUG_ON(!llist_empty(&engine->barrier_tasks));

i915_timeline_fini(&engine->timeline);

intel_wa_list_free(&engine->ctx_wa_list);
intel_wa_list_free(&engine->wa_list);
intel_wa_list_free(&engine->whitelist);
Expand Down Expand Up @@ -1482,16 +1492,6 @@ void intel_engine_dump(struct intel_engine_cs *engine,

drm_printf(m, "\tRequests:\n");

rq = list_first_entry(&engine->timeline.requests,
struct i915_request, link);
if (&rq->link != &engine->timeline.requests)
print_request(m, rq, "\t\tfirst ");

rq = list_last_entry(&engine->timeline.requests,
struct i915_request, link);
if (&rq->link != &engine->timeline.requests)
print_request(m, rq, "\t\tlast ");

rq = intel_engine_find_active_request(engine);
if (rq) {
print_request(m, rq, "\t\tactive ");
Expand Down Expand Up @@ -1572,7 +1572,7 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine)
if (!intel_engine_supports_stats(engine))
return -ENODEV;

spin_lock_irqsave(&engine->timeline.lock, flags);
spin_lock_irqsave(&engine->active.lock, flags);
write_seqlock(&engine->stats.lock);

if (unlikely(engine->stats.enabled == ~0)) {
Expand All @@ -1598,7 +1598,7 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine)

unlock:
write_sequnlock(&engine->stats.lock);
spin_unlock_irqrestore(&engine->timeline.lock, flags);
spin_unlock_irqrestore(&engine->active.lock, flags);

return err;
}
Expand Down Expand Up @@ -1683,22 +1683,22 @@ intel_engine_find_active_request(struct intel_engine_cs *engine)
* At all other times, we must assume the GPU is still running, but
* we only care about the snapshot of this moment.
*/
spin_lock_irqsave(&engine->timeline.lock, flags);
list_for_each_entry(request, &engine->timeline.requests, link) {
spin_lock_irqsave(&engine->active.lock, flags);
list_for_each_entry(request, &engine->active.requests, sched.link) {
if (i915_request_completed(request))
continue;

if (!i915_request_started(request))
break;
continue;

/* More than one preemptible request may match! */
if (!match_ring(request))
break;
continue;

active = request;
break;
}
spin_unlock_irqrestore(&engine->timeline.lock, flags);
spin_unlock_irqrestore(&engine->active.lock, flags);

return active;
}
Expand Down
6 changes: 5 additions & 1 deletion drivers/gpu/drm/i915/gt/intel_engine_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ struct intel_engine_cs {

struct intel_ring *buffer;

struct i915_timeline timeline;
struct {
spinlock_t lock;
struct list_head requests;
} active;

struct llist_head barrier_tasks;

struct intel_context *kernel_context; /* pinned */
Expand Down
Loading

0 comments on commit 422d7df

Please sign in to comment.