drm/i915: Pull out some more common engine init code
Created two common helpers for engine setup and engine init phases respectively to help with code sharing. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1468422221-12132-1-git-send-email-tvrtko.ursulin@linux.intel.com Reviewed-by: Chris Wilson <chris-wilson.co.uk>
This commit is contained in:
Родитель
88d2ba2e95
Коммит
019bf27763
|
@ -160,3 +160,50 @@ cleanup:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void intel_engine_init_hangcheck(struct intel_engine_cs *engine)
|
||||
{
|
||||
memset(&engine->hangcheck, 0, sizeof(engine->hangcheck));
|
||||
}
|
||||
|
||||
/**
|
||||
* intel_engines_setup_common - setup engine state not requiring hw access
|
||||
* @engine: Engine to setup.
|
||||
*
|
||||
* Initializes @engine@ structure members shared between legacy and execlists
|
||||
* submission modes which do not require hardware access.
|
||||
*
|
||||
* Typically done early in the submission mode specific engine setup stage.
|
||||
*/
|
||||
void intel_engine_setup_common(struct intel_engine_cs *engine)
|
||||
{
|
||||
INIT_LIST_HEAD(&engine->active_list);
|
||||
INIT_LIST_HEAD(&engine->request_list);
|
||||
INIT_LIST_HEAD(&engine->buffers);
|
||||
INIT_LIST_HEAD(&engine->execlist_queue);
|
||||
spin_lock_init(&engine->execlist_lock);
|
||||
|
||||
intel_engine_init_hangcheck(engine);
|
||||
i915_gem_batch_pool_init(&engine->i915->drm, &engine->batch_pool);
|
||||
}
|
||||
|
||||
/**
|
||||
* intel_engines_init_common - initialize cengine state which might require hw access
|
||||
* @engine: Engine to initialize.
|
||||
*
|
||||
* Initializes @engine@ structure members shared between legacy and execlists
|
||||
* submission modes which do require hardware access.
|
||||
*
|
||||
* Typcally done at later stages of submission mode specific engine setup.
|
||||
*
|
||||
* Returns zero on success or an error code on failure.
|
||||
*/
|
||||
int intel_engine_init_common(struct intel_engine_cs *engine)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = intel_engine_init_breadcrumbs(engine);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return i915_cmd_parser_init_ring(engine);
|
||||
}
|
||||
|
|
|
@ -2009,6 +2009,8 @@ logical_ring_setup(struct intel_engine_cs *engine)
|
|||
struct drm_i915_private *dev_priv = engine->i915;
|
||||
enum forcewake_domains fw_domains;
|
||||
|
||||
intel_engine_setup_common(engine);
|
||||
|
||||
/* Intentionally left blank. */
|
||||
engine->buffer = NULL;
|
||||
|
||||
|
@ -2026,21 +2028,12 @@ logical_ring_setup(struct intel_engine_cs *engine)
|
|||
|
||||
engine->fw_domains = fw_domains;
|
||||
|
||||
INIT_LIST_HEAD(&engine->active_list);
|
||||
INIT_LIST_HEAD(&engine->request_list);
|
||||
INIT_LIST_HEAD(&engine->buffers);
|
||||
INIT_LIST_HEAD(&engine->execlist_queue);
|
||||
spin_lock_init(&engine->execlist_lock);
|
||||
|
||||
tasklet_init(&engine->irq_tasklet,
|
||||
intel_lrc_irq_handler, (unsigned long)engine);
|
||||
|
||||
logical_ring_init_platform_invariants(engine);
|
||||
logical_ring_default_vfuncs(engine);
|
||||
logical_ring_default_irqs(engine);
|
||||
|
||||
intel_engine_init_hangcheck(engine);
|
||||
i915_gem_batch_pool_init(&dev_priv->drm, &engine->batch_pool);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2049,11 +2042,7 @@ logical_ring_init(struct intel_engine_cs *engine)
|
|||
struct i915_gem_context *dctx = engine->i915->kernel_context;
|
||||
int ret;
|
||||
|
||||
ret = intel_engine_init_breadcrumbs(engine);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
ret = i915_cmd_parser_init_ring(engine);
|
||||
ret = intel_engine_init_common(engine);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -549,11 +549,6 @@ static bool stop_ring(struct intel_engine_cs *engine)
|
|||
return (I915_READ_HEAD(engine) & HEAD_ADDR) == 0;
|
||||
}
|
||||
|
||||
void intel_engine_init_hangcheck(struct intel_engine_cs *engine)
|
||||
{
|
||||
memset(&engine->hangcheck, 0, sizeof(engine->hangcheck));
|
||||
}
|
||||
|
||||
static int init_ring_common(struct intel_engine_cs *engine)
|
||||
{
|
||||
struct drm_i915_private *dev_priv = engine->i915;
|
||||
|
@ -2176,15 +2171,12 @@ static int intel_init_ring_buffer(struct intel_engine_cs *engine)
|
|||
|
||||
WARN_ON(engine->buffer);
|
||||
|
||||
INIT_LIST_HEAD(&engine->active_list);
|
||||
INIT_LIST_HEAD(&engine->request_list);
|
||||
INIT_LIST_HEAD(&engine->execlist_queue);
|
||||
INIT_LIST_HEAD(&engine->buffers);
|
||||
i915_gem_batch_pool_init(&dev_priv->drm, &engine->batch_pool);
|
||||
intel_engine_setup_common(engine);
|
||||
|
||||
memset(engine->semaphore.sync_seqno, 0,
|
||||
sizeof(engine->semaphore.sync_seqno));
|
||||
|
||||
ret = intel_engine_init_breadcrumbs(engine);
|
||||
ret = intel_engine_init_common(engine);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
|
@ -2225,10 +2217,6 @@ static int intel_init_ring_buffer(struct intel_engine_cs *engine)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ret = i915_cmd_parser_init_ring(engine);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
|
|
@ -480,6 +480,9 @@ int intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req);
|
|||
int intel_init_pipe_control(struct intel_engine_cs *engine, int size);
|
||||
void intel_fini_pipe_control(struct intel_engine_cs *engine);
|
||||
|
||||
void intel_engine_setup_common(struct intel_engine_cs *engine);
|
||||
int intel_engine_init_common(struct intel_engine_cs *engine);
|
||||
|
||||
int intel_init_render_ring_buffer(struct intel_engine_cs *engine);
|
||||
int intel_init_bsd_ring_buffer(struct intel_engine_cs *engine);
|
||||
int intel_init_bsd2_ring_buffer(struct intel_engine_cs *engine);
|
||||
|
|
Загрузка…
Ссылка в новой задаче