summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2017-11-11 22:09:16 -0800
committerKenneth Graunke <[email protected]>2017-11-13 17:10:51 -0800
commit596e8603179006a448b2cb5be5890bc57f41e090 (patch)
treea0cfe8369c6e56459a72461a09ac3a11ce816623
parent4bb119f00b2a5742adf79958d691d3b92ea6f87e (diff)
intel/tools/error: Refactor buffer matching, add more buffers.
Based on a similar patch to intel_error_decode by Chris Wilson. While we're de-duplicating the gtt_offset calculation, we can simplify it to assume two hex digits are there - the kernel has done this since v4.6, and we already require error states from v4.10. Reviewed-by: Chris Wilson <[email protected]>
-rw-r--r--src/intel/tools/aubinator_error_decode.c92
1 files changed, 30 insertions, 62 deletions
diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c
index ae9f08f1d2b..0b0a308a317 100644
--- a/src/intel/tools/aubinator_error_decode.c
+++ b/src/intel/tools/aubinator_error_decode.c
@@ -488,7 +488,7 @@ read_data_file(FILE *file)
char *line = NULL;
size_t line_size;
uint32_t offset, value;
- uint64_t gtt_offset = 0, new_gtt_offset;
+ uint64_t gtt_offset = 0;
const char *buffer_name = "batch buffer";
char *ring_name = NULL;
struct gen_device_info devinfo;
@@ -538,76 +538,44 @@ read_data_file(FILE *file)
dashes = strstr(line, "---");
if (dashes) {
- uint32_t lo, hi;
- char *new_ring_name = malloc(dashes - line);
- strncpy(new_ring_name, line, dashes - line);
- new_ring_name[dashes - line - 1] = '\0';
+ const struct {
+ const char *match;
+ const char *name;
+ } buffers[] = {
+ { "ringbuffer", "ring buffer" },
+ { "gtt_offset", "batch buffer" },
+ { "hw context", "HW Context" },
+ { "hw status", "HW status" },
+ { "wa context", "WA context" },
+ { "wa batchbuffer", "WA batch" },
+ { "user", "user" },
+ { "semaphores", "semaphores", },
+ { "guc log buffer", "GuC log", },
+ { NULL, "unknown" },
+ }, *b;
printf("%s", line);
- matched = sscanf(dashes, "--- gtt_offset = 0x%08x %08x\n",
- &hi, &lo);
- if (matched > 0) {
- new_gtt_offset = hi;
- if (matched == 2) {
- new_gtt_offset <<= 32;
- new_gtt_offset |= lo;
- }
-
- gtt_offset = new_gtt_offset;
- free(ring_name);
- ring_name = new_ring_name;
- buffer_name = "batch buffer";
- continue;
- }
+ gtt_offset = 0;
- matched = sscanf(dashes, "--- ringbuffer = 0x%08x %08x\n",
- &hi, &lo);
- if (matched > 0) {
- new_gtt_offset = hi;
- if (matched == 2) {
- new_gtt_offset <<= 32;
- new_gtt_offset |= lo;
- }
+ free(ring_name);
+ ring_name = malloc(dashes - line);
+ strncpy(ring_name, line, dashes - line);
- gtt_offset = new_gtt_offset;
- free(ring_name);
- ring_name = new_ring_name;
- buffer_name = "ring buffer";
- continue;
+ dashes += 4;
+ for (b = buffers; b->match; b++) {
+ if (strncasecmp(dashes, b->match, strlen(b->match)) == 0)
+ break;
}
- matched = sscanf(dashes, "--- HW Context = 0x%08x %08x\n",
- &hi, &lo);
- if (matched > 0) {
- new_gtt_offset = hi;
- if (matched == 2) {
- new_gtt_offset <<= 32;
- new_gtt_offset |= lo;
- }
-
- gtt_offset = new_gtt_offset;
- free(ring_name);
- ring_name = new_ring_name;
- buffer_name = "HW Context";
- continue;
- }
+ buffer_name = b->name;
- matched = sscanf(dashes, "--- user = 0x%08x %08x\n",
- &hi, &lo);
- if (matched > 0) {
- new_gtt_offset = hi;
- if (matched == 2) {
- new_gtt_offset <<= 32;
- new_gtt_offset |= lo;
- }
+ uint32_t hi, lo;
+ dashes = strchr(dashes, '=');
+ if (dashes && sscanf(dashes, "= 0x%08x %08x\n", &hi, &lo))
+ gtt_offset = ((uint64_t) hi) << 32 | lo;
- gtt_offset = new_gtt_offset;
- free(ring_name);
- ring_name = new_ring_name;
- buffer_name = "user";
- continue;
- }
+ continue;
}
matched = sscanf(line, "%08x : %08x", &offset, &value);