Skip to content

Commit

Permalink
drm/i915: execlist request keeps ptr/ref to gem_request
Browse files Browse the repository at this point in the history
Add a reference and pointer from the execlist queue item to the associated
gem request. For execlist requests that don't have a request, create one
as a placeholder.

Issue: VIZ-4274
v1: Rebase after upstream of "Replace seqno values with request structures" patchset.

Signed-off-by: Nick Hoath <nicholas.hoath@intel.com>
Reviewed-by: Thomas Daniel <thomas.daniel@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
  • Loading branch information
Nick Hoath authored and Daniel Vetter committed Jan 27, 2015
1 parent 16f3f65 commit 2d12955
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
31 changes: 25 additions & 6 deletions drivers/gpu/drm/i915/intel_lrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring)

static int execlists_context_queue(struct intel_engine_cs *ring,
struct intel_context *to,
u32 tail)
u32 tail,
struct drm_i915_gem_request *request)
{
struct intel_ctx_submit_request *req = NULL, *cursor;
struct drm_i915_private *dev_priv = ring->dev->dev_private;
Expand All @@ -553,6 +554,21 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
req->ring = ring;
req->tail = tail;

if (!request) {
/*
* If there isn't a request associated with this submission,
* create one as a temporary holder.
*/
WARN(1, "execlist context submission without request");
request = kzalloc(sizeof(*request), GFP_KERNEL);
if (request == NULL)
return -ENOMEM;
request->ctx = to;
request->ring = ring;
}
req->request = request;
i915_gem_request_reference(request);

intel_runtime_pm_get(dev_priv);

spin_lock_irqsave(&ring->execlist_lock, flags);
Expand Down Expand Up @@ -766,6 +782,7 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring)
intel_lr_context_unpin(ring, ctx);
intel_runtime_pm_put(dev_priv);
i915_gem_context_unreference(req->ctx);
i915_gem_request_unreference(req->request);
list_del(&req->execlist_link);
kfree(req);
}
Expand Down Expand Up @@ -818,7 +835,8 @@ int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf)
* on a queue waiting for the ELSP to be ready to accept a new context submission. At that
* point, the tail *inside* the context is updated and the ELSP written to.
*/
void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf)
void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf,
struct drm_i915_gem_request *request)
{
struct intel_engine_cs *ring = ringbuf->ring;
struct intel_context *ctx = ringbuf->FIXME_lrc_ctx;
Expand All @@ -828,7 +846,7 @@ void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf)
if (intel_ring_stopped(ring))
return;

execlists_context_queue(ring, ctx, ringbuf->tail);
execlists_context_queue(ring, ctx, ringbuf->tail, request);
}

static int intel_lr_context_pin(struct intel_engine_cs *ring,
Expand Down Expand Up @@ -972,7 +990,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
return ret;

/* Force the context submission in case we have been skipping it */
intel_logical_ring_advance_and_submit(ringbuf);
intel_logical_ring_advance_and_submit(ringbuf, NULL);

/* With GEM the hangcheck timer should kick us out of the loop,
* leaving it early runs the risk of corrupting GEM state (due
Expand Down Expand Up @@ -1311,7 +1329,8 @@ static void gen8_set_seqno(struct intel_engine_cs *ring, u32 seqno)
intel_write_status_page(ring, I915_GEM_HWS_INDEX, seqno);
}

static int gen8_emit_request(struct intel_ringbuffer *ringbuf)
static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
struct drm_i915_gem_request *request)
{
struct intel_engine_cs *ring = ringbuf->ring;
u32 cmd;
Expand All @@ -1333,7 +1352,7 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf)
i915_gem_request_get_seqno(ring->outstanding_lazy_request));
intel_logical_ring_emit(ringbuf, MI_USER_INTERRUPT);
intel_logical_ring_emit(ringbuf, MI_NOOP);
intel_logical_ring_advance_and_submit(ringbuf);
intel_logical_ring_advance_and_submit(ringbuf, request);

return 0;
}
Expand Down
6 changes: 5 additions & 1 deletion drivers/gpu/drm/i915/intel_lrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
int intel_logical_rings_init(struct drm_device *dev);

int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf);
void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf);
void intel_logical_ring_advance_and_submit(
struct intel_ringbuffer *ringbuf,
struct drm_i915_gem_request *request);
/**
* intel_logical_ring_advance() - advance the ringbuffer tail
* @ringbuf: Ringbuffer to advance.
Expand Down Expand Up @@ -110,6 +112,8 @@ struct intel_ctx_submit_request {
struct list_head execlist_link;

int elsp_submitted;

struct drm_i915_gem_request *request;
};

void intel_lrc_irq_handler(struct intel_engine_cs *ring);
Expand Down

0 comments on commit 2d12955

Please sign in to comment.