[Intel-gfx] [RFC 04/10] drm/i915: Use explicit flag to mark unreachable intel_context
Chris Wilson
chris at chris-wilson.co.uk
Fri Mar 13 11:03:19 UTC 2020
Quoting Tvrtko Ursulin (2020-03-11 18:26:12)
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>
> I need to keep the GEM context around a bit longer so adding an explicit
> flag for syncing execbuf with closed/abandonded contexts.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_context.c | 3 ++-
> drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 +-
> drivers/gpu/drm/i915/gt/intel_context_types.h | 1 +
> 3 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 0f4150c8d7fe..c49cfec6d616 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -568,7 +568,8 @@ static void engines_idle_release(struct i915_gem_context *ctx,
> int err = 0;
>
> /* serialises with execbuf */
> - RCU_INIT_POINTER(ce->gem_context, NULL);
> + WRITE_ONCE(ce->closed, true);
> +
> if (!intel_context_pin_if_active(ce))
> continue;
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index 0893ce781a84..17dbe03f8e2e 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -2547,7 +2547,7 @@ static void eb_request_add(struct i915_execbuffer *eb)
> prev = __i915_request_commit(rq);
>
> /* Check that the context wasn't destroyed before submission */
> - if (likely(rcu_access_pointer(eb->context->gem_context))) {
> + if (likely(!READ_ONCE(eb->context->closed))) {
> attr = eb->gem_context->sched;
>
> /*
> diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h b/drivers/gpu/drm/i915/gt/intel_context_types.h
> index 0f3b68b95c56..bcefebcf6b88 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context_types.h
> +++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
> @@ -50,6 +50,7 @@ struct intel_context {
>
> struct i915_address_space *vm;
> struct i915_gem_context __rcu *gem_context;
> + bool closed;
But we do have intel_context.flags, right?
-Chris
More information about the Intel-gfx
mailing list