Commit a5627721 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Inline engine->init_context into its caller

We only use the init_context vfunc once while recording the default
context state, and we use the same sequence in each backend (eliding
steps that do not apply). Remove the vfunc for simplicity and
de-duplication.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190729113720.24830-1-chris@chris-wilson.co.uk
parent 1032a2af
...@@ -383,7 +383,6 @@ struct intel_engine_cs { ...@@ -383,7 +383,6 @@ struct intel_engine_cs {
const struct intel_context_ops *cops; const struct intel_context_ops *cops;
int (*request_alloc)(struct i915_request *rq); int (*request_alloc)(struct i915_request *rq);
int (*init_context)(struct i915_request *rq);
int (*emit_flush)(struct i915_request *request, u32 mode); int (*emit_flush)(struct i915_request *request, u32 mode);
#define EMIT_INVALIDATE BIT(0) #define EMIT_INVALIDATE BIT(0)
......
...@@ -141,7 +141,6 @@ ...@@ -141,7 +141,6 @@
#include "intel_gt.h" #include "intel_gt.h"
#include "intel_lrc_reg.h" #include "intel_lrc_reg.h"
#include "intel_mocs.h" #include "intel_mocs.h"
#include "intel_renderstate.h"
#include "intel_reset.h" #include "intel_reset.h"
#include "intel_workarounds.h" #include "intel_workarounds.h"
...@@ -2727,25 +2726,6 @@ static u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *request, u32 *cs) ...@@ -2727,25 +2726,6 @@ static u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *request, u32 *cs)
return gen8_emit_wa_tail(request, cs); return gen8_emit_wa_tail(request, cs);
} }
static int gen8_init_rcs_context(struct i915_request *rq)
{
int ret;
ret = intel_engine_emit_ctx_wa(rq);
if (ret)
return ret;
ret = intel_rcs_context_init_mocs(rq);
/*
* Failing to program the MOCS is non-fatal.The system will not
* run at peak performance. So generate an error and carry on.
*/
if (ret)
DRM_ERROR("MOCS failed to program: expect performance issues.\n");
return intel_renderstate_emit(rq);
}
static void execlists_park(struct intel_engine_cs *engine) static void execlists_park(struct intel_engine_cs *engine)
{ {
del_timer_sync(&engine->execlists.timer); del_timer_sync(&engine->execlists.timer);
...@@ -2853,7 +2833,6 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine) ...@@ -2853,7 +2833,6 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine)
logical_ring_default_irqs(engine); logical_ring_default_irqs(engine);
if (engine->class == RENDER_CLASS) { if (engine->class == RENDER_CLASS) {
engine->init_context = gen8_init_rcs_context;
engine->emit_flush = gen8_emit_flush_render; engine->emit_flush = gen8_emit_flush_render;
engine->emit_fini_breadcrumb = gen8_emit_fini_breadcrumb_rcs; engine->emit_fini_breadcrumb = gen8_emit_fini_breadcrumb_rcs;
} }
......
...@@ -568,11 +568,14 @@ void intel_mocs_init_l3cc_table(struct intel_gt *gt) ...@@ -568,11 +568,14 @@ void intel_mocs_init_l3cc_table(struct intel_gt *gt)
* *
* Return: 0 on success, otherwise the error status. * Return: 0 on success, otherwise the error status.
*/ */
int intel_rcs_context_init_mocs(struct i915_request *rq) int intel_mocs_emit(struct i915_request *rq)
{ {
struct drm_i915_mocs_table t; struct drm_i915_mocs_table t;
int ret; int ret;
if (rq->engine->class != RENDER_CLASS)
return 0;
if (get_mocs_settings(rq->engine->gt, &t)) { if (get_mocs_settings(rq->engine->gt, &t)) {
/* Program the RCS control registers */ /* Program the RCS control registers */
ret = emit_mocs_control_table(rq, &t); ret = emit_mocs_control_table(rq, &t);
......
...@@ -54,8 +54,9 @@ struct i915_request; ...@@ -54,8 +54,9 @@ struct i915_request;
struct intel_engine_cs; struct intel_engine_cs;
struct intel_gt; struct intel_gt;
int intel_rcs_context_init_mocs(struct i915_request *rq);
void intel_mocs_init_l3cc_table(struct intel_gt *gt); void intel_mocs_init_l3cc_table(struct intel_gt *gt);
void intel_mocs_init_engine(struct intel_engine_cs *engine); void intel_mocs_init_engine(struct intel_engine_cs *engine);
int intel_mocs_emit(struct i915_request *rq);
#endif #endif
...@@ -41,7 +41,7 @@ struct intel_renderstate { ...@@ -41,7 +41,7 @@ struct intel_renderstate {
static const struct intel_renderstate_rodata * static const struct intel_renderstate_rodata *
render_state_get_rodata(const struct intel_engine_cs *engine) render_state_get_rodata(const struct intel_engine_cs *engine)
{ {
if (engine->id != RCS0) if (engine->class != RENDER_CLASS)
return NULL; return NULL;
switch (INTEL_GEN(engine->i915)) { switch (INTEL_GEN(engine->i915)) {
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "i915_trace.h" #include "i915_trace.h"
#include "intel_context.h" #include "intel_context.h"
#include "intel_gt.h" #include "intel_gt.h"
#include "intel_renderstate.h"
#include "intel_reset.h" #include "intel_reset.h"
#include "intel_workarounds.h" #include "intel_workarounds.h"
...@@ -849,21 +848,6 @@ static void reset_finish(struct intel_engine_cs *engine) ...@@ -849,21 +848,6 @@ static void reset_finish(struct intel_engine_cs *engine)
{ {
} }
static int intel_rcs_ctx_init(struct i915_request *rq)
{
int ret;
ret = intel_engine_emit_ctx_wa(rq);
if (ret != 0)
return ret;
ret = intel_renderstate_emit(rq);
if (ret)
return ret;
return 0;
}
static int rcs_resume(struct intel_engine_cs *engine) static int rcs_resume(struct intel_engine_cs *engine)
{ {
struct drm_i915_private *dev_priv = engine->i915; struct drm_i915_private *dev_priv = engine->i915;
...@@ -2227,11 +2211,9 @@ static void setup_rcs(struct intel_engine_cs *engine) ...@@ -2227,11 +2211,9 @@ static void setup_rcs(struct intel_engine_cs *engine)
engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT; engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT;
if (INTEL_GEN(i915) >= 7) { if (INTEL_GEN(i915) >= 7) {
engine->init_context = intel_rcs_ctx_init;
engine->emit_flush = gen7_render_ring_flush; engine->emit_flush = gen7_render_ring_flush;
engine->emit_fini_breadcrumb = gen7_rcs_emit_breadcrumb; engine->emit_fini_breadcrumb = gen7_rcs_emit_breadcrumb;
} else if (IS_GEN(i915, 6)) { } else if (IS_GEN(i915, 6)) {
engine->init_context = intel_rcs_ctx_init;
engine->emit_flush = gen6_render_ring_flush; engine->emit_flush = gen6_render_ring_flush;
engine->emit_fini_breadcrumb = gen6_rcs_emit_breadcrumb; engine->emit_fini_breadcrumb = gen6_rcs_emit_breadcrumb;
} else if (IS_GEN(i915, 5)) { } else if (IS_GEN(i915, 5)) {
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "gt/intel_gt_pm.h" #include "gt/intel_gt_pm.h"
#include "gt/intel_mocs.h" #include "gt/intel_mocs.h"
#include "gt/intel_reset.h" #include "gt/intel_reset.h"
#include "gt/intel_renderstate.h"
#include "gt/intel_workarounds.h" #include "gt/intel_workarounds.h"
#include "i915_drv.h" #include "i915_drv.h"
...@@ -1294,10 +1295,24 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915) ...@@ -1294,10 +1295,24 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915)
goto err_active; goto err_active;
} }
err = 0; err = intel_engine_emit_ctx_wa(rq);
if (rq->engine->init_context) if (err)
err = rq->engine->init_context(rq); goto err_rq;
/*
* Failing to program the MOCS is non-fatal.The system will not
* run at peak performance. So warn the user and carry on.
*/
err = intel_mocs_emit(rq);
if (err)
dev_notice(i915->drm.dev,
"Failed to program MOCS registers; expect performance issues.\n");
err = intel_renderstate_emit(rq);
if (err)
goto err_rq;
err_rq:
i915_request_add(rq); i915_request_add(rq);
if (err) if (err)
goto err_active; goto err_active;
......
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