Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 37 additions and 5 deletions.
  1. +32 −1 rnn/demmt.c
  2. +4 −3 rnn/demmt.h
  3. +1 −1  rnn/demmt_pushbuf.c
33 rnn/demmt.c
View
@@ -59,6 +59,7 @@ int chipset;
int guess_invalid_pushbuf = 1;
int invalid_pushbufs_visible = 1;
int decode_invalid_buffers = 1;
+int find_ib_buffer = 0;
static void dump(int id)
{
@@ -89,6 +90,30 @@ static void dump_writes(int id)
comment[0][0] = 0;
comment[1][0] = 0;
+ if (find_ib_buffer)
+ {
+ if (cur->start != 0 || cur->end < 8)
+ return;
+ uint32_t *data = (uint32_t *)buffers[id]->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);
+ int i;
+ for (i = 0; i < MAX_ID; ++i)
+ {
+ if (buffers[i] && buffers[i]->gpu_start == gpu_addr &&
+ buffers[i]->length >= 4 * ((data[1] & 0x7fffffff) >> 10))
+ {
+ fprintf(stdout, "possible IB buffer: %d\n", id);
+ break;
+ }
+ }
+
+ return;
+ }
+
mmt_log("currently buffered writes for id: %d:\n", id);
while (cur)
{
@@ -521,6 +546,9 @@ static void clear_buffered_writes()
static void demmt_memread(struct mmt_read *w, void *state)
{
+ if (find_ib_buffer)
+ return;
+
char comment[50];
if (print_gpu_addresses && buffers[w->id]->gpu_start)
sprintf(comment, " (gpu=0x%08lx)", buffers[w->id]->gpu_start + w->offset);
@@ -924,7 +952,8 @@ static void usage()
fprintf(stderr, "Usage: demmt [OPTION]\n"
"Decodes binary trace files generated by Valgrind MMT. Reads standard input.\n\n"
" -m 'chipset'\tset chipset version\n"
- " -n id\t\tassume buffer \"id\" contains IB entries\n"
+ " -f\t\tfind possible IB buffer(s)\n"
+ " -n id\t\tset buffer \"id\" as IB\n"
" -g\t\tprint gpu addresses\n"
" -o\t\tdump ioctl data\n"
"\n"
@@ -971,6 +1000,8 @@ int main(int argc, char *argv[])
dump_ioctls = 1;
else if (!strcmp(argv[i], "-g"))
print_gpu_addresses = 1;
+ else if (!strcmp(argv[i], "-f"))
+ find_ib_buffer = 1;
else
usage();
}
7 rnn/demmt.h
View
@@ -4,10 +4,11 @@
#include "demmt_pushbuf.h"
#define MMT_DEBUG 0
+extern int find_ib_buffer;
-#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
-#define mmt_log(fmt, ...) do { fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
-#define mmt_log_cont(fmt, ...) do { fprintf(stdout, fmt, __VA_ARGS__); } while (0)
+#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
+#define mmt_log(fmt, ...) do { if (!find_ib_buffer) fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
+#define mmt_log_cont(fmt, ...) do { if (!find_ib_buffer) fprintf(stdout, fmt, __VA_ARGS__); } while (0)
#define mmt_error(fmt, ...) do { fprintf(stderr, fmt, __VA_ARGS__); } while (0)
struct buffer
2  rnn/demmt_pushbuf.c
View
@@ -339,7 +339,7 @@ void ib_decode(struct ib_decode_state *state, uint32_t data, char *output)
{
int i;
- state->address |= data & 0xff;
+ state->address |= ((uint64_t)(data & 0xff)) << 32;
state->unk8 = (data >> 8) & 0x1;
state->not_main = (data >> 9) & 0x1;
state->size = (data & 0x7fffffff) >> 10;

No commit comments for this range

Something went wrong with that request. Please try again.