Commit 4a774ee3 authored by Chris Wilson's avatar Chris Wilson

drm/i915/selftests: Pin the mock kernel context

The driver assumes that the kernel context is pinned and always
available for use from any process or atomic context. Make it so for
selftesting as well!
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180523142346.27953-1-chris@chris-wilson.co.uk
parent f0d2b758
...@@ -212,8 +212,13 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915, ...@@ -212,8 +212,13 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915,
if (!engine->base.buffer) if (!engine->base.buffer)
goto err_breadcrumbs; goto err_breadcrumbs;
if (IS_ERR(intel_context_pin(i915->kernel_context, &engine->base)))
goto err_ring;
return &engine->base; return &engine->base;
err_ring:
mock_ring_free(engine->base.buffer);
err_breadcrumbs: err_breadcrumbs:
intel_engine_fini_breadcrumbs(&engine->base); intel_engine_fini_breadcrumbs(&engine->base);
i915_timeline_fini(&engine->base.timeline); i915_timeline_fini(&engine->base.timeline);
...@@ -254,6 +259,8 @@ void mock_engine_free(struct intel_engine_cs *engine) ...@@ -254,6 +259,8 @@ void mock_engine_free(struct intel_engine_cs *engine)
if (ce) if (ce)
intel_context_unpin(ce); intel_context_unpin(ce);
__intel_context_unpin(engine->i915->kernel_context, engine);
mock_ring_free(engine->buffer); mock_ring_free(engine->buffer);
intel_engine_fini_breadcrumbs(engine); intel_engine_fini_breadcrumbs(engine);
......
...@@ -136,8 +136,6 @@ static struct dev_pm_domain pm_domain = { ...@@ -136,8 +136,6 @@ static struct dev_pm_domain pm_domain = {
struct drm_i915_private *mock_gem_device(void) struct drm_i915_private *mock_gem_device(void)
{ {
struct drm_i915_private *i915; struct drm_i915_private *i915;
struct intel_engine_cs *engine;
enum intel_engine_id id;
struct pci_dev *pdev; struct pci_dev *pdev;
int err; int err;
...@@ -233,13 +231,13 @@ struct drm_i915_private *mock_gem_device(void) ...@@ -233,13 +231,13 @@ struct drm_i915_private *mock_gem_device(void)
mock_init_ggtt(i915); mock_init_ggtt(i915);
mkwrite_device_info(i915)->ring_mask = BIT(0); mkwrite_device_info(i915)->ring_mask = BIT(0);
i915->engine[RCS] = mock_engine(i915, "mock", RCS);
if (!i915->engine[RCS])
goto err_unlock;
i915->kernel_context = mock_context(i915, NULL); i915->kernel_context = mock_context(i915, NULL);
if (!i915->kernel_context) if (!i915->kernel_context)
goto err_engine; goto err_unlock;
i915->engine[RCS] = mock_engine(i915, "mock", RCS);
if (!i915->engine[RCS])
goto err_context;
mutex_unlock(&i915->drm.struct_mutex); mutex_unlock(&i915->drm.struct_mutex);
...@@ -247,9 +245,8 @@ struct drm_i915_private *mock_gem_device(void) ...@@ -247,9 +245,8 @@ struct drm_i915_private *mock_gem_device(void)
return i915; return i915;
err_engine: err_context:
for_each_engine(engine, i915, id) i915_gem_contexts_fini(i915);
mock_engine_free(engine);
err_unlock: err_unlock:
mutex_unlock(&i915->drm.struct_mutex); mutex_unlock(&i915->drm.struct_mutex);
kmem_cache_destroy(i915->priorities); kmem_cache_destroy(i915->priorities);
......
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