When using RCU lookup for the request, commit 0eafec6d3244 ("drm/i915:
Enable lockless lookup of request tracking via RCU"), we acknowledge that
we may race with another thread that could have reallocated the request.
In order for the first thread not to blow up, the second thread must not
clear the request completed before overwriting it. In the RCU lookup, we
allow for the engine/seqno to be replaced but we do not allow for it to
be zeroed.

Fixes: 0eafec6d3244 ("drm/i915: Enable lockless lookup of request...")
Signed-off-by: Chris Wilson <[email protected]>
Cc: "Goel, Akash" <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_request.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_request.c 
b/drivers/gpu/drm/i915/i915_gem_request.c
index b317a672040f..7529b6b5deda 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -355,7 +355,7 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
        if (req && i915_gem_request_completed(req))
                i915_gem_request_retire(req);
 
-       req = kmem_cache_zalloc(dev_priv->requests, GFP_KERNEL);
+       req = kmem_cache_alloc(dev_priv->requests, GFP_KERNEL);
        if (!req)
                return ERR_PTR(-ENOMEM);
 
@@ -375,6 +375,10 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
        req->engine = engine;
        req->ctx = i915_gem_context_get(ctx);
 
+       req->signaling.wait.tsk = NULL;
+       req->previous_context = NULL;
+       req->file_priv = NULL;
+
        /*
         * Reserve space in the ring buffer for all the commands required to
         * eventually emit this request. This is to guarantee that the
-- 
2.8.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to