Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

demmt: automatically detect pushbufs (-f/-n not needed)

  • Loading branch information...
commit ca15120fa0c5e51823307e389fec9169aa54a1a5 1 parent d013aa3
@mslusarz mslusarz authored
Showing with 57 additions and 40 deletions.
  1. +56 −40 rnn/demmt.c
  2. +1 −0  rnn/demmt.h
View
96 rnn/demmt.c
@@ -71,6 +71,7 @@ int quiet = 0;
int disassemble_shaders = 1;
int indent_logs = 1;
int is_nouveau = 0;
+int force_pushbuf_decoding = 0;
const struct envy_colors *colors = NULL;
static void dump(struct buffer *buf)
@@ -104,52 +105,61 @@ static void dump_writes(struct buffer *buf)
comment[0][0] = 0;
comment[1][0] = 0;
- if (find_pb_pointer)
+ if (find_pb_pointer || (!is_nouveau && pb_pointer_buffer == -1))
{
- if (ib_supported)
+ do
{
- if (cur->start != 0 || cur->end < 8)
- return;
- uint32_t *data = (uint32_t *)buf->data;
- if (!data[0] || !data[1])
- return;
- if (data[0] & 0x3)
- return;
- uint64_t gpu_addr = (((uint64_t)(data[1] & 0xff)) << 32) | (data[0] & 0xfffffffc);
- struct buffer *buf2;
- for (buf2 = buffers_list; buf2 != NULL; buf2 = buf2->next)
+ if (ib_supported)
{
- if (buf2->gpu_start == gpu_addr &&
- buf2->length >= 4 * ((data[1] & 0x7fffffff) >> 10))
- {
- fprintf(stdout, "possible IB buffer: %d\n", buf->id);
+ if (cur->start != 0 || cur->end < 8)
+ break;
+ uint32_t *data = (uint32_t *)buf->data;
+ if (!data[0] || !data[1])
break;
+ if (data[0] & 0x3)
+ break;
+ uint64_t gpu_addr = (((uint64_t)(data[1] & 0xff)) << 32) | (data[0] & 0xfffffffc);
+ struct buffer *buf2;
+ for (buf2 = buffers_list; buf2 != NULL; buf2 = buf2->next)
+ {
+ if (buf2->gpu_start == gpu_addr &&
+ buf2->length >= 4 * ((data[1] & 0x7fffffff) >> 10))
+ {
+ if (!quiet)
+ fprintf(stdout, "%sIB buffer: %d\n", find_pb_pointer ? "possible " : "", buf->id);
+ pb_pointer_buffer = buf->id;
+ buf->type = IB;
+ break;
+ }
}
}
- }
- else
- {
- if (buf->type == USER) // already checked
- return;
- if (cur->start != 0x40 || cur->end < 0x44)
- return;
- uint32_t gpu_addr = *(uint32_t *)&(buf->data[0x40]);
- if (!gpu_addr)
- return;
-
- struct buffer *buf2;
- for (buf2 = buffers_list; buf2 != NULL; buf2 = buf2->next)
+ else
{
- if (gpu_addr >= buf2->gpu_start && gpu_addr < buf2->gpu_start + buf2->length)
- {
- fprintf(stdout, "possible USER buffer: %d\n", buf->id);
- buf->type = USER;
+ if (buf->type == USER) // already checked
+ break;
+ if (cur->start != 0x40 || cur->end < 0x44)
break;
+ uint32_t gpu_addr = *(uint32_t *)&(buf->data[0x40]);
+ if (!gpu_addr)
+ break;
+
+ struct buffer *buf2;
+ for (buf2 = buffers_list; buf2 != NULL; buf2 = buf2->next)
+ {
+ if (gpu_addr >= buf2->gpu_start && gpu_addr < buf2->gpu_start + buf2->length)
+ {
+ if (!quiet)
+ fprintf(stdout, "%sUSER buffer: %d\n", find_pb_pointer ? "possible " : "", buf->id);
+ pb_pointer_buffer = buf->id;
+ buf->type = USER;
+ break;
+ }
}
}
- }
+ } while (0);
- return;
+ if (find_pb_pointer)
+ return;
}
mmt_log("currently buffered writes for id: %d:\n", buf->id);
@@ -212,7 +222,7 @@ static void dump_writes(struct buffer *buf)
ib_decode_start(ibstate);
else if (buf->type == PUSH)
{
- if (pb_pointer_buffer == -1 && !is_nouveau)
+ if (force_pushbuf_decoding)
{
if (addr != state->next_command_offset)
{
@@ -248,7 +258,7 @@ static void dump_writes(struct buffer *buf)
}
else if (buf->type == PUSH)
{
- if (pb_pointer_buffer != -1 || quiet || is_nouveau)
+ if (!force_pushbuf_decoding)
pushbuf_desc[0] = 0;
else if (state->pushbuf_invalid == 0 || decode_invalid_buffers)
pushbuf_decode(state, *(uint32_t *)(data + addr), pushbuf_desc, NULL, 0);
@@ -291,7 +301,10 @@ static void dump_writes(struct buffer *buf)
if (buf->type == IB)
ib_decode_end(ibstate);
else if (buf->type == PUSH)
- pushbuf_decode_end(state);
+ {
+ if (force_pushbuf_decoding)
+ pushbuf_decode_end(state);
+ }
else if (buf->type == USER)
user_decode_end(ustate);
@@ -1221,17 +1234,18 @@ const struct mmt_nvidia_decode_funcs demmt_funcs =
static void usage()
{
fprintf(stderr, "Usage: demmt [OPTION]\n"
- "Decodes binary trace files generated by Valgrind MMT. Reads standard input.\n\n"
+ "Decodes binary trace files generated by Valgrind MMT. Reads standard input or file passed by -l.\n\n"
" -m 'chipset'\tset chipset version (required)\n"
" -f\t\tfind possible pushbuf pointers (IB / USER)\n"
" -n id\t\tset pushbuf pointer to \"id\"\n"
" -g\t\tprint gpu addresses\n"
" -o\t\tdump ioctl data\n"
- " -q\t\t(quiet) print only the most important data (pushbufs from IB / USER and disassembled code)\n"
+ " -q\t\t(quiet) print only the most important data (pushbufs from IB / USER, disassembled code, TSCs, TICs, etc)\n"
" -a\t\tdisable shader disassembly\n"
" -c\t\tenable colors\n"
" -l file\tuse \"file\" as input (can be compressed by gzip / bzip2 / xz)\n"
" -t\t\tdeindent logs\n"
+ " -x\t\tforce pushbuf decoding even without pushbuf pointer\n"
"\n"
" -s\t\tdo not \"compress\" obvious buffer clears\n"
" -i\t\tdo not guess invalid pushbufs\n"
@@ -1293,6 +1307,8 @@ int main(int argc, char *argv[])
}
else if (!strcmp(argv[i], "-t"))
indent_logs = 0;
+ else if (!strcmp(argv[i], "-x"))
+ force_pushbuf_decoding = 1;
else
usage();
}
View
1  rnn/demmt.h
@@ -66,6 +66,7 @@ extern int chipset;
extern int ib_supported;
extern int guess_invalid_pushbuf;
extern int is_nouveau;
+extern int force_pushbuf_decoding;
void buffer_register_write(struct buffer *buf, uint32_t offset, uint8_t len, const void *data);
void register_gpu_only_buffer(uint64_t gpu_start, int len, uint64_t mmap_offset, uint64_t data1, uint64_t data2);
Please sign in to comment.
Something went wrong with that request. Please try again.