Commit cdb736fa authored by Mika Kuoppala's avatar Mika Kuoppala Committed by Chris Wilson

drm/i915: Use engine relative LRIs on context setup

Daniele pointed out that relative mmio works differently in
on context restore. Instead of adding the engine mmio base to offset,
it masks out the base and adds bits [12:2] to current engine base.

This should allow us to construct context register state to be
applicable to all instances, including virtual. And avoid the trouble
of updating the registers on virtual instances when submitting work.

v2: only enable for gen12 for now (Mika)
v3: make enabling readable (Chris)

Bspec: 20206
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Suggested-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190906134957.25909-1-mika.kuoppala@linux.intel.com
parent 71cd86cf
...@@ -481,6 +481,7 @@ struct intel_engine_cs { ...@@ -481,6 +481,7 @@ struct intel_engine_cs {
#define I915_ENGINE_HAS_SEMAPHORES BIT(3) #define I915_ENGINE_HAS_SEMAPHORES BIT(3)
#define I915_ENGINE_NEEDS_BREADCRUMB_TASKLET BIT(4) #define I915_ENGINE_NEEDS_BREADCRUMB_TASKLET BIT(4)
#define I915_ENGINE_IS_VIRTUAL BIT(5) #define I915_ENGINE_IS_VIRTUAL BIT(5)
#define I915_ENGINE_HAS_RELATIVE_MMIO BIT(6)
unsigned int flags; unsigned int flags;
/* /*
...@@ -576,6 +577,12 @@ intel_engine_is_virtual(const struct intel_engine_cs *engine) ...@@ -576,6 +577,12 @@ intel_engine_is_virtual(const struct intel_engine_cs *engine)
return engine->flags & I915_ENGINE_IS_VIRTUAL; return engine->flags & I915_ENGINE_IS_VIRTUAL;
} }
static inline bool
intel_engine_has_relative_mmio(const struct intel_engine_cs * const engine)
{
return engine->flags & I915_ENGINE_HAS_RELATIVE_MMIO;
}
#define instdone_has_slice(dev_priv___, sseu___, slice___) \ #define instdone_has_slice(dev_priv___, sseu___, slice___) \
((IS_GEN(dev_priv___, 7) ? 1 : ((sseu___)->slice_mask)) & BIT(slice___)) ((IS_GEN(dev_priv___, 7) ? 1 : ((sseu___)->slice_mask)) & BIT(slice___))
......
...@@ -132,6 +132,8 @@ ...@@ -132,6 +132,8 @@
* address/value pairs. Don't overdue it, though, x <= 2^4 must hold! * address/value pairs. Don't overdue it, though, x <= 2^4 must hold!
*/ */
#define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*(x)-1) #define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*(x)-1)
/* Gen11+. addr = base + (ctx_restore ? offset & GENMASK(12,2) : offset) */
#define MI_LRI_CS_MMIO (1<<19)
#define MI_LRI_FORCE_POSTED (1<<12) #define MI_LRI_FORCE_POSTED (1<<12)
#define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1) #define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1)
#define MI_STORE_REGISTER_MEM_GEN8 MI_INSTR(0x24, 2) #define MI_STORE_REGISTER_MEM_GEN8 MI_INSTR(0x24, 2)
......
...@@ -1214,7 +1214,10 @@ static void execlists_dequeue(struct intel_engine_cs *engine) ...@@ -1214,7 +1214,10 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
unsigned int n; unsigned int n;
GEM_BUG_ON(READ_ONCE(ve->context.inflight)); GEM_BUG_ON(READ_ONCE(ve->context.inflight));
virtual_update_register_offsets(regs, engine);
if (!intel_engine_has_relative_mmio(engine))
virtual_update_register_offsets(regs,
engine);
if (!list_empty(&ve->context.signals)) if (!list_empty(&ve->context.signals))
virtual_xfer_breadcrumbs(ve, engine); virtual_xfer_breadcrumbs(ve, engine);
...@@ -2939,6 +2942,9 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine) ...@@ -2939,6 +2942,9 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
if (HAS_LOGICAL_RING_PREEMPTION(engine->i915)) if (HAS_LOGICAL_RING_PREEMPTION(engine->i915))
engine->flags |= I915_ENGINE_HAS_PREEMPTION; engine->flags |= I915_ENGINE_HAS_PREEMPTION;
} }
if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 12)
engine->flags |= I915_ENGINE_HAS_RELATIVE_MMIO;
} }
static void execlists_destroy(struct intel_engine_cs *engine) static void execlists_destroy(struct intel_engine_cs *engine)
...@@ -3130,8 +3136,10 @@ static void execlists_init_reg_state(u32 *regs, ...@@ -3130,8 +3136,10 @@ static void execlists_init_reg_state(u32 *regs,
struct intel_ring *ring) struct intel_ring *ring)
{ {
struct i915_ppgtt *ppgtt = vm_alias(ce->vm); struct i915_ppgtt *ppgtt = vm_alias(ce->vm);
bool rcs = engine->class == RENDER_CLASS; const bool rcs = engine->class == RENDER_CLASS;
u32 base = engine->mmio_base; const u32 base = engine->mmio_base;
const u32 lri_base =
intel_engine_has_relative_mmio(engine) ? MI_LRI_CS_MMIO : 0;
/* /*
* A context is actually a big batch buffer with several * A context is actually a big batch buffer with several
...@@ -3143,8 +3151,10 @@ static void execlists_init_reg_state(u32 *regs, ...@@ -3143,8 +3151,10 @@ static void execlists_init_reg_state(u32 *regs,
* *
* Must keep consistent with virtual_update_register_offsets(). * Must keep consistent with virtual_update_register_offsets().
*/ */
regs[CTX_LRI_HEADER_0] = MI_LOAD_REGISTER_IMM(rcs ? 14 : 11) | regs[CTX_LRI_HEADER_0] =
MI_LRI_FORCE_POSTED; MI_LOAD_REGISTER_IMM(rcs ? 14 : 11) |
MI_LRI_FORCE_POSTED |
lri_base;
CTX_REG(regs, CTX_CONTEXT_CONTROL, RING_CONTEXT_CONTROL(base), CTX_REG(regs, CTX_CONTEXT_CONTROL, RING_CONTEXT_CONTROL(base),
_MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT) | _MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT) |
...@@ -3191,7 +3201,10 @@ static void execlists_init_reg_state(u32 *regs, ...@@ -3191,7 +3201,10 @@ static void execlists_init_reg_state(u32 *regs,
} }
} }
regs[CTX_LRI_HEADER_1] = MI_LOAD_REGISTER_IMM(9) | MI_LRI_FORCE_POSTED; regs[CTX_LRI_HEADER_1] =
MI_LOAD_REGISTER_IMM(9) |
MI_LRI_FORCE_POSTED |
lri_base;
CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0); CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0);
/* PDP values well be assigned later if needed */ /* PDP values well be assigned later if needed */
...@@ -3218,7 +3231,7 @@ static void execlists_init_reg_state(u32 *regs, ...@@ -3218,7 +3231,7 @@ static void execlists_init_reg_state(u32 *regs,
} }
if (rcs) { if (rcs) {
regs[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1); regs[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1) | lri_base;
CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0); CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0);
} }
...@@ -3411,6 +3424,7 @@ static void virtual_engine_initial_hint(struct virtual_engine *ve) ...@@ -3411,6 +3424,7 @@ static void virtual_engine_initial_hint(struct virtual_engine *ve)
return; return;
swap(ve->siblings[swp], ve->siblings[0]); swap(ve->siblings[swp], ve->siblings[0]);
if (!intel_engine_has_relative_mmio(ve->siblings[0]))
virtual_update_register_offsets(ve->context.lrc_reg_state, virtual_update_register_offsets(ve->context.lrc_reg_state,
ve->siblings[0]); ve->siblings[0]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment