drm/i915/selftests: Create mock_engine() under struct_mutex

Calling mock_engine() calls i915_timeline_init() and that requires
struct_mutex to be held as it adds itself to the global list of
timelines. This error was introduced by commit a89d1f921c ("drm/i915:
Split i915_gem_timeline into individual timelines") but the issue was
masked in CI by the earlier lockdep spam.

Fixes: a89d1f921c ("drm/i915: Split i915_gem_timeline into individual timelines")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Michel Thierry <michel.thierry@intel.com>
Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180508211056.17151-1-chris@chris-wilson.co.uk
This commit is contained in:
Chris Wilson 2018-05-08 22:10:56 +01:00
parent 0adb90d330
commit 1d7a99f514

View File

@ -229,18 +229,20 @@ struct drm_i915_private *mock_gem_device(void)
INIT_LIST_HEAD(&i915->gt.closed_vma); INIT_LIST_HEAD(&i915->gt.closed_vma);
mutex_lock(&i915->drm.struct_mutex); mutex_lock(&i915->drm.struct_mutex);
mock_init_ggtt(i915); mock_init_ggtt(i915);
mutex_unlock(&i915->drm.struct_mutex);
mkwrite_device_info(i915)->ring_mask = BIT(0); mkwrite_device_info(i915)->ring_mask = BIT(0);
i915->engine[RCS] = mock_engine(i915, "mock", RCS); i915->engine[RCS] = mock_engine(i915, "mock", RCS);
if (!i915->engine[RCS]) if (!i915->engine[RCS])
goto err_priorities; 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_engine;
mutex_unlock(&i915->drm.struct_mutex);
WARN_ON(i915_gemfs_init(i915)); WARN_ON(i915_gemfs_init(i915));
return i915; return i915;
@ -248,7 +250,8 @@ struct drm_i915_private *mock_gem_device(void)
err_engine: err_engine:
for_each_engine(engine, i915, id) for_each_engine(engine, i915, id)
mock_engine_free(engine); mock_engine_free(engine);
err_priorities: err_unlock:
mutex_unlock(&i915->drm.struct_mutex);
kmem_cache_destroy(i915->priorities); kmem_cache_destroy(i915->priorities);
err_dependencies: err_dependencies:
kmem_cache_destroy(i915->dependencies); kmem_cache_destroy(i915->dependencies);