Commit 0e124e19 authored by Chris Wilson's avatar Chris Wilson Committed by Rodrigo Vivi

drm/i915/gem: Propagate error from cancelled submit due to context closure

In the course of discovering and closing many races with context closure
and execbuf submission, since commit 61231f6b ("drm/i915/gem: Check
that the context wasn't closed during setup") we started checking that
the context was not closed by another userspace thread during the execbuf
ioctl. In doing so we cancelled the inflight request (by telling it to be
skipped), but kept reporting success since we do submit a request, albeit
one that doesn't execute. As the error is known before we return from the
ioctl, we can report the error we detect immediately, rather than leave
it on the fence status. With the immediate propagation of the error, it
is easier for userspace to handle.

Fixes: 61231f6b ("drm/i915/gem: Check that the context wasn't closed during setup")
Testcase: igt/gem_ctx_exec/basic-close-race
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: <stable@vger.kernel.org> # v5.7+
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201203103432.31526-1-chris@chris-wilson.co.uk
(cherry picked from commit ba38b79e)
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 352ded44
...@@ -3097,7 +3097,7 @@ static void retire_requests(struct intel_timeline *tl, struct i915_request *end) ...@@ -3097,7 +3097,7 @@ static void retire_requests(struct intel_timeline *tl, struct i915_request *end)
break; break;
} }
static void eb_request_add(struct i915_execbuffer *eb) static int eb_request_add(struct i915_execbuffer *eb, int err)
{ {
struct i915_request *rq = eb->request; struct i915_request *rq = eb->request;
struct intel_timeline * const tl = i915_request_timeline(rq); struct intel_timeline * const tl = i915_request_timeline(rq);
...@@ -3118,6 +3118,7 @@ static void eb_request_add(struct i915_execbuffer *eb) ...@@ -3118,6 +3118,7 @@ static void eb_request_add(struct i915_execbuffer *eb)
/* Serialise with context_close via the add_to_timeline */ /* Serialise with context_close via the add_to_timeline */
i915_request_set_error_once(rq, -ENOENT); i915_request_set_error_once(rq, -ENOENT);
__i915_request_skip(rq); __i915_request_skip(rq);
err = -ENOENT; /* override any transient errors */
} }
__i915_request_queue(rq, &attr); __i915_request_queue(rq, &attr);
...@@ -3127,6 +3128,8 @@ static void eb_request_add(struct i915_execbuffer *eb) ...@@ -3127,6 +3128,8 @@ static void eb_request_add(struct i915_execbuffer *eb)
retire_requests(tl, prev); retire_requests(tl, prev);
mutex_unlock(&tl->mutex); mutex_unlock(&tl->mutex);
return err;
} }
static const i915_user_extension_fn execbuf_extensions[] = { static const i915_user_extension_fn execbuf_extensions[] = {
...@@ -3332,7 +3335,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, ...@@ -3332,7 +3335,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
err = eb_submit(&eb, batch); err = eb_submit(&eb, batch);
err_request: err_request:
i915_request_get(eb.request); i915_request_get(eb.request);
eb_request_add(&eb); err = eb_request_add(&eb, err);
if (eb.fences) if (eb.fences)
signal_fence_array(&eb); signal_fence_array(&eb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment