Skip to content

Commit f9eb63b

Browse files
committed
drm/i915/selftests: Avoid drm_gem_handle_create under struct_mutex
Despite us reloading the module around every selftest, the lockclasses persist and the chains used in selftesting may then dictate how we are allowed to nest locks during runtime testing. As such we have to be just as careful, and in particular it turns out we are not allowed to nest dev->object_name_lock (drm_gem_handle_create) inside dev->struct_mutex. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103830 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171121110652.1107-1-chris@chris-wilson.co.uk Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
1 parent cff109f commit f9eb63b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

drivers/gpu/drm/i915/selftests/i915_gem_context.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,23 @@ static int cpu_check(struct drm_i915_gem_object *obj, unsigned int max)
264264
return err;
265265
}
266266

267+
static int file_add_object(struct drm_file *file,
268+
struct drm_i915_gem_object *obj)
269+
{
270+
int err;
271+
272+
GEM_BUG_ON(obj->base.handle_count);
273+
274+
/* tie the object to the drm_file for easy reaping */
275+
err = idr_alloc(&file->object_idr, &obj->base, 1, 0, GFP_KERNEL);
276+
if (err < 0)
277+
return err;
278+
279+
i915_gem_object_get(obj);
280+
obj->base.handle_count++;
281+
return 0;
282+
}
283+
267284
static struct drm_i915_gem_object *
268285
create_test_object(struct i915_gem_context *ctx,
269286
struct drm_file *file,
@@ -273,7 +290,6 @@ create_test_object(struct i915_gem_context *ctx,
273290
struct i915_address_space *vm =
274291
ctx->ppgtt ? &ctx->ppgtt->base : &ctx->i915->ggtt.base;
275292
u64 size;
276-
u32 handle;
277293
int err;
278294

279295
size = min(vm->total / 2, 1024ull * DW_PER_PAGE * PAGE_SIZE);
@@ -283,8 +299,7 @@ create_test_object(struct i915_gem_context *ctx,
283299
if (IS_ERR(obj))
284300
return obj;
285301

286-
/* tie the handle to the drm_file for easy reaping */
287-
err = drm_gem_handle_create(file, &obj->base, &handle);
302+
err = file_add_object(file, obj);
288303
i915_gem_object_put(obj);
289304
if (err)
290305
return ERR_PTR(err);

0 commit comments

Comments
 (0)