[Intel-gfx] [PATCH 52/70] drm/i915: Cache the execlist ctx descriptor
Chris Wilson
chris at chris-wilson.co.uk
Tue Apr 7 08:21:16 PDT 2015
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/intel_lrc.c | 56 +++++++++++++++++----------------
drivers/gpu/drm/i915/intel_ringbuffer.h | 3 +-
2 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 459a27a2b486..3fe63bf604b4 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -230,37 +230,13 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists
return 0;
}
-static uint32_t execlists_ctx_descriptor(struct intel_engine_cs *engine,
- uint32_t ggtt_offset)
-{
- uint32_t desc;
-
- desc = GEN8_CTX_VALID;
- desc |= LEGACY_CONTEXT << GEN8_CTX_MODE_SHIFT;
- desc |= GEN8_CTX_L3LLC_COHERENT;
- desc |= GEN8_CTX_PRIVILEGE;
- desc |= ggtt_offset;
-
- /* TODO: WaDisableLiteRestore when we start using semaphore
- * signalling between Command Streamers */
- /* desc |= GEN8_CTX_FORCE_RESTORE; */
-
- /* WaEnableForceRestoreInCtxtDescForVCS:skl */
- if (IS_GEN9(engine->dev) && INTEL_REVID(engine->dev) <= SKL_REVID_B0 &&
- (engine->id == BCS || engine->id == VCS ||
- engine->id == VECS || engine->id == VCS2))
- desc |= GEN8_CTX_FORCE_RESTORE;
-
- return desc;
-}
-
static uint32_t execlists_request_write_tail(struct intel_engine_cs *engine,
struct drm_i915_gem_request *rq)
{
struct intel_ringbuffer *ring = rq->ctx->engine[engine->id].ringbuf;
ring->regs[CTX_RING_TAIL+1] = rq->tail;
- return execlists_ctx_descriptor(engine, ring->ggtt_offset);
+ return ring->descriptor;
}
static void execlists_submit_pair(struct intel_engine_cs *ring)
@@ -498,6 +474,7 @@ static int intel_lr_context_pin(struct intel_engine_cs *ring,
{
struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;
struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
+ u32 ggtt_offset;
int ret;
WARN_ON(!mutex_is_locked(&ring->dev->struct_mutex));
@@ -508,11 +485,12 @@ static int intel_lr_context_pin(struct intel_engine_cs *ring,
if (ret)
goto reset_pin_count;
- ringbuf->ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj);
- if (WARN_ON(ringbuf->ggtt_offset & 0xFFFFFFFF00000FFFULL)) {
+ ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj);
+ if (WARN_ON(ggtt_offset & 0xFFFFFFFF00000FFFULL)) {
ret = -ENODEV;
goto unpin_ctx_obj;
}
+ ringbuf->descriptor = ggtt_offset | ring->execlist_ctx_descriptor;
ret = intel_pin_and_map_ringbuffer_obj(ring->dev, ringbuf);
if (ret)
@@ -1222,6 +1200,28 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)
}
}
+static uint32_t base_ctx_descriptor(struct intel_engine_cs *engine)
+{
+ uint32_t desc;
+
+ desc = GEN8_CTX_VALID;
+ desc |= LEGACY_CONTEXT << GEN8_CTX_MODE_SHIFT;
+ desc |= GEN8_CTX_L3LLC_COHERENT;
+ desc |= GEN8_CTX_PRIVILEGE;
+
+ /* TODO: WaDisableLiteRestore when we start using semaphore
+ * signalling between Command Streamers */
+ /* desc |= GEN8_CTX_FORCE_RESTORE; */
+
+ /* WaEnableForceRestoreInCtxtDescForVCS:skl */
+ if (IS_GEN9(engine->dev) && INTEL_REVID(engine->dev) <= SKL_REVID_B0 &&
+ (engine->id == BCS || engine->id == VCS ||
+ engine->id == VECS || engine->id == VCS2))
+ desc |= GEN8_CTX_FORCE_RESTORE;
+
+ return desc;
+}
+
static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *ring)
{
int ret;
@@ -1243,6 +1243,8 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin
if (ret)
return ret;
+ ring->execlist_ctx_descriptor = base_ctx_descriptor(ring);
+
ret = intel_lr_context_deferred_create(ring->default_context, ring);
return ret;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 55c91014bfdf..97832b6369a6 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -98,7 +98,7 @@ struct intel_ringbuffer {
struct drm_i915_gem_object *obj;
void __iomem *virtual_start;
uint32_t *regs;
- uint32_t ggtt_offset;
+ uint32_t descriptor;
struct intel_engine_cs *ring;
@@ -243,6 +243,7 @@ struct intel_engine_cs {
struct drm_i915_gem_request *execlist_port[2];
struct list_head execlist_queue;
struct list_head execlist_completed;
+ u32 execlist_ctx_descriptor;
u8 next_context_status_buffer;
u32 irq_keep_mask; /* bitmask for interrupts that should not be masked */
int (*emit_request)(struct intel_ringbuffer *ringbuf,
--
2.1.4
More information about the Intel-gfx
mailing list