[PATCH 03/22] drm/i915/gem: Check that the context wasn't closed during setup

Chris Wilson chris at chris-wilson.co.uk
Sun Mar 1 14:48:13 UTC 2020


As setup takes a long time, the user may close the context during the
construction of the execbuf. In order to make sure we correctly track
all outstanding work with non-persistent contexts, we need to serialise
the submission with the context closure and mop up any leaks.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index ac0e5fc5675e..b2a3653b9d5d 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -2775,9 +2775,18 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 
 	trace_i915_request_queue(eb.request, eb.batch_flags);
 	err = eb_submit(&eb);
+
+	/* Check that the context wasn't destroyed before submission */
+	if (!rcu_access_pointer(eb.context->gem_context)) {
+		err = -ENOENT; /* serious error, supercede any earlier ones */
+		goto err_request;
+	}
+
 err_request:
 	add_to_client(eb.request, file);
 	i915_request_get(eb.request);
+	if (err)
+		i915_request_skip(eb.request, err);
 	i915_request_add(eb.request);
 
 	if (fences)
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list