There is no other state pertaining to the completed requests in the
hang, other than gleamed through the ringbuffer, so including the
expired requests in the list of outstanding requests simply adds noise.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 105 +++++++++++++++++++---------------
 1 file changed, 58 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index 52d1564f37c4..5d8fd0beda2e 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1034,12 +1034,65 @@ static void error_record_engine_registers(struct 
drm_i915_error_state *error,
        }
 }
 
+static void engine_record_requests(struct intel_engine_cs *engine,
+                                  struct drm_i915_gem_request *first,
+                                  struct drm_i915_error_engine *ee)
+{
+       struct drm_i915_gem_request *request;
+       int count;
+
+       count = 0;
+       request = first;
+       list_for_each_entry_from(request, &engine->request_list, link)
+               count++;
+
+       ee->requests = NULL;
+       kcalloc(count, sizeof(*ee->requests),
+               GFP_ATOMIC);
+       if (ee->requests == NULL)
+               return;
+       ee->num_requests = count;
+
+       count = 0;
+       request = first;
+       list_for_each_entry_from(request, &engine->request_list, link) {
+               struct drm_i915_error_request *erq;
+
+               if (count >= ee->num_requests) {
+                       /*
+                        * If the ring request list was changed in
+                        * between the point where the error request
+                        * list was created and dimensioned and this
+                        * point then just exit early to avoid crashes.
+                        *
+                        * We don't need to communicate that the
+                        * request list changed state during error
+                        * state capture and that the error state is
+                        * slightly incorrect as a consequence since we
+                        * are typically only interested in the request
+                        * list state at the point of error state
+                        * capture, not in any changes happening during
+                        * the capture.
+                        */
+                       break;
+               }
+
+               erq = &ee->requests[count++];
+               erq->seqno = request->fence.seqno;
+               erq->jiffies = request->emitted_jiffies;
+               erq->tail = request->tail;
+
+               rcu_read_lock();
+               erq->pid = request->ctx ? pid_nr(request->ctx->pid) : 0;
+               rcu_read_unlock();
+       }
+}
+
 static void i915_gem_record_rings(struct drm_i915_private *dev_priv,
                                  struct drm_i915_error_state *error)
 {
        struct i915_ggtt *ggtt = &dev_priv->ggtt;
-       struct drm_i915_gem_request *request;
-       int i, count;
+       int i;
 
        error->semaphore =
                i915_error_object_create(dev_priv, dev_priv->semaphore);
@@ -1047,6 +1100,7 @@ static void i915_gem_record_rings(struct drm_i915_private 
*dev_priv,
        for (i = 0; i < I915_NUM_ENGINES; i++) {
                struct intel_engine_cs *engine = &dev_priv->engine[i];
                struct drm_i915_error_engine *ee = &error->engine[i];
+               struct drm_i915_gem_request *request;
 
                ee->pid = -1;
                ee->engine_id = -1;
@@ -1105,6 +1159,8 @@ static void i915_gem_record_rings(struct drm_i915_private 
*dev_priv,
                        ee->cpu_ring_tail = ring->tail;
                        ee->ringbuffer =
                                i915_error_object_create(dev_priv, ring->vma);
+
+                       engine_record_requests(engine, request, ee);
                }
 
                ee->hws_page =
@@ -1113,51 +1169,6 @@ static void i915_gem_record_rings(struct 
drm_i915_private *dev_priv,
 
                ee->wa_ctx =
                        i915_error_object_create(dev_priv, engine->wa_ctx.vma);
-
-               count = 0;
-               list_for_each_entry(request, &engine->request_list, link)
-                       count++;
-
-               ee->num_requests = count;
-               ee->requests =
-                       kcalloc(count, sizeof(*ee->requests), GFP_ATOMIC);
-               if (!ee->requests) {
-                       ee->num_requests = 0;
-                       continue;
-               }
-
-               count = 0;
-               list_for_each_entry(request, &engine->request_list, link) {
-                       struct drm_i915_error_request *erq;
-
-                       if (count >= ee->num_requests) {
-                               /*
-                                * If the ring request list was changed in
-                                * between the point where the error request
-                                * list was created and dimensioned and this
-                                * point then just exit early to avoid crashes.
-                                *
-                                * We don't need to communicate that the
-                                * request list changed state during error
-                                * state capture and that the error state is
-                                * slightly incorrect as a consequence since we
-                                * are typically only interested in the request
-                                * list state at the point of error state
-                                * capture, not in any changes happening during
-                                * the capture.
-                                */
-                               break;
-                       }
-
-                       erq = &ee->requests[count++];
-                       erq->seqno = request->fence.seqno;
-                       erq->jiffies = request->emitted_jiffies;
-                       erq->tail = request->postfix;
-
-                       rcu_read_lock();
-                       erq->pid = request->ctx ? pid_nr(request->ctx->pid) : 0;
-                       rcu_read_unlock();
-               }
        }
 }
 
-- 
2.8.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to