diff mbox

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

Message ID 20180614094103.18025-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson June 14, 2018, 9:41 a.m. UTC
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@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_engine_cs.c | 35 ++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 5 deletions(-)

Comments

Joonas Lahtinen June 14, 2018, 12:10 p.m. UTC | #1
Quoting Chris Wilson (2018-06-14 12:41:00)
> 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@chris-wilson.co.uk>

A ring-buffer dumper utility func might make it more readable by quick
glance.

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
diff mbox

Patch

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();