[PATCH 061/131] drm/i915: Skip holding context reference for constructing the request

Chris Wilson chris at chris-wilson.co.uk
Sat Aug 6 07:36:28 UTC 2016


As we pin the context and acquire a reference on it for the duration of
the pin, we can forgo taking an extra reference for the construction
itself as that is guarded by the caller. Once the request is submitted,
the context will remain referenced whilst it is active (legacy keeps a
reference until the request after we finish using the context, execlists
keeps it pinned until the request after). So it is safe to assume that
we hold a reference whilst inspecting an active request - i.e. during
GPU error capture.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_request.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 6f5a895dd77f..8f98a7e34212 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -191,7 +191,6 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
 					       request->engine);
 	}
 
-	i915_gem_context_put(request->ctx);
 	i915_gem_request_put(request);
 }
 
@@ -374,7 +373,7 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
 	INIT_LIST_HEAD(&req->active_list);
 	req->i915 = dev_priv;
 	req->engine = engine;
-	req->ctx = i915_gem_context_get(ctx);
+	req->ctx = ctx;
 
 	/* No zalloc, must clear what we need by hand */
 	req->signaling.wait.tsk = NULL;
@@ -397,7 +396,7 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
 	else
 		ret = intel_ring_alloc_request_extras(req);
 	if (ret)
-		goto err_ctx;
+		goto err;
 
 	/* Record the position of the start of the request so that
 	 * should we detect the updated seqno part-way through the
@@ -408,8 +407,6 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
 
 	return req;
 
-err_ctx:
-	i915_gem_context_put(ctx);
 err:
 	kmem_cache_free(dev_priv->requests, req);
 	return ERR_PTR(ret);
-- 
2.8.1



More information about the Intel-gfx-trybot mailing list