<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div dir="auto">
<div dir="auto"><span style="font-size: 12pt;">On August 6, 2021 15:18:59 Daniel Vetter <daniel.vetter@ffwll.ch> wrote:</span></div><div id="aqm-original" style="color: black;">
<div><br></div>
<blockquote type="cite" class="gmail_quote" style="margin: 0 0 0 0.75ex; border-left: 1px solid #808080; padding-left: 0.75ex;">
<div dir="auto">gem context refcounting is another exercise in least locking design it</div>
<div dir="auto">seems, where most things get destroyed upon context closure (which can</div>
<div dir="auto">race with anything really). Only the actual memory allocation and the</div>
<div dir="auto">locks survive while holding a reference.</div>
<div dir="auto"><br></div>
<div dir="auto">This tripped up Jason when reimplementing the single timeline feature</div>
<div dir="auto">in</div>
<div dir="auto"><br></div>
<div dir="auto">commit 00dae4d3d35d4f526929633b76e00b0ab4d3970d</div>
<div dir="auto">Author: Jason Ekstrand <jason@jlekstrand.net></div>
<div dir="auto">Date: Thu Jul 8 10:48:12 2021 -0500</div>
<div dir="auto"><br></div>
<div dir="auto"> drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4)</div>
<div dir="auto"><br></div>
<div dir="auto">We could fix the bug by holding ctx->mutex, but it's cleaner to just</div><div dir="auto"></div></blockquote></div><div dir="auto"><br></div><div dir="auto">What bug is this fixing, exactly?</div><div dir="auto"><br></div><div dir="auto">--Jason</div><div dir="auto"><br></div><div id="aqm-original" style="color: black;" dir="auto"><blockquote type="cite" class="gmail_quote" style="margin: 0 0 0 0.75ex; border-left: 1px solid #808080; padding-left: 0.75ex;"><div dir="auto"><br></div>
<div dir="auto">make the context object actually invariant over its _entire_ lifetime.</div>
<div dir="auto"><br></div>
<div dir="auto">Signed-off-by: Daniel Vetter <daniel.vetter@intel.com></div>
<div dir="auto">Fixes: 00dae4d3d35d ("drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4)")</div>
<div dir="auto">Cc: Jason Ekstrand <jason@jlekstrand.net></div>
<div dir="auto">Cc: Chris Wilson <chris@chris-wilson.co.uk></div>
<div dir="auto">Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com></div>
<div dir="auto">Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com></div>
<div dir="auto">Cc: Matthew Brost <matthew.brost@intel.com></div>
<div dir="auto">Cc: Matthew Auld <matthew.auld@intel.com></div>
<div dir="auto">Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com></div>
<div dir="auto">Cc: "Thomas Hellström" <thomas.hellstrom@intel.com></div>
<div dir="auto">Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com></div>
<div dir="auto">Cc: Dave Airlie <airlied@redhat.com></div>
<div dir="auto">---</div>
<div dir="auto"> drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 +++---</div>
<div dir="auto"> 1 file changed, 3 insertions(+), 3 deletions(-)</div>
<div dir="auto"><br></div>
<div dir="auto">diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c</div>
<div dir="auto">index 754b9b8d4981..93ba0197d70a 100644</div>
<div dir="auto">--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c</div>
<div dir="auto">+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c</div>
<div dir="auto">@@ -940,6 +940,9 @@ void i915_gem_context_release(struct kref *ref)</div>
<div dir="auto"> trace_i915_context_free(ctx);</div>
<div dir="auto"> GEM_BUG_ON(!i915_gem_context_is_closed(ctx));</div>
<div dir="auto"> </div>
<div dir="auto">+ if (ctx->syncobj)</div>
<div dir="auto">+ drm_syncobj_put(ctx->syncobj);</div>
<div dir="auto">+</div>
<div dir="auto"> mutex_destroy(&ctx->engines_mutex);</div>
<div dir="auto"> mutex_destroy(&ctx->lut_mutex);</div>
<div dir="auto"> </div>
<div dir="auto">@@ -1159,9 +1162,6 @@ static void context_close(struct i915_gem_context *ctx)</div>
<div dir="auto"> if (vm)</div>
<div dir="auto"> i915_vm_close(vm);</div>
<div dir="auto"> </div>
<div dir="auto">- if (ctx->syncobj)</div>
<div dir="auto">- drm_syncobj_put(ctx->syncobj);</div>
<div dir="auto">-</div>
<div dir="auto"> ctx->file_priv = ERR_PTR(-EBADF);</div>
<div dir="auto"> </div>
<div dir="auto"> /*</div>
<div dir="auto">-- </div>
<div dir="auto">2.32.0</div>
</blockquote>
</div><div dir="auto"><br></div>
</div></body>
</html>