Skip to content

Commit

Permalink
drm/i915: Make own struct for execlist items
Browse files Browse the repository at this point in the history
Engine's execlist related items have been increasing to
a point where a separate struct is warranted. Carve execlist
specific items to a dedicated struct to add clarity.

v2: add kerneldoc and fix whitespace (Joonas, Chris)
v3: csb_mmio changes, rebase
v4: s/\b(el|execlist)\b/execlists/ (Joonas)

Suggested-by: Chris Wilson <[email protected]>
Cc: Chris Wilson <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Signed-off-by: Mika Kuoppala <[email protected]>
Acked-by: Joonas Lahtinen <[email protected]>
Reviewed-by: Michał Winiarski <[email protected]> (v3)
Reviewed-by: Chris Wilson <[email protected]> (v3)
Reviewed-by: Joonas Lahtinen <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
mikuint committed Sep 25, 2017
1 parent d27ffc1 commit b620e87
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 99 deletions.
8 changes: 4 additions & 4 deletions drivers/gpu/drm/i915/i915_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3323,7 +3323,7 @@ static int i915_engine_info(struct seq_file *m, void *unused)
read = GEN8_CSB_READ_PTR(ptr);
write = GEN8_CSB_WRITE_PTR(ptr);
seq_printf(m, "\tExeclist CSB read %d [%d cached], write %d [%d from hws], interrupt posted? %s\n",
read, engine->csb_head,
read, engine->execlists.csb_head,
write,
intel_read_status_page(engine, intel_hws_csb_write_index(engine->i915)),
yesno(test_bit(ENGINE_IRQ_EXECLIST,
Expand All @@ -3345,10 +3345,10 @@ static int i915_engine_info(struct seq_file *m, void *unused)
}

rcu_read_lock();
for (idx = 0; idx < ARRAY_SIZE(engine->execlist_port); idx++) {
for (idx = 0; idx < ARRAY_SIZE(engine->execlists.port); idx++) {
unsigned int count;

rq = port_unpack(&engine->execlist_port[idx],
rq = port_unpack(&engine->execlists.port[idx],
&count);
if (rq) {
seq_printf(m, "\t\tELSP[%d] count=%d, ",
Expand All @@ -3362,7 +3362,7 @@ static int i915_engine_info(struct seq_file *m, void *unused)
rcu_read_unlock();

spin_lock_irq(&engine->timeline->lock);
for (rb = engine->execlist_first; rb; rb = rb_next(rb)){
for (rb = engine->execlists.first; rb; rb = rb_next(rb)) {
struct i915_priolist *p =
rb_entry(rb, typeof(*p), node);

Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2815,8 +2815,8 @@ i915_gem_reset_prepare_engine(struct intel_engine_cs *engine)
* Turning off the engine->irq_tasklet until the reset is over
* prevents the race.
*/
tasklet_kill(&engine->irq_tasklet);
tasklet_disable(&engine->irq_tasklet);
tasklet_kill(&engine->execlists.irq_tasklet);
tasklet_disable(&engine->execlists.irq_tasklet);

if (engine->irq_seqno_barrier)
engine->irq_seqno_barrier(engine);
Expand Down Expand Up @@ -2995,7 +2995,7 @@ void i915_gem_reset(struct drm_i915_private *dev_priv)

void i915_gem_reset_finish_engine(struct intel_engine_cs *engine)
{
tasklet_enable(&engine->irq_tasklet);
tasklet_enable(&engine->execlists.irq_tasklet);
kthread_unpark(engine->breadcrumbs.signaler);
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/i915_gpu_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,10 +1327,10 @@ static void engine_record_requests(struct intel_engine_cs *engine,
static void error_record_engine_execlists(struct intel_engine_cs *engine,
struct drm_i915_error_engine *ee)
{
const struct execlist_port *port = engine->execlist_port;
const struct execlist_port *port = engine->execlists.port;
unsigned int n;

for (n = 0; n < ARRAY_SIZE(engine->execlist_port); n++) {
for (n = 0; n < ARRAY_SIZE(engine->execlists.port); n++) {
struct drm_i915_gem_request *rq = port_request(&port[n]);

if (!rq)
Expand Down
31 changes: 17 additions & 14 deletions drivers/gpu/drm/i915/i915_guc_submission.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,12 @@ static void i915_guc_submit(struct intel_engine_cs *engine)
struct drm_i915_private *dev_priv = engine->i915;
struct intel_guc *guc = &dev_priv->guc;
struct i915_guc_client *client = guc->execbuf_client;
struct execlist_port *port = engine->execlist_port;
unsigned int engine_id = engine->id;
struct intel_engine_execlists * const execlists = &engine->execlists;
struct execlist_port *port = execlists->port;
const unsigned int engine_id = engine->id;
unsigned int n;

for (n = 0; n < ARRAY_SIZE(engine->execlist_port); n++) {
for (n = 0; n < ARRAY_SIZE(execlists->port); n++) {
struct drm_i915_gem_request *rq;
unsigned int count;

Expand Down Expand Up @@ -558,7 +559,8 @@ static void port_assign(struct execlist_port *port,

static void i915_guc_dequeue(struct intel_engine_cs *engine)
{
struct execlist_port *port = engine->execlist_port;
struct intel_engine_execlists * const execlists = &engine->execlists;
struct execlist_port *port = execlists->port;
struct drm_i915_gem_request *last = NULL;
bool submit = false;
struct rb_node *rb;
Expand All @@ -567,15 +569,15 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)
port++;

spin_lock_irq(&engine->timeline->lock);
rb = engine->execlist_first;
GEM_BUG_ON(rb_first(&engine->execlist_queue) != rb);
rb = execlists->first;
GEM_BUG_ON(rb_first(&execlists->queue) != rb);
while (rb) {
struct i915_priolist *p = rb_entry(rb, typeof(*p), node);
struct drm_i915_gem_request *rq, *rn;

list_for_each_entry_safe(rq, rn, &p->requests, priotree.link) {
if (last && rq->ctx != last->ctx) {
if (port != engine->execlist_port) {
if (port != execlists->port) {
__list_del_many(&p->requests,
&rq->priotree.link);
goto done;
Expand All @@ -596,13 +598,13 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)
}

rb = rb_next(rb);
rb_erase(&p->node, &engine->execlist_queue);
rb_erase(&p->node, &execlists->queue);
INIT_LIST_HEAD(&p->requests);
if (p->priority != I915_PRIORITY_NORMAL)
kmem_cache_free(engine->i915->priorities, p);
}
done:
engine->execlist_first = rb;
execlists->first = rb;
if (submit) {
port_assign(port, last);
i915_guc_submit(engine);
Expand All @@ -612,8 +614,8 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)

static void i915_guc_irq_handler(unsigned long data)
{
struct intel_engine_cs *engine = (struct intel_engine_cs *)data;
struct execlist_port *port = engine->execlist_port;
struct intel_engine_cs * const engine = (struct intel_engine_cs *)data;
struct execlist_port *port = engine->execlists.port;
struct drm_i915_gem_request *rq;

rq = port_request(&port[0]);
Expand Down Expand Up @@ -1144,7 +1146,7 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)
* and it is guaranteed that it will remove the work item from the
* queue before our request is completed.
*/
BUILD_BUG_ON(ARRAY_SIZE(engine->execlist_port) *
BUILD_BUG_ON(ARRAY_SIZE(engine->execlists.port) *
sizeof(struct guc_wq_item) *
I915_NUM_ENGINES > GUC_WQ_SIZE);

Expand Down Expand Up @@ -1175,14 +1177,15 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)
guc_interrupts_capture(dev_priv);

for_each_engine(engine, dev_priv, id) {
struct intel_engine_execlists * const execlists = &engine->execlists;
/* The tasklet was initialised by execlists, and may be in
* a state of flux (across a reset) and so we just want to
* take over the callback without changing any other state
* in the tasklet.
*/
engine->irq_tasklet.func = i915_guc_irq_handler;
execlists->irq_tasklet.func = i915_guc_irq_handler;
clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
tasklet_schedule(&engine->irq_tasklet);
tasklet_schedule(&execlists->irq_tasklet);
}

return 0;
Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/i915/i915_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,10 +1346,11 @@ static void snb_gt_irq_handler(struct drm_i915_private *dev_priv,
static void
gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir, int test_shift)
{
struct intel_engine_execlists * const execlists = &engine->execlists;
bool tasklet = false;

if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << test_shift)) {
if (port_count(&engine->execlist_port[0])) {
if (port_count(&execlists->port[0])) {
__set_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
tasklet = true;
}
Expand All @@ -1361,7 +1362,7 @@ gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir, int test_shift)
}

if (tasklet)
tasklet_hi_schedule(&engine->irq_tasklet);
tasklet_hi_schedule(&execlists->irq_tasklet);
}

static irqreturn_t gen8_gt_irq_ack(struct drm_i915_private *dev_priv,
Expand Down
12 changes: 6 additions & 6 deletions drivers/gpu/drm/i915/intel_engine_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ static void intel_engine_init_timeline(struct intel_engine_cs *engine)
*/
void intel_engine_setup_common(struct intel_engine_cs *engine)
{
engine->execlist_queue = RB_ROOT;
engine->execlist_first = NULL;
engine->execlists.queue = RB_ROOT;
engine->execlists.first = NULL;

intel_engine_init_timeline(engine);
intel_engine_init_hangcheck(engine);
Expand Down Expand Up @@ -1475,11 +1475,11 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
return false;

/* Both ports drained, no more ELSP submission? */
if (port_request(&engine->execlist_port[0]))
if (port_request(&engine->execlists.port[0]))
return false;

/* ELSP is empty, but there are ready requests? */
if (READ_ONCE(engine->execlist_first))
if (READ_ONCE(engine->execlists.first))
return false;

/* Ring stopped? */
Expand Down Expand Up @@ -1528,8 +1528,8 @@ void intel_engines_mark_idle(struct drm_i915_private *i915)
for_each_engine(engine, i915, id) {
intel_engine_disarm_breadcrumbs(engine);
i915_gem_batch_pool_fini(&engine->batch_pool);
tasklet_kill(&engine->irq_tasklet);
engine->no_priolist = false;
tasklet_kill(&engine->execlists.irq_tasklet);
engine->execlists.no_priolist = false;
}
}

Expand Down
Loading

0 comments on commit b620e87

Please sign in to comment.