[Intel-gfx] [PATCH 2/5] drm/i915: Dump the ringbuffer of the active request for debugging

Chris Wilson chris at chris-wilson.co.uk
Thu Jun 14 09:41:00 UTC 2018


Sometimes we need to see what instructions we emitted for a request to
try and gather a glimmer of insight into what the GPU is doing when it
stops responding.

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

diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
index d278fed8cb31..d7f757fb8401 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -1443,12 +1443,10 @@ void intel_engine_dump(struct intel_engine_cs *engine,
 
 	rq = i915_gem_find_active_request(engine);
 	if (rq) {
+		void *ring;
+		int size;
+
 		print_request(m, rq, "\t\tactive ");
-		drm_printf(m,
-			   "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n",
-			   rq->head, rq->postfix, rq->tail,
-			   rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u,
-			   rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u);
 		drm_printf(m, "\t\tring->start:  0x%08x\n",
 			   i915_ggtt_offset(rq->ring->vma));
 		drm_printf(m, "\t\tring->head:   0x%08x\n",
@@ -1459,6 +1457,33 @@ void intel_engine_dump(struct intel_engine_cs *engine,
 			   rq->ring->emit);
 		drm_printf(m, "\t\tring->space:  0x%08x\n",
 			   rq->ring->space);
+
+		drm_printf(m,
+			   "[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]:\n",
+			   rq->head, rq->postfix, rq->tail,
+			   rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u,
+			   rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u);
+
+		size = rq->tail - rq->head;
+		if (rq->tail < rq->head)
+			size += rq->ring->size;
+
+		ring = kmalloc(size, GFP_ATOMIC);
+		if (ring) {
+			const void *vaddr = rq->ring->vaddr;
+			unsigned int head = rq->head;
+			unsigned int len = 0;
+
+			if (rq->tail < head) {
+				len = rq->ring->size - head;
+				memcpy(ring, vaddr + head, len);
+				head = 0;
+			}
+			memcpy(ring + len, vaddr + head, size - len);
+
+			hexdump(m, ring, size);
+			kfree(ring);
+		}
 	}
 
 	rcu_read_unlock();
-- 
2.17.1



More information about the Intel-gfx mailing list