On Mon, 3 Jun 2019 at 15:00, Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> wrote: > > Use i915_gem_object_lock() to guard the LUT and active reference to > allow us to break free of struct_mutex for handling GEM_CLOSE. > > Testcase: igt/gem_close_race > Testcase: igt/gem_exec_parallel > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > --- > drivers/gpu/drm/i915/gem/i915_gem_context.c | 75 ++++++++++--------- > .../gpu/drm/i915/gem/i915_gem_context_types.h | 12 +-- > .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 25 +++++-- > drivers/gpu/drm/i915/gem/i915_gem_object.c | 38 ++++++---- > .../gpu/drm/i915/gem/i915_gem_object_types.h | 1 - > .../gpu/drm/i915/gem/selftests/mock_context.c | 1 - > drivers/gpu/drm/i915/i915_drv.h | 4 +- > drivers/gpu/drm/i915/i915_gem.c | 1 + > drivers/gpu/drm/i915/i915_gem_gtt.c | 1 + > drivers/gpu/drm/i915/i915_timeline.c | 13 ++-- > drivers/gpu/drm/i915/i915_vma.c | 42 +++++++---- > drivers/gpu/drm/i915/i915_vma.h | 17 ++--- > .../gpu/drm/i915/selftests/mock_gem_device.c | 1 + > 13 files changed, 131 insertions(+), 100 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c > index 08721ef62e4e..fb03a19932cf 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c > @@ -95,24 +95,40 @@ void i915_lut_handle_free(struct i915_lut_handle *lut) > > static void lut_close(struct i915_gem_context *ctx) > { > - struct i915_lut_handle *lut, *ln; > struct radix_tree_iter iter; > void __rcu **slot; > > - list_for_each_entry_safe(lut, ln, &ctx->handles_list, ctx_link) { > - list_del(&lut->obj_link); > - i915_lut_handle_free(lut); > - } > - INIT_LIST_HEAD(&ctx->handles_list); > + lockdep_assert_held(&ctx->mutex); > > rcu_read_lock(); > radix_tree_for_each_slot(slot, &ctx->handles_vma, &iter, 0) { > struct i915_vma *vma = rcu_dereference_raw(*slot); > + struct drm_i915_gem_object *obj = vma->obj; > + struct i915_lut_handle *lut; > + > + rcu_read_unlock(); > + i915_gem_object_lock(obj); > + list_for_each_entry(lut, &obj->lut_list, obj_link) { > + if (lut->ctx != ctx) > + continue; > > - radix_tree_iter_delete(&ctx->handles_vma, &iter, slot); > + if (lut->handle != iter.index) > + continue; > > - vma->open_count--; > - i915_vma_put(vma); > + list_del(&lut->obj_link); > + break; > + } > + i915_gem_object_unlock(obj); > + rcu_read_lock(); > + > + if (&lut->obj_link != &obj->lut_list) { So mean. Fwiw, Reviewed-by: Matthew Auld <matthew.auld@xxxxxxxxx> _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx