Skip to content

Commit

Permalink
drm/i915/gt: Use the kernel_context to measure the breadcrumb size
Browse files Browse the repository at this point in the history
We set up a dummy ring in order to measure the size we require for our
breadcrumb emission, so that we don't have to manually count dwords! We
can pass in the kernel_context to use for this so that if required it is
known for the breadcrumb emitter, and we can reuse some details from the
kernel_context to reduce the number of temporaries we have to mock.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200207125827.2787472-1-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Feb 7, 2020
1 parent 71b7cc6 commit fb5970d
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions drivers/gpu/drm/i915/gt/intel_engine_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,13 @@ static int engine_setup_common(struct intel_engine_cs *engine)

struct measure_breadcrumb {
struct i915_request rq;
struct intel_timeline timeline;
struct intel_ring ring;
u32 cs[1024];
};

static int measure_breadcrumb_dw(struct intel_engine_cs *engine)
static int measure_breadcrumb_dw(struct intel_context *ce)
{
struct intel_engine_cs *engine = ce->engine;
struct measure_breadcrumb *frame;
int dw = -ENOMEM;

Expand All @@ -647,39 +647,27 @@ static int measure_breadcrumb_dw(struct intel_engine_cs *engine)
if (!frame)
return -ENOMEM;

if (intel_timeline_init(&frame->timeline,
engine->gt,
engine->status_page.vma))
goto out_frame;

mutex_lock(&frame->timeline.mutex);
frame->rq.i915 = engine->i915;
frame->rq.engine = engine;
frame->rq.context = ce;
rcu_assign_pointer(frame->rq.timeline, ce->timeline);

frame->ring.vaddr = frame->cs;
frame->ring.size = sizeof(frame->cs);
frame->ring.effective_size = frame->ring.size;
intel_ring_update_space(&frame->ring);

frame->rq.i915 = engine->i915;
frame->rq.engine = engine;
frame->rq.ring = &frame->ring;
rcu_assign_pointer(frame->rq.timeline, &frame->timeline);

dw = intel_timeline_pin(&frame->timeline);
if (dw < 0)
goto out_timeline;

mutex_lock(&ce->timeline->mutex);
spin_lock_irq(&engine->active.lock);

dw = engine->emit_fini_breadcrumb(&frame->rq, frame->cs) - frame->cs;

spin_unlock_irq(&engine->active.lock);
mutex_unlock(&ce->timeline->mutex);

GEM_BUG_ON(dw & 1); /* RING_TAIL must be qword aligned */

intel_timeline_unpin(&frame->timeline);

out_timeline:
mutex_unlock(&frame->timeline.mutex);
intel_timeline_fini(&frame->timeline);
out_frame:
kfree(frame);
return dw;
}
Expand Down Expand Up @@ -754,12 +742,6 @@ static int engine_init_common(struct intel_engine_cs *engine)

engine->set_default_submission(engine);

ret = measure_breadcrumb_dw(engine);
if (ret < 0)
return ret;

engine->emit_fini_breadcrumb_dw = ret;

/*
* We may need to do things with the shrinker which
* require us to immediately switch back to the default
Expand All @@ -772,9 +754,18 @@ static int engine_init_common(struct intel_engine_cs *engine)
if (IS_ERR(ce))
return PTR_ERR(ce);

ret = measure_breadcrumb_dw(ce);
if (ret < 0)
goto err_context;

engine->emit_fini_breadcrumb_dw = ret;
engine->kernel_context = ce;

return 0;

err_context:
intel_context_put(ce);
return ret;
}

int intel_engines_init(struct intel_gt *gt)
Expand Down

0 comments on commit fb5970d

Please sign in to comment.