On Fri, Apr 11, 2014 at 05:48:12PM +0100, oscar.ma...@intel.com wrote:
> +static void check_error_state(const char *expected_ring_name,
> +                             uint64_t expected_offset)
> +{
> +     FILE *file;
> +     int debug_fd;
> +     char *line = NULL;
> +     size_t line_size = 0;
> +     char *dashes = NULL;
> +     char *ring_name = NULL;
> +     int bb_matched = 0;
> +     uint32_t gtt_offset;
> +     char expected_line[32];
> +     int req_matched = 0;
> +     int requests;
> +     uint32_t seqno, tail;
> +     long jiffies;
> +     int ringbuf_matched = 0;
> +     unsigned int offset, command, expected_addr = 0;
> +     int i, items;
> +     bool bb_ok = false, req_ok = false, ringbuf_ok = false;

Most of these are only of use in local scope.

> +     debug_fd = igt_debugfs_open("i915_error_state", O_RDONLY);
> +     igt_assert(debug_fd >= 0);
> +     file = fdopen(debug_fd, "r");
> +
> +     while (getline(&line, &line_size, file) > 0) {
> +             dashes = strstr(line, "---");
> +             if (!dashes)
> +                     continue;
> +
> +             ring_name = realloc(ring_name, dashes - line);
> +             strncpy(ring_name, line, dashes - line);
> +             ring_name[dashes - line - 1] = '\0';
> +
> +             bb_matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n",
> +                             &gtt_offset);
> +             if (bb_matched == 1) {
> +                     igt_assert(strstr(ring_name, expected_ring_name));
> +                     igt_assert(gtt_offset == expected_offset);
> +
> +                     for (i = 0; i < sizeof(batch) / 4; i++) {
> +                             igt_assert(getline(&line, &line_size, file) > 
> 0);
> +                             snprintf(expected_line, sizeof(expected_line), 
> "%08x :  %08x",
> +                                             4*i, batch[i]);
> +                             igt_assert(strstr(line, expected_line));
> +                     }
> +                     bb_ok = true;
> +                     continue;
> +             }
> +
> +             req_matched = sscanf(dashes, "--- %d requests\n",
> +                             &requests);
> +             if (req_matched == 1) {
> +                     igt_assert(strstr(ring_name, expected_ring_name));
> +                     igt_assert(requests == 1);

Bad assumption. You could still have the request from
gem_quiescent_gpu() which may not have been retired before the error
triggers.

> +
> +                     igt_assert(getline(&line, &line_size, file) > 0);
> +                     items = sscanf(line, "  seqno 0x%08x, emitted %ld, tail 
> 0x%08x\n",
> +                                     &seqno, &jiffies, &tail);
> +                     igt_assert(items == 3);

Bad. I may change the format. s/may/will/

> +                     req_ok = true;
> +                     continue;
> +             }
> +
> +             ringbuf_matched = sscanf(dashes, "--- ringbuffer = 0x%08x\n",
> +                             &gtt_offset);
> +             if (ringbuf_matched == 1) {
> +                     if (!strstr(ring_name, expected_ring_name))
> +                             continue;
> +                     igt_assert(req_ok);
> +
> +                     for (i = 0; i < tail / 4; i++) {
> +                             igt_assert(getline(&line, &line_size, file) > 
> 0);
> +                             items = sscanf(line, "%08x :  %08x\n",
> +                                             &offset, &command);
> +                             igt_assert(items == 2);
> +                             if ((command & 0x1F800000) == 
> MI_BATCH_BUFFER_START) {
> +                                     igt_assert(getline(&line, &line_size, 
> file) > 0);
> +                                     items = sscanf(line, "%08x :  %08x\n",
> +                                                     &offset, 
> &expected_addr);
> +                                     igt_assert(items == 2);
> +                                     i++;
> +                             }
> +                     }
> +                     igt_assert(expected_addr == expected_offset);

Bad. Some gen encode flags into the BB start address.

> +                     ringbuf_ok = true;
> +                     continue;
> +             }
> +
> +             if (bb_ok && req_ok && ringbuf_ok)
> +                     break;
> +     }
> +     igt_assert(bb_ok && req_ok && ringbuf_ok);
> +
> +     free(line);
> +     free(ring_name);
> +     close(debug_fd);
> +}

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to