Skip to contentSkip to conversation

intel_error_decode: Whitespacing fix

PATCH In review Ben Widawsky 2 participants 14 messages Apr 22, 2013 – Apr 23, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 intel_error_decode: Whitespacing fix

The rest of igt has moved to kernel coding style. People had already been not conforming with the existing formatting in error decode, so we may as well fix it.

This addresses two primary issues, tabbing (remove spaces), and space after function in function call. I may have missed some of the latter since that was done by hand.

I have upcoming work in this file, and it was annoying me.

v2: Fix case alignment (Chris)

---
 tools/intel_error_decode.c | 585 +++++++++++++++++++++++----------------------
 1 file changed, 293 insertions(+), 292 deletions(-)
tools/intel_error_decode.c +293 -292
index 56bb984..f554d57 100644
@@ -1,4 +1,3 @@
-/* -*- c-basic-offset: 4 -*- */
 /*
  * Copyright © 2007 Intel Corporation
  * Copyright © 2009 Intel Corporation
@@ -57,30 +56,30 @@
 #include "instdone.h"
 
 static void
-print_instdone (uint32_t devid, unsigned int instdone, unsigned int instdone1)
+print_instdone(uint32_t devid, unsigned int instdone, unsigned int instdone1)
 {
-    int i;
-    static int once;
+	int i;
+	static int once;
 
-    if (!once) {
-	init_instdone_definitions(devid);
-	once = 1;
-    }
+	if (!once) {
+		init_instdone_definitions(devid);
+		once = 1;
+	}
 
-    for (i = 0; i < num_instdone_bits; i++) {
-	int busy = 0;
+	for (i = 0; i < num_instdone_bits; i++) {
+		int busy = 0;
 
-	if (instdone_bits[i].reg == INST_DONE_1) {
-	    if (!(instdone1 & instdone_bits[i].bit))
-		busy = 1;
-	} else {
-	    if (!(instdone & instdone_bits[i].bit))
-		busy = 1;
-	}
+		if (instdone_bits[i].reg == INST_DONE_1) {
+			if (!(instdone1 & instdone_bits[i].bit))
+				busy = 1;
+		} else {
+			if (!(instdone & instdone_bits[i].bit))
+				busy = 1;
+		}
 
-	if (busy)
-	    printf("    busy: %s\n", instdone_bits[i].name);
-    }
+		if (busy)
+			printf("    busy: %s\n", instdone_bits[i].name);
+	}
 }
 
 static void
@@ -105,7 +104,7 @@ print_i830_pgtbl_err(unsigned int reg)
 	}
 
 	if (str)
-		printf ("    source = %s\n", str);
+		printf("    source = %s\n", str);
 
 	switch(reg & 0x7) {
 	case 0x0: str  = "Invalid GTT"; break;
@@ -117,85 +116,85 @@ print_i830_pgtbl_err(unsigned int reg)
 	case 0x6: str = "Invalid Tiling"; break;
 	case 0x7: str = "Host to CAM"; break;
 	}
-	printf ("    error = %s\n", str);
+	printf("    error = %s\n", str);
 }
 
 static void
 print_i915_pgtbl_err(unsigned int reg)
 {
 	if (reg & (1 << 29))
-		printf ("    Cursor A: Invalid GTT PTE\n");
+		printf("    Cursor A: Invalid GTT PTE\n");
 	if (reg & (1 << 28))
-		printf ("    Cursor B: Invalid GTT PTE\n");
+		printf("    Cursor B: Invalid GTT PTE\n");
 	if (reg & (1 << 27))
-		printf ("    MT: Invalid tiling\n");
+		printf("    MT: Invalid tiling\n");
 	if (reg & (1 << 26))
-		printf ("    MT: Invalid GTT PTE\n");
+		printf("    MT: Invalid GTT PTE\n");
 	if (reg & (1 << 25))
-		printf ("    LC: Invalid tiling\n");
+		printf("    LC: Invalid tiling\n");
 	if (reg & (1 << 24))
-		printf ("    LC: Invalid GTT PTE\n");
+		printf("    LC: Invalid GTT PTE\n");
 	if (reg & (1 << 23))
-		printf ("    BIN VertexData: Invalid GTT PTE\n");
+		printf("    BIN VertexData: Invalid GTT PTE\n");
 	if (reg & (1 << 22))
-		printf ("    BIN Instruction: Invalid GTT PTE\n");
+		printf("    BIN Instruction: Invalid GTT PTE\n");
 	if (reg & (1 << 21))
-		printf ("    CS VertexData: Invalid GTT PTE\n");
+		printf("    CS VertexData: Invalid GTT PTE\n");
 	if (reg & (1 << 20))
-		printf ("    CS Instruction: Invalid GTT PTE\n");
+		printf("    CS Instruction: Invalid GTT PTE\n");
 	if (reg & (1 << 19))
-		printf ("    CS: Invalid GTT\n");
+		printf("    CS: Invalid GTT\n");
 	if (reg & (1 << 18))
-		printf ("    Overlay: Invalid tiling\n");
+		printf("    Overlay: Invalid tiling\n");
 	if (reg & (1 << 16))
-		printf ("    Overlay: Invalid GTT PTE\n");
+		printf("    Overlay: Invalid GTT PTE\n");
 	if (reg & (1 << 14))
-		printf ("    Display C: Invalid tiling\n");
+		printf("    Display C: Invalid tiling\n");
 	if (reg & (1 << 12))
-		printf ("    Display C: Invalid GTT PTE\n");
+		printf("    Display C: Invalid GTT PTE\n");
 	if (reg & (1 << 10))
-		printf ("    Display B: Invalid tiling\n");
+		printf("    Display B: Invalid tiling\n");
 	if (reg & (1 << 8))
-		printf ("    Display B: Invalid GTT PTE\n");
+		printf("    Display B: Invalid GTT PTE\n");
 	if (reg & (1 << 6))
-		printf ("    Display A: Invalid tiling\n");
+		printf("    Display A: Invalid tiling\n");
 	if (reg & (1 << 4))
-		printf ("    Display A: Invalid GTT PTE\n");
+		printf("    Display A: Invalid GTT PTE\n");
 	if (reg & (1 << 1))
-		printf ("    Host Invalid PTE data\n");
+		printf("    Host Invalid PTE data\n");
 	if (reg & (1 << 0))
-		printf ("    Host Invalid GTT PTE\n");
+		printf("    Host Invalid GTT PTE\n");
 }
 
 static void
 print_i965_pgtbl_err(unsigned int reg)
 {
 	if (reg & (1 << 26))
-		printf ("    Invalid Sampler Cache GTT entry\n");
+		printf("    Invalid Sampler Cache GTT entry\n");
 	if (reg & (1 << 24))
-		printf ("    Invalid Render Cache GTT entry\n");
+		printf("    Invalid Render Cache GTT entry\n");
 	if (reg & (1 << 23))
-		printf ("    Invalid Instruction/State Cache GTT entry\n");
+		printf("    Invalid Instruction/State Cache GTT entry\n");
 	if (reg & (1 << 22))
-		printf ("    There is no ROC, this cannot occur!\n");
+		printf("    There is no ROC, this cannot occur!\n");
 	if (reg & (1 << 21))
-		printf ("    Invalid GTT entry during Vertex Fetch\n");
+		printf("    Invalid GTT entry during Vertex Fetch\n");
 	if (reg & (1 << 20))
-		printf ("    Invalid GTT entry during Command Fetch\n");
+		printf("    Invalid GTT entry during Command Fetch\n");
 	if (reg & (1 << 19))
-		printf ("    Invalid GTT entry during CS\n");
+		printf("    Invalid GTT entry during CS\n");
 	if (reg & (1 << 18))
-		printf ("    Invalid GTT entry during Cursor Fetch\n");
+		printf("    Invalid GTT entry during Cursor Fetch\n");
 	if (reg & (1 << 17))
-		printf ("    Invalid GTT entry during Overlay Fetch\n");
+		printf("    Invalid GTT entry during Overlay Fetch\n");
 	if (reg & (1 << 8))
-		printf ("    Invalid GTT entry during Display B Fetch\n");
+		printf("    Invalid GTT entry during Display B Fetch\n");
 	if (reg & (1 << 4))
-		printf ("    Invalid GTT entry during Display A Fetch\n");
+		printf("    Invalid GTT entry during Display A Fetch\n");
 	if (reg & (1 << 1))
-		printf ("    Valid PTE references illegal memory\n");
+		printf("    Valid PTE references illegal memory\n");
 	if (reg & (1 << 0))
-		printf ("    Invalid GTT entry during fetch for host\n");
+		printf("    Invalid GTT entry during fetch for host\n");
 }
 
 static void
@@ -214,22 +213,22 @@ static void
 print_snb_fence(unsigned int devid, uint64_t fence)
 {
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %u\n",
-		fence & 1 ? "" : "in",
-		fence & (1<<1) ? 'y' : 'x',
-		(int)(((fence>>32)&0xfff)+1)*128,
-		(uint32_t)fence & 0xfffff000,
-		(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
+			fence & 1 ? "" : "in",
+			fence & (1<<1) ? 'y' : 'x',
+			(int)(((fence>>32)&0xfff)+1)*128,
+			(uint32_t)fence & 0xfffff000,
+			(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
 }
 
 static void
 print_i965_fence(unsigned int devid, uint64_t fence)
 {
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %u\n",
-		fence & 1 ? "" : "in",
-		fence & (1<<1) ? 'y' : 'x',
-		(int)(((fence>>2)&0x1ff)+1)*128,
-		(uint32_t)fence & 0xfffff000,
-		(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
+			fence & 1 ? "" : "in",
+			fence & (1<<1) ? 'y' : 'x',
+			(int)(((fence>>2)&0x1ff)+1)*128,
+			(uint32_t)fence & 0xfffff000,
+			(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
 }
 
 static void
@@ -242,22 +241,22 @@ print_i915_fence(unsigned int devid, uint64_t fence)
 		tile_width = 512;
 
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %i\n",
-		fence & 1 ? "" : "in",
-		fence & 12 ? 'y' : 'x',
-		(1<<((fence>>4)&0xf))*tile_width,
-		(uint32_t)fence & 0xff00000,
-		1<<(20 + ((fence>>8)&0xf)));
+			fence & 1 ? "" : "in",
+			fence & 12 ? 'y' : 'x',
+			(1<<((fence>>4)&0xf))*tile_width,
+			(uint32_t)fence & 0xff00000,
+			1<<(20 + ((fence>>8)&0xf)));
 }
 
 static void
 print_i830_fence(unsigned int devid, uint64_t fence)
 {
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %i\n",
-		fence & 1 ? "" : "in",
-		fence & 12 ? 'y' : 'x',
-		(1<<((fence>>4)&0xf))*128,
-		(uint32_t)fence & 0x7f80000,
-		1<<(19 + ((fence>>8)&0xf)));
+			fence & 1 ? "" : "in",
+			fence & 12 ? 'y' : 'x',
+			(1<<((fence>>4)&0xf))*128,
+			(uint32_t)fence & 0x7f80000,
+			1<<(19 + ((fence>>8)&0xf)));
 }
 
 static void
@@ -275,252 +274,254 @@ print_fence(unsigned int devid, uint64_t fence)
 }
 
 static void
-read_data_file (FILE *file)
+read_data_file(FILE *file)
 {
-    struct drm_intel_decode *decode_ctx = NULL;
-    uint32_t devid = PCI_CHIP_I855_GM;
-    uint32_t *data = NULL;
-    long long unsigned fence;
-    int data_size = 0, count = 0, line_number = 0, matched;
-    char *line = NULL;
-    size_t line_size;
-    uint32_t offset, value;
-    uint32_t gtt_offset = 0, new_gtt_offset;
-    const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
-    char *ring_name = NULL;
-    int is_batch = 1;
-
-    while (getline (&line, &line_size, file) > 0) {
-	char *dashes;
-	line_number++;
-
-	dashes = strstr(line, "---");
-	if (dashes) {
-		char *new_ring_name = malloc(dashes - line);
-		strncpy(new_ring_name, line, dashes - line);
-		new_ring_name[dashes - line - 1] = '\0';
-
-		matched = sscanf (dashes, "--- gtt_offset = 0x%08x\n",
-				  &new_gtt_offset);
-		if (matched == 1) {
-			if (count) {
-				printf("%s (%s) at 0x%08x:\n",
-				       buffer_type[is_batch],
-				       ring_name,
-				       gtt_offset);
-				drm_intel_decode_set_batch_pointer(decode_ctx,
-								   data, gtt_offset,
-								   count);
-				drm_intel_decode(decode_ctx);
-				count = 0;
+	struct drm_intel_decode *decode_ctx = NULL;
+	uint32_t devid = PCI_CHIP_I855_GM;
+	uint32_t *data = NULL;
+	long long unsigned fence;
+	int data_size = 0, count = 0, line_number = 0, matched;
+	char *line = NULL;
+	size_t line_size;
+	uint32_t offset, value;
+	uint32_t gtt_offset = 0, new_gtt_offset;
+	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
+	char *ring_name = NULL;
+	int is_batch = 1;
+
+	while (getline(&line, &line_size, file) > 0) {
+		char *dashes;
+		line_number++;
+
+		dashes = strstr(line, "---");
+		if (dashes) {
+			char *new_ring_name = malloc(dashes - line);
+			strncpy(new_ring_name, line, dashes - line);
+			new_ring_name[dashes - line - 1] = '\0';
+
+			matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n",
+					&new_gtt_offset);
+			if (matched == 1) {
+				if (count) {
+					printf("%s (%s) at 0x%08x:\n",
+							buffer_type[is_batch],
+							ring_name,
+							gtt_offset);
+					drm_intel_decode_set_batch_pointer(decode_ctx,
+							data, gtt_offset,
+							count);
+					drm_intel_decode(decode_ctx);
+					count = 0;
+				}
+				gtt_offset = new_gtt_offset;
+				is_batch = 1;
+				free(ring_name);
+				ring_name = new_ring_name;
+				continue;
+			}
+
+			matched = sscanf(dashes, "--- ringbuffer = 0x%08x\n",
+					&new_gtt_offset);
+			if (matched == 1) {
+				if (count) {
+					printf("%s (%s) at 0x%08x:\n",
+							buffer_type[is_batch],
+							ring_name,
+							gtt_offset);
+					drm_intel_decode_set_batch_pointer(decode_ctx,
+							data, gtt_offset,
+							count);
+					drm_intel_decode(decode_ctx);
+					count = 0;
+				}
+				gtt_offset = new_gtt_offset;
+				is_batch = 0;
+				free(ring_name);
+				ring_name = new_ring_name;
+				continue;
 			}
-			gtt_offset = new_gtt_offset;
-			is_batch = 1;
-			free(ring_name);
-			ring_name = new_ring_name;
-			continue;
 		}
 
-		matched = sscanf (dashes, "--- ringbuffer = 0x%08x\n",
-				  &new_gtt_offset);
-		if (matched == 1) {
+		matched = sscanf(line, "%08x : %08x", &offset, &value);
+		if (matched != 2) {
+			unsigned int reg;
+
+			/* display reg section is after the ringbuffers, don't mix them */
 			if (count) {
 				printf("%s (%s) at 0x%08x:\n",
-				       buffer_type[is_batch],
-				       ring_name,
-				       gtt_offset);
+						buffer_type[is_batch],
+						ring_name,
+						gtt_offset);
 				drm_intel_decode_set_batch_pointer(decode_ctx,
-								   data, gtt_offset,
-								   count);
+						data, gtt_offset,
+						count);
 				drm_intel_decode(decode_ctx);
 				count = 0;
 			}
-			gtt_offset = new_gtt_offset;
-			is_batch = 0;
-			free(ring_name);
-			ring_name = new_ring_name;
+
+			printf("%s", line);
+
+			matched = sscanf(line, "PCI ID: 0x%04x\n", &reg);
+			if (matched == 0)
+				matched = sscanf(line, " PCI ID: 0x%04x\n", &reg);
+			if (matched == 0) {
+				const char *pci_id_start = strstr(line, "PCI ID");
+				if (pci_id_start)
+					matched = sscanf(pci_id_start, "PCI ID: 0x%04x\n", &reg);
+			}
+			if (matched == 1) {
+				devid = reg;
+				printf("Detected GEN%i chipset\n",
+						intel_gen(devid));
+
+				decode_ctx = drm_intel_decode_context_alloc(devid);
+			}
+
+			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);
+			if (matched == 1)
+				drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
+
+			matched = sscanf(line, "  PGTBL_ER: 0x%08x\n", &reg);
+			if (matched == 1 && reg)
+				print_pgtbl_err(reg, devid);
+
+			matched = sscanf(line, "  INSTDONE: 0x%08x\n", &reg);
+			if (matched == 1)
+				print_instdone(devid, reg, -1);
+
+			matched = sscanf(line, "  INSTDONE1: 0x%08x\n", &reg);
+			if (matched == 1)
+				print_instdone(devid, -1, reg);
+
+			matched = sscanf(line, "  fence[%i] = %Lx\n", &reg, &fence);
+			if (matched == 2)
+				print_fence(devid, fence);
+
 			continue;
 		}
-	}
 
-	matched = sscanf (line, "%08x : %08x", &offset, &value);
-	if (matched != 2) {
-	    unsigned int reg;
-
-	    /* display reg section is after the ringbuffers, don't mix them */
-	    if (count) {
-		    printf("%s (%s) at 0x%08x:\n",
-			   buffer_type[is_batch],
-			   ring_name,
-			   gtt_offset);
-		    drm_intel_decode_set_batch_pointer(decode_ctx,
-						       data, gtt_offset,
-						       count);
-		    drm_intel_decode(decode_ctx);
-		    count = 0;
-	    }
-
-	    printf("%s", line);
-
-	    matched = sscanf (line, "PCI ID: 0x%04x\n", &reg);
-	    if (matched == 0)
-		    matched = sscanf (line, " PCI ID: 0x%04x\n", &reg);
-	    if (matched == 0) {
-		    const char *pci_id_start = strstr (line, "PCI ID");
-		    if (pci_id_start)
-			    matched = sscanf (pci_id_start, "PCI ID: 0x%04x\n", &reg);
-	    }
-	    if (matched == 1) {
-		    devid = reg;
-		    printf("Detected GEN%i chipset\n",
-			   intel_gen(devid));
-
-		    decode_ctx = drm_intel_decode_context_alloc(devid);
-	    }
-
-	    matched = sscanf (line, "  ACTHD: 0x%08x\n", &reg);
-	    if (matched == 1)
-		    drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
-
-	    matched = sscanf (line, "  PGTBL_ER: 0x%08x\n", &reg);
-	    if (matched == 1 && reg)
-		    print_pgtbl_err(reg, devid);
-
-	    matched = sscanf (line, "  INSTDONE: 0x%08x\n", &reg);
-	    if (matched == 1)
-		print_instdone (devid, reg, -1);
-
-	    matched = sscanf (line, "  INSTDONE1: 0x%08x\n", &reg);
-	    if (matched == 1)
-		print_instdone (devid, -1, reg);
-
-	    matched = sscanf (line, "  fence[%i] = %Lx\n", &reg, &fence); 
-	    if (matched == 2)
-		print_fence (devid, fence);
-
-	    continue;
-	}
+		count++;
+
+		if (count > data_size) {
+			data_size = data_size ? data_size * 2 : 1024;
+			data = realloc(data, data_size * sizeof (uint32_t));
+			if (data == NULL) {
+				fprintf(stderr, "Out of memory.\n");
+				exit(1);
+			}
+		}
 
-	count++;
+		data[count-1] = value;
+	}
 
-	if (count > data_size) {
-	    data_size = data_size ? data_size * 2 : 1024;
-	    data = realloc (data, data_size * sizeof (uint32_t));
-	    if (data == NULL) {
-		fprintf (stderr, "Out of memory.\n");
-		exit (1);
-	    }
+	if (count) {
+		printf("%s (%s) at 0x%08x:\n",
+				buffer_type[is_batch],
+				ring_name,
+				gtt_offset);
+		drm_intel_decode_set_batch_pointer(decode_ctx,
+				data, gtt_offset,
+				count);
+		drm_intel_decode(decode_ctx);
 	}
 
-	data[count-1] = value;
-    }
-
-    if (count) {
-	printf("%s (%s) at 0x%08x:\n",
-	       buffer_type[is_batch],
-	       ring_name,
-	       gtt_offset);
-	drm_intel_decode_set_batch_pointer(decode_ctx,
-					   data, gtt_offset,
-					   count);
-	drm_intel_decode(decode_ctx);
-    }
-
-    free (data);
-    free (line);
-    free (ring_name);
+	free(data);
+	free(line);
+	free(ring_name);
 }
 
 int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
 {
-    FILE *file;
-    const char *path;
-    char *filename = NULL;
-    struct stat st;
-    int error;
-
-    if (argc > 2) {
-	fprintf (stderr,
-		 "intel_gpu_decode: Parse an Intel GPU i915_error_state\n"
-		 "Usage:\n"
-		 "\t%s [<file>]\n"
-		 "\n"
-		 "With no arguments, debugfs-dri-directory is probed for in "
-		 "/debug and \n"
-		 "/sys/kernel/debug.  Otherwise, it may be "
-		 "specified.  If a file is given,\n"
-		 "it is parsed as an GPU dump in the format of "
-		 "/debug/dri/0/i915_error_state.\n",
-		 argv[0]);
-	return 1;
-    }
-
-    if (argc == 1) {
-	if (isatty(0)) {
-	    path = "/debug/dri";
-	    error = stat (path, &st);
-	    if (error != 0) {
-		path = "/sys/kernel/debug/dri";
-		error = stat (path, &st);
-		if (error != 0) {
-		    errx(1,
-			 "Couldn't find i915 debugfs directory.\n\n"
-			 "Is debugfs mounted? You might try mounting it with a command such as:\n\n"
-			 "\tsudo mount -t debugfs debugfs /sys/kernel/debug\n");
+	FILE *file;
+	const char *path;
+	char *filename = NULL;
+	struct stat st;
+	int error;
+
+	if (argc > 2) {
+		fprintf(stderr,
+				"intel_gpu_decode: Parse an Intel GPU i915_error_state\n"
+				"Usage:\n"
+				"\t%s [<file>]\n"
+				"\n"
+				"With no arguments, debugfs-dri-directory is probed for in "
+				"/debug and \n"
+				"/sys/kernel/debug.  Otherwise, it may be "
+				"specified.  If a file is given,\n"
+				"it is parsed as an GPU dump in the format of "
+				"/debug/dri/0/i915_error_state.\n",
+				argv[0]);
+		return 1;
+	}
+
+	if (argc == 1) {
+		if (isatty(0)) {
+			path = "/debug/dri";
+			error = stat(path, &st);
+			if (error != 0) {
+				path = "/sys/kernel/debug/dri";
+				error = stat(path, &st);
+				if (error != 0) {
+					errx(1,
+					       "Couldn't find i915 debugfs directory.\n\n"
+					       "Is debugfs mounted? You might try mounting it with a command such as:\n\n"
+					       "\tsudo mount -t debugfs debugfs /sys/kernel/debug\n");
+				}
+			}
+		} else {
+			read_data_file(stdin);
+			exit(0);
 		}
-	    }
 	} else {
-	    read_data_file(stdin);
-	    exit(0);
-	}
-    } else {
-	path = argv[1];
-	error = stat (path, &st);
-	if (error != 0) {
-	    fprintf (stderr, "Error opening %s: %s\n",
-		     path, strerror (errno));
-	    exit (1);
+		path = argv[1];
+		error = stat(path, &st);
+		if (error != 0) {
+			fprintf(stderr, "Error opening %s: %s\n",
+					path, strerror(errno));
+			exit(1);
+		}
 	}
-    }
 
-    if (S_ISDIR (st.st_mode)) {
-	int ret;
+	if (S_ISDIR(st.st_mode)) {
+		int ret;
 
-	ret = asprintf (&filename, "%s/i915_error_state", path);
-	assert(ret > 0);
-	file = fopen(filename, "r");
-	if (!file) {
-	    int minor;
-	    for (minor = 0; minor < 64; minor++) {
-		free(filename);
-		ret = asprintf(&filename, "%s/%d/i915_error_state", path, minor);
+		ret = asprintf(&filename, "%s/i915_error_state", path);
 		assert(ret > 0);
-
 		file = fopen(filename, "r");
-		if (file)
-		    break;
-	    }
-	}
-	if (!file) {
-	    fprintf (stderr, "Failed to find i915_error_state beneath %s\n",
-		     path);
-	    exit (1);
-	}
-    } else {
-	file = fopen(path, "r");
-	if (!file) {
-	    fprintf (stderr, "Failed to open %s: %s\n",
-		     path, strerror (errno));
-	    exit (1);
+		if (!file) {
+			int minor;
+			for (minor = 0; minor < 64; minor++) {
+				free(filename);
+				ret = asprintf(&filename, "%s/%d/i915_error_state", path, minor);
+				assert(ret > 0);
+
+				file = fopen(filename, "r");
+				if (file)
+					break;
+			}
+		}
+		if (!file) {
+			fprintf(stderr, "Failed to find i915_error_state beneath %s\n",
+					path);
+			exit (1);
+		}
+	} else {
+		file = fopen(path, "r");
+		if (!file) {
+			fprintf(stderr, "Failed to open %s: %s\n",
+					path, strerror(errno));
+			exit (1);
+		}
 	}
-    }
 
-    read_data_file (file);
-    fclose (file);
+	read_data_file(file);
+	fclose(file);
 
-    if (filename != path)
-	free (filename);
+	if (filename != path)
+		free(filename);
 
-    return 0;
+	return 0;
 }
+
+/* vim: set ts=8 sw=8 tw=0 noet :*/
Signature · 6 lines
1.8.2.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/4 intel_error_decode: HEAD stuff

Show the decoded HEAD value, as well as print the calculated head offset per ringbuffer.

This will be superceded in the next commit, but I think more info is better.

---
 tools/intel_error_decode.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
tools/intel_error_decode.c +20 -2
index f554d57..e29ee1e 100644
@@ -55,6 +55,13 @@
 #include "intel_gpu_tools.h"
 #include "instdone.h"
 
+static uint32_t
+print_head(unsigned int reg)
+{
+	printf("    head = 0x%08x, wraps = %d\n", reg & (0x7ffff<<2), reg >> 21);
+	return reg & (0x7ffff<<2);
+}
+
 static void
 print_instdone(uint32_t devid, unsigned int instdone, unsigned int instdone1)
 {
@@ -288,6 +295,8 @@ read_data_file(FILE *file)
 	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
 	char *ring_name = NULL;
 	int is_batch = 1;
+	uint32_t head[3] = {-1, -1, -1};
+	int i = 0, num_rings = -1;
 
 	while (getline(&line, &line_size, file) > 0) {
 		char *dashes;
@@ -299,6 +308,9 @@ read_data_file(FILE *file)
 			strncpy(new_ring_name, line, dashes - line);
 			new_ring_name[dashes - line - 1] = '\0';
 
+			if (num_rings == -1)
+				num_rings = i;
+
 			matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n",
 					&new_gtt_offset);
 			if (matched == 1) {
@@ -324,10 +336,11 @@ read_data_file(FILE *file)
 					&new_gtt_offset);
 			if (matched == 1) {
 				if (count) {
-					printf("%s (%s) at 0x%08x:\n",
+					printf("%s (%s) at 0x%08x; HEAD points to 0x%08x:\n",
 							buffer_type[is_batch],
 							ring_name,
-							gtt_offset);
+							gtt_offset,
+							head[i++ % num_rings] + gtt_offset);
 					drm_intel_decode_set_batch_pointer(decode_ctx,
 							data, gtt_offset,
 							count);
@@ -377,6 +390,11 @@ read_data_file(FILE *file)
 				decode_ctx = drm_intel_decode_context_alloc(devid);
 			}
 
+			matched = sscanf(line, "  HEAD: 0x%08x\n", &reg);
+			if (matched == 1) {
+				head[i++] = print_head(reg);
+			}
+
 			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);
 			if (matched == 1)
 				drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
Signature · 1 line
1.8.2.1
#2 lore raw

Re: [PATCH 2/4] intel_error_decode: HEAD stuff

Quoted 2 lines · Ben Widawsky

Show the decoded HEAD value, as well as print the calculated head offset per ringbuffer.

Give us an example!
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw

PATCH 3/4 intel_error_decode: Fix ACTHD/HEAD mess with libdrm

In reply to Ben Widawsky

Easy to do with the stuff in place before this.

---
 tools/intel_error_decode.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
tools/intel_error_decode.c +15 -3
index e29ee1e..96aaf72 100644
@@ -295,7 +295,7 @@ read_data_file(FILE *file)
 	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
 	char *ring_name = NULL;
 	int is_batch = 1;
-	uint32_t head[3] = {-1, -1, -1};
+	uint32_t raw_head = -1, head[3] = {-1, -1, -1}, acthd[3] = {-1,-1,-1};
 	int i = 0, num_rings = -1;
 
 	while (getline(&line, &line_size, file) > 0) {
@@ -319,6 +319,9 @@ read_data_file(FILE *file)
 							buffer_type[is_batch],
 							ring_name,
 							gtt_offset);
+					drm_intel_decode_set_head_tail(decode_ctx,
+							acthd[i++ % num_rings] + gtt_offset,
+							0xffffffff);
 					drm_intel_decode_set_batch_pointer(decode_ctx,
 							data, gtt_offset,
 							count);
@@ -341,6 +344,9 @@ read_data_file(FILE *file)
 							ring_name,
 							gtt_offset,
 							head[i++ % num_rings] + gtt_offset);
+					drm_intel_decode_set_head_tail(decode_ctx,
+							acthd[i++ % num_rings] + gtt_offset,
+							0xffffffff);
 					drm_intel_decode_set_batch_pointer(decode_ctx,
 							data, gtt_offset,
 							count);
@@ -393,11 +399,17 @@ read_data_file(FILE *file)
 			matched = sscanf(line, "  HEAD: 0x%08x\n", &reg);
 			if (matched == 1) {
 				head[i++] = print_head(reg);
+				raw_head = reg;
 			}
 
 			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);
-			if (matched == 1)
-				drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
+			if (matched == 1) {
+				assert(raw_head != -1);
+				if (reg == raw_head)
+					acthd[i] = print_head(reg);
+				else
+					acthd[i] = reg;
+			}
 
 			matched = sscanf(line, "  PGTBL_ER: 0x%08x\n", &reg);
 			if (matched == 1 && reg)
Signature · 1 line
1.8.2.1
Reviewed-by on v1 3/4
#4 lore raw

Re: [PATCH 3/4] intel_error_decode: Fix ACTHD/HEAD mess with libdrm

Quoted 1 line · Ben Widawsky

Easy to do with the stuff in place before this.

This looks like it will make me happier, thanks.
With just a couple of minor changes,

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#5 lore raw

Re: [PATCH 3/4] intel_error_decode: Fix ACTHD/HEAD mess with libdrm

In reply to Ben Widawsky
Quoted 3 lines · Ben Widawsky

Easy to do with the stuff in place before this.

My assumptions on ordering of the error dump were incorrect. Ie. this patch is no good. Working on a fix when I have some time.

[snip]

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#6 lore raw

PATCH 4/4 intel_error_decode: Future proof ring count

In reply to Ben Widawsky
---
 tools/intel_error_decode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/intel_error_decode.c +3 -1
index 96aaf72..d2e91e7 100644
@@ -283,6 +283,7 @@ print_fence(unsigned int devid, uint64_t fence)
 static void
 read_data_file(FILE *file)
 {
+#define MAX_RINGS 10 /* I really hope this never... */
 	struct drm_intel_decode *decode_ctx = NULL;
 	uint32_t devid = PCI_CHIP_I855_GM;
 	uint32_t *data = NULL;
@@ -295,7 +296,7 @@ read_data_file(FILE *file)
 	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
 	char *ring_name = NULL;
 	int is_batch = 1;
-	uint32_t raw_head = -1, head[3] = {-1, -1, -1}, acthd[3] = {-1,-1,-1};
+	uint32_t raw_head = -1, head[MAX_RINGS] = {-1, -1, -1}, acthd[MAX_RINGS] = {-1,-1,-1};
 	int i = 0, num_rings = -1;
 
 	while (getline(&line, &line_size, file) > 0) {
@@ -400,6 +401,7 @@ read_data_file(FILE *file)
 			if (matched == 1) {
 				head[i++] = print_head(reg);
 				raw_head = reg;
+				assert(i < MAX_RINGS);
 			}
 
 			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);
Signature · 1 line
1.8.2.1
#7 lore raw

Re: [PATCH 4/4] intel_error_decode: Future proof ring count

Quoted 1 line · Ben Widawsky

Fold this into the earlier patch.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#8 lore raw

PATCH 1/3 intel_error_decode: Whitespacing fix

In reply to Ben Widawsky

The rest of igt has moved to kernel coding style. People had already been not conforming with the existing formatting in error decode, so we may as well fix it.

This addresses two primary issues, tabbing (remove spaces), and space after function in function call. I may have missed some of the latter since that was done by hand.

I have upcoming work in this file, and it was annoying me.

v2: Fix case alignment (Chris)

---
 tools/intel_error_decode.c | 585 +++++++++++++++++++++++----------------------
 1 file changed, 293 insertions(+), 292 deletions(-)
tools/intel_error_decode.c +293 -292
index 56bb984..f554d57 100644
@@ -1,4 +1,3 @@
-/* -*- c-basic-offset: 4 -*- */
 /*
  * Copyright © 2007 Intel Corporation
  * Copyright © 2009 Intel Corporation
@@ -57,30 +56,30 @@
 #include "instdone.h"
 
 static void
-print_instdone (uint32_t devid, unsigned int instdone, unsigned int instdone1)
+print_instdone(uint32_t devid, unsigned int instdone, unsigned int instdone1)
 {
-    int i;
-    static int once;
+	int i;
+	static int once;
 
-    if (!once) {
-	init_instdone_definitions(devid);
-	once = 1;
-    }
+	if (!once) {
+		init_instdone_definitions(devid);
+		once = 1;
+	}
 
-    for (i = 0; i < num_instdone_bits; i++) {
-	int busy = 0;
+	for (i = 0; i < num_instdone_bits; i++) {
+		int busy = 0;
 
-	if (instdone_bits[i].reg == INST_DONE_1) {
-	    if (!(instdone1 & instdone_bits[i].bit))
-		busy = 1;
-	} else {
-	    if (!(instdone & instdone_bits[i].bit))
-		busy = 1;
-	}
+		if (instdone_bits[i].reg == INST_DONE_1) {
+			if (!(instdone1 & instdone_bits[i].bit))
+				busy = 1;
+		} else {
+			if (!(instdone & instdone_bits[i].bit))
+				busy = 1;
+		}
 
-	if (busy)
-	    printf("    busy: %s\n", instdone_bits[i].name);
-    }
+		if (busy)
+			printf("    busy: %s\n", instdone_bits[i].name);
+	}
 }
 
 static void
@@ -105,7 +104,7 @@ print_i830_pgtbl_err(unsigned int reg)
 	}
 
 	if (str)
-		printf ("    source = %s\n", str);
+		printf("    source = %s\n", str);
 
 	switch(reg & 0x7) {
 	case 0x0: str  = "Invalid GTT"; break;
@@ -117,85 +116,85 @@ print_i830_pgtbl_err(unsigned int reg)
 	case 0x6: str = "Invalid Tiling"; break;
 	case 0x7: str = "Host to CAM"; break;
 	}
-	printf ("    error = %s\n", str);
+	printf("    error = %s\n", str);
 }
 
 static void
 print_i915_pgtbl_err(unsigned int reg)
 {
 	if (reg & (1 << 29))
-		printf ("    Cursor A: Invalid GTT PTE\n");
+		printf("    Cursor A: Invalid GTT PTE\n");
 	if (reg & (1 << 28))
-		printf ("    Cursor B: Invalid GTT PTE\n");
+		printf("    Cursor B: Invalid GTT PTE\n");
 	if (reg & (1 << 27))
-		printf ("    MT: Invalid tiling\n");
+		printf("    MT: Invalid tiling\n");
 	if (reg & (1 << 26))
-		printf ("    MT: Invalid GTT PTE\n");
+		printf("    MT: Invalid GTT PTE\n");
 	if (reg & (1 << 25))
-		printf ("    LC: Invalid tiling\n");
+		printf("    LC: Invalid tiling\n");
 	if (reg & (1 << 24))
-		printf ("    LC: Invalid GTT PTE\n");
+		printf("    LC: Invalid GTT PTE\n");
 	if (reg & (1 << 23))
-		printf ("    BIN VertexData: Invalid GTT PTE\n");
+		printf("    BIN VertexData: Invalid GTT PTE\n");
 	if (reg & (1 << 22))
-		printf ("    BIN Instruction: Invalid GTT PTE\n");
+		printf("    BIN Instruction: Invalid GTT PTE\n");
 	if (reg & (1 << 21))
-		printf ("    CS VertexData: Invalid GTT PTE\n");
+		printf("    CS VertexData: Invalid GTT PTE\n");
 	if (reg & (1 << 20))
-		printf ("    CS Instruction: Invalid GTT PTE\n");
+		printf("    CS Instruction: Invalid GTT PTE\n");
 	if (reg & (1 << 19))
-		printf ("    CS: Invalid GTT\n");
+		printf("    CS: Invalid GTT\n");
 	if (reg & (1 << 18))
-		printf ("    Overlay: Invalid tiling\n");
+		printf("    Overlay: Invalid tiling\n");
 	if (reg & (1 << 16))
-		printf ("    Overlay: Invalid GTT PTE\n");
+		printf("    Overlay: Invalid GTT PTE\n");
 	if (reg & (1 << 14))
-		printf ("    Display C: Invalid tiling\n");
+		printf("    Display C: Invalid tiling\n");
 	if (reg & (1 << 12))
-		printf ("    Display C: Invalid GTT PTE\n");
+		printf("    Display C: Invalid GTT PTE\n");
 	if (reg & (1 << 10))
-		printf ("    Display B: Invalid tiling\n");
+		printf("    Display B: Invalid tiling\n");
 	if (reg & (1 << 8))
-		printf ("    Display B: Invalid GTT PTE\n");
+		printf("    Display B: Invalid GTT PTE\n");
 	if (reg & (1 << 6))
-		printf ("    Display A: Invalid tiling\n");
+		printf("    Display A: Invalid tiling\n");
 	if (reg & (1 << 4))
-		printf ("    Display A: Invalid GTT PTE\n");
+		printf("    Display A: Invalid GTT PTE\n");
 	if (reg & (1 << 1))
-		printf ("    Host Invalid PTE data\n");
+		printf("    Host Invalid PTE data\n");
 	if (reg & (1 << 0))
-		printf ("    Host Invalid GTT PTE\n");
+		printf("    Host Invalid GTT PTE\n");
 }
 
 static void
 print_i965_pgtbl_err(unsigned int reg)
 {
 	if (reg & (1 << 26))
-		printf ("    Invalid Sampler Cache GTT entry\n");
+		printf("    Invalid Sampler Cache GTT entry\n");
 	if (reg & (1 << 24))
-		printf ("    Invalid Render Cache GTT entry\n");
+		printf("    Invalid Render Cache GTT entry\n");
 	if (reg & (1 << 23))
-		printf ("    Invalid Instruction/State Cache GTT entry\n");
+		printf("    Invalid Instruction/State Cache GTT entry\n");
 	if (reg & (1 << 22))
-		printf ("    There is no ROC, this cannot occur!\n");
+		printf("    There is no ROC, this cannot occur!\n");
 	if (reg & (1 << 21))
-		printf ("    Invalid GTT entry during Vertex Fetch\n");
+		printf("    Invalid GTT entry during Vertex Fetch\n");
 	if (reg & (1 << 20))
-		printf ("    Invalid GTT entry during Command Fetch\n");
+		printf("    Invalid GTT entry during Command Fetch\n");
 	if (reg & (1 << 19))
-		printf ("    Invalid GTT entry during CS\n");
+		printf("    Invalid GTT entry during CS\n");
 	if (reg & (1 << 18))
-		printf ("    Invalid GTT entry during Cursor Fetch\n");
+		printf("    Invalid GTT entry during Cursor Fetch\n");
 	if (reg & (1 << 17))
-		printf ("    Invalid GTT entry during Overlay Fetch\n");
+		printf("    Invalid GTT entry during Overlay Fetch\n");
 	if (reg & (1 << 8))
-		printf ("    Invalid GTT entry during Display B Fetch\n");
+		printf("    Invalid GTT entry during Display B Fetch\n");
 	if (reg & (1 << 4))
-		printf ("    Invalid GTT entry during Display A Fetch\n");
+		printf("    Invalid GTT entry during Display A Fetch\n");
 	if (reg & (1 << 1))
-		printf ("    Valid PTE references illegal memory\n");
+		printf("    Valid PTE references illegal memory\n");
 	if (reg & (1 << 0))
-		printf ("    Invalid GTT entry during fetch for host\n");
+		printf("    Invalid GTT entry during fetch for host\n");
 }
 
 static void
@@ -214,22 +213,22 @@ static void
 print_snb_fence(unsigned int devid, uint64_t fence)
 {
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %u\n",
-		fence & 1 ? "" : "in",
-		fence & (1<<1) ? 'y' : 'x',
-		(int)(((fence>>32)&0xfff)+1)*128,
-		(uint32_t)fence & 0xfffff000,
-		(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
+			fence & 1 ? "" : "in",
+			fence & (1<<1) ? 'y' : 'x',
+			(int)(((fence>>32)&0xfff)+1)*128,
+			(uint32_t)fence & 0xfffff000,
+			(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
 }
 
 static void
 print_i965_fence(unsigned int devid, uint64_t fence)
 {
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %u\n",
-		fence & 1 ? "" : "in",
-		fence & (1<<1) ? 'y' : 'x',
-		(int)(((fence>>2)&0x1ff)+1)*128,
-		(uint32_t)fence & 0xfffff000,
-		(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
+			fence & 1 ? "" : "in",
+			fence & (1<<1) ? 'y' : 'x',
+			(int)(((fence>>2)&0x1ff)+1)*128,
+			(uint32_t)fence & 0xfffff000,
+			(uint32_t)(((fence>>32)&0xfffff000) - (fence&0xfffff000) + 4096));
 }
 
 static void
@@ -242,22 +241,22 @@ print_i915_fence(unsigned int devid, uint64_t fence)
 		tile_width = 512;
 
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %i\n",
-		fence & 1 ? "" : "in",
-		fence & 12 ? 'y' : 'x',
-		(1<<((fence>>4)&0xf))*tile_width,
-		(uint32_t)fence & 0xff00000,
-		1<<(20 + ((fence>>8)&0xf)));
+			fence & 1 ? "" : "in",
+			fence & 12 ? 'y' : 'x',
+			(1<<((fence>>4)&0xf))*tile_width,
+			(uint32_t)fence & 0xff00000,
+			1<<(20 + ((fence>>8)&0xf)));
 }
 
 static void
 print_i830_fence(unsigned int devid, uint64_t fence)
 {
 	printf("    %svalid, %c-tiled, pitch: %i, start: 0x%08x, size: %i\n",
-		fence & 1 ? "" : "in",
-		fence & 12 ? 'y' : 'x',
-		(1<<((fence>>4)&0xf))*128,
-		(uint32_t)fence & 0x7f80000,
-		1<<(19 + ((fence>>8)&0xf)));
+			fence & 1 ? "" : "in",
+			fence & 12 ? 'y' : 'x',
+			(1<<((fence>>4)&0xf))*128,
+			(uint32_t)fence & 0x7f80000,
+			1<<(19 + ((fence>>8)&0xf)));
 }
 
 static void
@@ -275,252 +274,254 @@ print_fence(unsigned int devid, uint64_t fence)
 }
 
 static void
-read_data_file (FILE *file)
+read_data_file(FILE *file)
 {
-    struct drm_intel_decode *decode_ctx = NULL;
-    uint32_t devid = PCI_CHIP_I855_GM;
-    uint32_t *data = NULL;
-    long long unsigned fence;
-    int data_size = 0, count = 0, line_number = 0, matched;
-    char *line = NULL;
-    size_t line_size;
-    uint32_t offset, value;
-    uint32_t gtt_offset = 0, new_gtt_offset;
-    const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
-    char *ring_name = NULL;
-    int is_batch = 1;
-
-    while (getline (&line, &line_size, file) > 0) {
-	char *dashes;
-	line_number++;
-
-	dashes = strstr(line, "---");
-	if (dashes) {
-		char *new_ring_name = malloc(dashes - line);
-		strncpy(new_ring_name, line, dashes - line);
-		new_ring_name[dashes - line - 1] = '\0';
-
-		matched = sscanf (dashes, "--- gtt_offset = 0x%08x\n",
-				  &new_gtt_offset);
-		if (matched == 1) {
-			if (count) {
-				printf("%s (%s) at 0x%08x:\n",
-				       buffer_type[is_batch],
-				       ring_name,
-				       gtt_offset);
-				drm_intel_decode_set_batch_pointer(decode_ctx,
-								   data, gtt_offset,
-								   count);
-				drm_intel_decode(decode_ctx);
-				count = 0;
+	struct drm_intel_decode *decode_ctx = NULL;
+	uint32_t devid = PCI_CHIP_I855_GM;
+	uint32_t *data = NULL;
+	long long unsigned fence;
+	int data_size = 0, count = 0, line_number = 0, matched;
+	char *line = NULL;
+	size_t line_size;
+	uint32_t offset, value;
+	uint32_t gtt_offset = 0, new_gtt_offset;
+	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
+	char *ring_name = NULL;
+	int is_batch = 1;
+
+	while (getline(&line, &line_size, file) > 0) {
+		char *dashes;
+		line_number++;
+
+		dashes = strstr(line, "---");
+		if (dashes) {
+			char *new_ring_name = malloc(dashes - line);
+			strncpy(new_ring_name, line, dashes - line);
+			new_ring_name[dashes - line - 1] = '\0';
+
+			matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n",
+					&new_gtt_offset);
+			if (matched == 1) {
+				if (count) {
+					printf("%s (%s) at 0x%08x:\n",
+							buffer_type[is_batch],
+							ring_name,
+							gtt_offset);
+					drm_intel_decode_set_batch_pointer(decode_ctx,
+							data, gtt_offset,
+							count);
+					drm_intel_decode(decode_ctx);
+					count = 0;
+				}
+				gtt_offset = new_gtt_offset;
+				is_batch = 1;
+				free(ring_name);
+				ring_name = new_ring_name;
+				continue;
+			}
+
+			matched = sscanf(dashes, "--- ringbuffer = 0x%08x\n",
+					&new_gtt_offset);
+			if (matched == 1) {
+				if (count) {
+					printf("%s (%s) at 0x%08x:\n",
+							buffer_type[is_batch],
+							ring_name,
+							gtt_offset);
+					drm_intel_decode_set_batch_pointer(decode_ctx,
+							data, gtt_offset,
+							count);
+					drm_intel_decode(decode_ctx);
+					count = 0;
+				}
+				gtt_offset = new_gtt_offset;
+				is_batch = 0;
+				free(ring_name);
+				ring_name = new_ring_name;
+				continue;
 			}
-			gtt_offset = new_gtt_offset;
-			is_batch = 1;
-			free(ring_name);
-			ring_name = new_ring_name;
-			continue;
 		}
 
-		matched = sscanf (dashes, "--- ringbuffer = 0x%08x\n",
-				  &new_gtt_offset);
-		if (matched == 1) {
+		matched = sscanf(line, "%08x : %08x", &offset, &value);
+		if (matched != 2) {
+			unsigned int reg;
+
+			/* display reg section is after the ringbuffers, don't mix them */
 			if (count) {
 				printf("%s (%s) at 0x%08x:\n",
-				       buffer_type[is_batch],
-				       ring_name,
-				       gtt_offset);
+						buffer_type[is_batch],
+						ring_name,
+						gtt_offset);
 				drm_intel_decode_set_batch_pointer(decode_ctx,
-								   data, gtt_offset,
-								   count);
+						data, gtt_offset,
+						count);
 				drm_intel_decode(decode_ctx);
 				count = 0;
 			}
-			gtt_offset = new_gtt_offset;
-			is_batch = 0;
-			free(ring_name);
-			ring_name = new_ring_name;
+
+			printf("%s", line);
+
+			matched = sscanf(line, "PCI ID: 0x%04x\n", &reg);
+			if (matched == 0)
+				matched = sscanf(line, " PCI ID: 0x%04x\n", &reg);
+			if (matched == 0) {
+				const char *pci_id_start = strstr(line, "PCI ID");
+				if (pci_id_start)
+					matched = sscanf(pci_id_start, "PCI ID: 0x%04x\n", &reg);
+			}
+			if (matched == 1) {
+				devid = reg;
+				printf("Detected GEN%i chipset\n",
+						intel_gen(devid));
+
+				decode_ctx = drm_intel_decode_context_alloc(devid);
+			}
+
+			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);
+			if (matched == 1)
+				drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
+
+			matched = sscanf(line, "  PGTBL_ER: 0x%08x\n", &reg);
+			if (matched == 1 && reg)
+				print_pgtbl_err(reg, devid);
+
+			matched = sscanf(line, "  INSTDONE: 0x%08x\n", &reg);
+			if (matched == 1)
+				print_instdone(devid, reg, -1);
+
+			matched = sscanf(line, "  INSTDONE1: 0x%08x\n", &reg);
+			if (matched == 1)
+				print_instdone(devid, -1, reg);
+
+			matched = sscanf(line, "  fence[%i] = %Lx\n", &reg, &fence);
+			if (matched == 2)
+				print_fence(devid, fence);
+
 			continue;
 		}
-	}
 
-	matched = sscanf (line, "%08x : %08x", &offset, &value);
-	if (matched != 2) {
-	    unsigned int reg;
-
-	    /* display reg section is after the ringbuffers, don't mix them */
-	    if (count) {
-		    printf("%s (%s) at 0x%08x:\n",
-			   buffer_type[is_batch],
-			   ring_name,
-			   gtt_offset);
-		    drm_intel_decode_set_batch_pointer(decode_ctx,
-						       data, gtt_offset,
-						       count);
-		    drm_intel_decode(decode_ctx);
-		    count = 0;
-	    }
-
-	    printf("%s", line);
-
-	    matched = sscanf (line, "PCI ID: 0x%04x\n", &reg);
-	    if (matched == 0)
-		    matched = sscanf (line, " PCI ID: 0x%04x\n", &reg);
-	    if (matched == 0) {
-		    const char *pci_id_start = strstr (line, "PCI ID");
-		    if (pci_id_start)
-			    matched = sscanf (pci_id_start, "PCI ID: 0x%04x\n", &reg);
-	    }
-	    if (matched == 1) {
-		    devid = reg;
-		    printf("Detected GEN%i chipset\n",
-			   intel_gen(devid));
-
-		    decode_ctx = drm_intel_decode_context_alloc(devid);
-	    }
-
-	    matched = sscanf (line, "  ACTHD: 0x%08x\n", &reg);
-	    if (matched == 1)
-		    drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
-
-	    matched = sscanf (line, "  PGTBL_ER: 0x%08x\n", &reg);
-	    if (matched == 1 && reg)
-		    print_pgtbl_err(reg, devid);
-
-	    matched = sscanf (line, "  INSTDONE: 0x%08x\n", &reg);
-	    if (matched == 1)
-		print_instdone (devid, reg, -1);
-
-	    matched = sscanf (line, "  INSTDONE1: 0x%08x\n", &reg);
-	    if (matched == 1)
-		print_instdone (devid, -1, reg);
-
-	    matched = sscanf (line, "  fence[%i] = %Lx\n", &reg, &fence); 
-	    if (matched == 2)
-		print_fence (devid, fence);
-
-	    continue;
-	}
+		count++;
+
+		if (count > data_size) {
+			data_size = data_size ? data_size * 2 : 1024;
+			data = realloc(data, data_size * sizeof (uint32_t));
+			if (data == NULL) {
+				fprintf(stderr, "Out of memory.\n");
+				exit(1);
+			}
+		}
 
-	count++;
+		data[count-1] = value;
+	}
 
-	if (count > data_size) {
-	    data_size = data_size ? data_size * 2 : 1024;
-	    data = realloc (data, data_size * sizeof (uint32_t));
-	    if (data == NULL) {
-		fprintf (stderr, "Out of memory.\n");
-		exit (1);
-	    }
+	if (count) {
+		printf("%s (%s) at 0x%08x:\n",
+				buffer_type[is_batch],
+				ring_name,
+				gtt_offset);
+		drm_intel_decode_set_batch_pointer(decode_ctx,
+				data, gtt_offset,
+				count);
+		drm_intel_decode(decode_ctx);
 	}
 
-	data[count-1] = value;
-    }
-
-    if (count) {
-	printf("%s (%s) at 0x%08x:\n",
-	       buffer_type[is_batch],
-	       ring_name,
-	       gtt_offset);
-	drm_intel_decode_set_batch_pointer(decode_ctx,
-					   data, gtt_offset,
-					   count);
-	drm_intel_decode(decode_ctx);
-    }
-
-    free (data);
-    free (line);
-    free (ring_name);
+	free(data);
+	free(line);
+	free(ring_name);
 }
 
 int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
 {
-    FILE *file;
-    const char *path;
-    char *filename = NULL;
-    struct stat st;
-    int error;
-
-    if (argc > 2) {
-	fprintf (stderr,
-		 "intel_gpu_decode: Parse an Intel GPU i915_error_state\n"
-		 "Usage:\n"
-		 "\t%s [<file>]\n"
-		 "\n"
-		 "With no arguments, debugfs-dri-directory is probed for in "
-		 "/debug and \n"
-		 "/sys/kernel/debug.  Otherwise, it may be "
-		 "specified.  If a file is given,\n"
-		 "it is parsed as an GPU dump in the format of "
-		 "/debug/dri/0/i915_error_state.\n",
-		 argv[0]);
-	return 1;
-    }
-
-    if (argc == 1) {
-	if (isatty(0)) {
-	    path = "/debug/dri";
-	    error = stat (path, &st);
-	    if (error != 0) {
-		path = "/sys/kernel/debug/dri";
-		error = stat (path, &st);
-		if (error != 0) {
-		    errx(1,
-			 "Couldn't find i915 debugfs directory.\n\n"
-			 "Is debugfs mounted? You might try mounting it with a command such as:\n\n"
-			 "\tsudo mount -t debugfs debugfs /sys/kernel/debug\n");
+	FILE *file;
+	const char *path;
+	char *filename = NULL;
+	struct stat st;
+	int error;
+
+	if (argc > 2) {
+		fprintf(stderr,
+				"intel_gpu_decode: Parse an Intel GPU i915_error_state\n"
+				"Usage:\n"
+				"\t%s [<file>]\n"
+				"\n"
+				"With no arguments, debugfs-dri-directory is probed for in "
+				"/debug and \n"
+				"/sys/kernel/debug.  Otherwise, it may be "
+				"specified.  If a file is given,\n"
+				"it is parsed as an GPU dump in the format of "
+				"/debug/dri/0/i915_error_state.\n",
+				argv[0]);
+		return 1;
+	}
+
+	if (argc == 1) {
+		if (isatty(0)) {
+			path = "/debug/dri";
+			error = stat(path, &st);
+			if (error != 0) {
+				path = "/sys/kernel/debug/dri";
+				error = stat(path, &st);
+				if (error != 0) {
+					errx(1,
+					       "Couldn't find i915 debugfs directory.\n\n"
+					       "Is debugfs mounted? You might try mounting it with a command such as:\n\n"
+					       "\tsudo mount -t debugfs debugfs /sys/kernel/debug\n");
+				}
+			}
+		} else {
+			read_data_file(stdin);
+			exit(0);
 		}
-	    }
 	} else {
-	    read_data_file(stdin);
-	    exit(0);
-	}
-    } else {
-	path = argv[1];
-	error = stat (path, &st);
-	if (error != 0) {
-	    fprintf (stderr, "Error opening %s: %s\n",
-		     path, strerror (errno));
-	    exit (1);
+		path = argv[1];
+		error = stat(path, &st);
+		if (error != 0) {
+			fprintf(stderr, "Error opening %s: %s\n",
+					path, strerror(errno));
+			exit(1);
+		}
 	}
-    }
 
-    if (S_ISDIR (st.st_mode)) {
-	int ret;
+	if (S_ISDIR(st.st_mode)) {
+		int ret;
 
-	ret = asprintf (&filename, "%s/i915_error_state", path);
-	assert(ret > 0);
-	file = fopen(filename, "r");
-	if (!file) {
-	    int minor;
-	    for (minor = 0; minor < 64; minor++) {
-		free(filename);
-		ret = asprintf(&filename, "%s/%d/i915_error_state", path, minor);
+		ret = asprintf(&filename, "%s/i915_error_state", path);
 		assert(ret > 0);
-
 		file = fopen(filename, "r");
-		if (file)
-		    break;
-	    }
-	}
-	if (!file) {
-	    fprintf (stderr, "Failed to find i915_error_state beneath %s\n",
-		     path);
-	    exit (1);
-	}
-    } else {
-	file = fopen(path, "r");
-	if (!file) {
-	    fprintf (stderr, "Failed to open %s: %s\n",
-		     path, strerror (errno));
-	    exit (1);
+		if (!file) {
+			int minor;
+			for (minor = 0; minor < 64; minor++) {
+				free(filename);
+				ret = asprintf(&filename, "%s/%d/i915_error_state", path, minor);
+				assert(ret > 0);
+
+				file = fopen(filename, "r");
+				if (file)
+					break;
+			}
+		}
+		if (!file) {
+			fprintf(stderr, "Failed to find i915_error_state beneath %s\n",
+					path);
+			exit (1);
+		}
+	} else {
+		file = fopen(path, "r");
+		if (!file) {
+			fprintf(stderr, "Failed to open %s: %s\n",
+					path, strerror(errno));
+			exit (1);
+		}
 	}
-    }
 
-    read_data_file (file);
-    fclose (file);
+	read_data_file(file);
+	fclose(file);
 
-    if (filename != path)
-	free (filename);
+	if (filename != path)
+		free(filename);
 
-    return 0;
+	return 0;
 }
+
+/* vim: set ts=8 sw=8 tw=0 noet :*/
Signature · 6 lines
1.8.2.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH v2 2/3 intel_error_decode: HEAD stuff

Show the decoded HEAD value, as well as print the calculated head offset per ringbuffer.

This will be superceded in the next commit, but that patch is way more complicated than this one (read: error prone), so I want this here.

Example:
ringbuffer (blitter ring) at 0x00044000; HEAD points to: 0x00044950

v2: Actually make it work for all rings.

---
 tools/intel_error_decode.c | 50 ++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 17 deletions(-)
tools/intel_error_decode.c +33 -17
index f554d57..434c13a 100644
@@ -55,6 +55,13 @@
 #include "intel_gpu_tools.h"
 #include "instdone.h"
 
+static uint32_t
+print_head(unsigned int reg)
+{
+	printf("    head = 0x%08x, wraps = %d\n", reg & (0x7ffff<<2), reg >> 21);
+	return reg & (0x7ffff<<2);
+}
+
 static void
 print_instdone(uint32_t devid, unsigned int instdone, unsigned int instdone1)
 {
@@ -273,6 +280,20 @@ print_fence(unsigned int devid, uint64_t fence)
 	}
 }
 
+#define MAX_RINGS 10 /* I really hope this never... */
+uint32_t head[MAX_RINGS];
+int head_ndx = 0;
+int num_rings = -1;
+static void print_batch(int is_batch, const char *ring_name, uint32_t gtt_offset)
+{
+	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
+	if (is_batch) {
+		printf("%s (%s) at 0x%08x\n", buffer_type[is_batch], ring_name, gtt_offset);
+	} else {
+		printf("%s (%s) at 0x%08x; HEAD points to: 0x%08x\n", buffer_type[is_batch], ring_name, gtt_offset, head[head_ndx++ % num_rings] + gtt_offset);
+	}
+}
+
 static void
 read_data_file(FILE *file)
 {
@@ -285,7 +306,6 @@ read_data_file(FILE *file)
 	size_t line_size;
 	uint32_t offset, value;
 	uint32_t gtt_offset = 0, new_gtt_offset;
-	const char *buffer_type[2] = {  "ringbuffer", "batchbuffer" };
 	char *ring_name = NULL;
 	int is_batch = 1;
 
@@ -299,14 +319,14 @@ read_data_file(FILE *file)
 			strncpy(new_ring_name, line, dashes - line);
 			new_ring_name[dashes - line - 1] = '\0';
 
+			if (num_rings == -1)
+				num_rings = head_ndx;
+
 			matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n",
 					&new_gtt_offset);
 			if (matched == 1) {
 				if (count) {
-					printf("%s (%s) at 0x%08x:\n",
-							buffer_type[is_batch],
-							ring_name,
-							gtt_offset);
+					print_batch(is_batch, ring_name, gtt_offset);
 					drm_intel_decode_set_batch_pointer(decode_ctx,
 							data, gtt_offset,
 							count);
@@ -324,10 +344,7 @@ read_data_file(FILE *file)
 					&new_gtt_offset);
 			if (matched == 1) {
 				if (count) {
-					printf("%s (%s) at 0x%08x:\n",
-							buffer_type[is_batch],
-							ring_name,
-							gtt_offset);
+					print_batch(is_batch, ring_name, gtt_offset);
 					drm_intel_decode_set_batch_pointer(decode_ctx,
 							data, gtt_offset,
 							count);
@@ -348,10 +365,7 @@ read_data_file(FILE *file)
 
 			/* display reg section is after the ringbuffers, don't mix them */
 			if (count) {
-				printf("%s (%s) at 0x%08x:\n",
-						buffer_type[is_batch],
-						ring_name,
-						gtt_offset);
+				print_batch(is_batch, ring_name, gtt_offset);
 				drm_intel_decode_set_batch_pointer(decode_ctx,
 						data, gtt_offset,
 						count);
@@ -377,6 +391,11 @@ read_data_file(FILE *file)
 				decode_ctx = drm_intel_decode_context_alloc(devid);
 			}
 
+			matched = sscanf(line, "  HEAD: 0x%08x\n", &reg);
+			if (matched == 1) {
+				head[head_ndx++] = print_head(reg);
+			}
+
 			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);
 			if (matched == 1)
 				drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
@@ -415,10 +434,7 @@ read_data_file(FILE *file)
 	}
 
 	if (count) {
-		printf("%s (%s) at 0x%08x:\n",
-				buffer_type[is_batch],
-				ring_name,
-				gtt_offset);
+		print_batch(is_batch, ring_name, gtt_offset);
 		drm_intel_decode_set_batch_pointer(decode_ctx,
 				data, gtt_offset,
 				count);
Signature · 1 line
1.8.2.1
#10 lore raw

PATCH v3 3/3 intel_error_decode: Fix ACTHD/HEAD mess with libdrm

In reply to Ben Widawsky

This patch is an enormous mess, and I'd be fine if people didn't want it. However I have made the code do what we want at least on the two error dumps I've tried.

The way that it works is it attempts to identify which ACTHD belongs to the ring, or batch, and add the appropriate offset as necessary so the libdrm decoder can do the right thing.

What I do is put each ACTHD in a fixed part of the array, and assume the error dump will dump each ring in gtt ascending order (ie. RCS offset < VCS offset < BCS offset). I know, its hacky.

---
 tools/intel_error_decode.c | 97 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 92 insertions(+), 5 deletions(-)
tools/intel_error_decode.c +92 -5
index 434c13a..3d500d6 100644
@@ -55,11 +55,29 @@
 #include "intel_gpu_tools.h"
 #include "instdone.h"
 
+#define MAX_RINGS 10 /* I really hope this never... */
+struct head {
+	uint32_t rsvd : 2;
+	uint32_t head : 19; /* In dwords */
+	uint32_t wraps : 11;
+} __attribute__ ((__packed__));
+
+struct acthd {
+	uint64_t val;
+	enum {
+		INVALID=0,
+		RING=1,
+		BATCH=2
+	} type;
+} ring_acthds[MAX_RINGS * 2]; /* Cheap trick to put ring acthd in fixed slots */
+
+
 static uint32_t
 print_head(unsigned int reg)
 {
-	printf("    head = 0x%08x, wraps = %d\n", reg & (0x7ffff<<2), reg >> 21);
-	return reg & (0x7ffff<<2);
+	struct head head = *((struct head *)&reg);
+	printf("    head = 0x%08x, wraps = %d\n", head.head<<2, head.wraps);
+	return head.head << 2;
 }
 
 static void
@@ -280,7 +298,6 @@ print_fence(unsigned int devid, uint64_t fence)
 	}
 }
 
-#define MAX_RINGS 10 /* I really hope this never... */
 uint32_t head[MAX_RINGS];
 int head_ndx = 0;
 int num_rings = -1;
@@ -294,6 +311,59 @@ static void print_batch(int is_batch, const char *ring_name, uint32_t gtt_offset
 	}
 }
 
+static void emit_acthd(struct drm_intel_decode *decode_ctx,
+		uint64_t gtt_offset, uint64_t size, int is_batch)
+{
+	/* XXX: This depends on always being in ascending gtt space order */
+	static int which_acthd = 0;
+	int i;
+	size <<=2;
+
+	if (!is_batch) {
+		struct acthd *cur_acthd = &ring_acthds[which_acthd + MAX_RINGS];
+		which_acthd++;
+		if (cur_acthd->type == INVALID) {
+			return;
+		}
+
+		cur_acthd->val += gtt_offset;
+		if ((cur_acthd->val >= gtt_offset) && (cur_acthd->val < gtt_offset + size)) {
+			drm_intel_decode_set_head_tail(decode_ctx, cur_acthd->val, 0xffffffff);
+			cur_acthd->type = INVALID;
+		}
+		return;
+	}
+
+	for (i = 0; i < MAX_RINGS; i++) {
+		uint64_t offset = ring_acthds[i].val;
+		if (ring_acthds[i].type == INVALID)
+			continue;
+
+		if ((offset >= gtt_offset) && (offset < gtt_offset + size)) {
+			drm_intel_decode_set_head_tail(decode_ctx, offset, 0xffffffff);
+			ring_acthds[i].type = INVALID;
+			return;
+		}
+	}
+}
+
+static int acthd_equals_head(uint32_t a, uint32_t h)
+{
+	struct head _acthd = *(struct head *)&a;
+	struct head _head = *(struct head *)&h;
+
+	if (a == h)
+		return 1;
+
+	/* Likely the same */
+	if (_acthd.wraps == _head.wraps ||
+			_head.wraps + 1 == _acthd.wraps) {
+		return 1;
+	}
+
+	return 0;
+}
+
 static void
 read_data_file(FILE *file)
 {
@@ -308,6 +378,8 @@ read_data_file(FILE *file)
 	uint32_t gtt_offset = 0, new_gtt_offset;
 	char *ring_name = NULL;
 	int is_batch = 1;
+	uint32_t raw_head = -1;
+	int i=0;
 
 	while (getline(&line, &line_size, file) > 0) {
 		char *dashes;
@@ -327,6 +399,7 @@ read_data_file(FILE *file)
 			if (matched == 1) {
 				if (count) {
 					print_batch(is_batch, ring_name, gtt_offset);
+					emit_acthd(decode_ctx, gtt_offset, count, is_batch);
 					drm_intel_decode_set_batch_pointer(decode_ctx,
 							data, gtt_offset,
 							count);
@@ -345,6 +418,7 @@ read_data_file(FILE *file)
 			if (matched == 1) {
 				if (count) {
 					print_batch(is_batch, ring_name, gtt_offset);
+					emit_acthd(decode_ctx, gtt_offset, count, is_batch);
 					drm_intel_decode_set_batch_pointer(decode_ctx,
 							data, gtt_offset,
 							count);
@@ -366,6 +440,7 @@ read_data_file(FILE *file)
 			/* display reg section is after the ringbuffers, don't mix them */
 			if (count) {
 				print_batch(is_batch, ring_name, gtt_offset);
+				emit_acthd(decode_ctx, gtt_offset, count, is_batch);
 				drm_intel_decode_set_batch_pointer(decode_ctx,
 						data, gtt_offset,
 						count);
@@ -394,11 +469,22 @@ read_data_file(FILE *file)
 			matched = sscanf(line, "  HEAD: 0x%08x\n", &reg);
 			if (matched == 1) {
 				head[head_ndx++] = print_head(reg);
+				raw_head = reg;
+				assert(head_ndx < MAX_RINGS);
 			}
 
 			matched = sscanf(line, "  ACTHD: 0x%08x\n", &reg);
-			if (matched == 1)
-				drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff);
+			if (matched == 1) {
+				assert(raw_head != -1);
+				if (acthd_equals_head(reg, raw_head)) {
+					ring_acthds[MAX_RINGS + head_ndx - 1].type = RING;
+					ring_acthds[MAX_RINGS + head_ndx - 1].val = print_head(reg);
+				} else {
+					ring_acthds[i].val = reg;
+					ring_acthds[i].type = BATCH;
+					i++;
+				}
+			}
 
 			matched = sscanf(line, "  PGTBL_ER: 0x%08x\n", &reg);
 			if (matched == 1 && reg)
@@ -435,6 +521,7 @@ read_data_file(FILE *file)
 
 	if (count) {
 		print_batch(is_batch, ring_name, gtt_offset);
+		emit_acthd(decode_ctx, gtt_offset, count, is_batch);
 		drm_intel_decode_set_batch_pointer(decode_ctx,
 				data, gtt_offset,
 				count);
Signature · 1 line
1.8.2.1
#11 lore raw

Re: [PATCH 3/3] [v3] intel_error_decode: Fix ACTHD/HEAD mess with libdrm

Quoted 15 lines · Ben Widawsky

This patch is an enormous mess, and I'd be fine if people didn't want it. However I have made the code do what we want at least on the two error dumps I've tried.

The way that it works is it attempts to identify which ACTHD belongs to the ring, or batch, and add the appropriate offset as necessary so the libdrm decoder can do the right thing.

What I do is put each ACTHD in a fixed part of the array, and assume the error dump will dump each ring in gtt ascending order (ie. RCS offset < VCS offset < BCS offset). I know, its hacky.

---

tools/intel_error_decode.c static void print_batch(int is_batch, const char *ring_name, uint32_t gtt_offset · line 318

Quoted 5 lines
tools/intel_error_decode.c +5 -0
+static void emit_acthd(struct drm_intel_decode *decode_ctx,
+		uint64_t gtt_offset, uint64_t size, int is_batch)
+{
+	/* XXX: This depends on always being in ascending gtt space order */
+	static int which_acthd = 0;

You have ring_name available to sort on.
I would prefer the use of RING_HEAD when decoding the ringbuffers, so that the current HEAD is always printed there - acting like a frame pointer in a stacktrace. Making that distinction between rings and batches should make this code simplier.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#12 lore raw

Re: [PATCH 3/3] [v3] intel_error_decode: Fix ACTHD/HEAD mess with libdrm

Quoted 16 lines · Chris Wilson
Quoted 14 lines · Ben Widawsky

This patch is an enormous mess, and I'd be fine if people didn't want it. However I have made the code do what we want at least on the two error dumps I've tried.

The way that it works is it attempts to identify which ACTHD belongs to the ring, or batch, and add the appropriate offset as necessary so the libdrm decoder can do the right thing.

What I do is put each ACTHD in a fixed part of the array, and assume the error dump will dump each ring in gtt ascending order (ie. RCS offset < VCS offset < BCS offset). I know, its hacky.

---

Quoted 15 lines

tools/intel_error_decode.c static void print_batch(int is_batch, const char *ring_name, uint32_t gtt_offset · line 318

Quoted 5 lines
tools/intel_error_decode.c +5 -0
+static void emit_acthd(struct drm_intel_decode *decode_ctx,
+		uint64_t gtt_offset, uint64_t size, int is_batch)
+{
+	/* XXX: This depends on always being in ascending gtt space order */
+	static int which_acthd = 0;

You have ring_name available to sort on.
I would prefer the use of RING_HEAD when decoding the ringbuffers, so that the current HEAD is always printed there - acting like a frame pointer in a stacktrace. Making that distinction between rings and batches should make this code simplier.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Any issue with me pushing the first 2, and stalling on this one?

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#13 lore raw

Re: [PATCH 3/3] [v3] intel_error_decode: Fix ACTHD/HEAD mess with libdrm

Quoted 1 line · Ben Widawsky

Any issue with me pushing the first 2, and stalling on this one?

None at all, the improvements are worthwhile.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre