drm/i915/gt: Report context-is-closed prior to pinning

Our assertion caught that we do try to pin a closed context if userspace
is viciously racing context-closure with execbuf, so make it fail
gracefully.

Closes: https://gitlab.freedesktop.org/drm/intel/issues/1492
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200320130159.3922-1-chris@chris-wilson.co.uk
This commit is contained in:
Chris Wilson 2020-03-20 13:01:56 +00:00
parent cb1824bb1e
commit b412c63f1c
1 changed files with 5 additions and 2 deletions

View File

@ -97,8 +97,6 @@ int __intel_context_do_pin(struct intel_context *ce)
{ {
int err; int err;
GEM_BUG_ON(intel_context_is_closed(ce));
if (unlikely(!test_bit(CONTEXT_ALLOC_BIT, &ce->flags))) { if (unlikely(!test_bit(CONTEXT_ALLOC_BIT, &ce->flags))) {
err = intel_context_alloc_state(ce); err = intel_context_alloc_state(ce);
if (err) if (err)
@ -114,6 +112,11 @@ int __intel_context_do_pin(struct intel_context *ce)
goto out_release; goto out_release;
} }
if (unlikely(intel_context_is_closed(ce))) {
err = -ENOENT;
goto out_release;
}
if (likely(!atomic_add_unless(&ce->pin_count, 1, 0))) { if (likely(!atomic_add_unless(&ce->pin_count, 1, 0))) {
err = intel_context_active_acquire(ce); err = intel_context_active_acquire(ce);
if (unlikely(err)) if (unlikely(err))