Permalink
Browse files

mmt: dump additional data for DRM_NOUVEAU_GEM_PUSHBUF ioctl

  • Loading branch information...
1 parent f14c918 commit a50d5c87696d088ed586e654fabb9eca3234ffa4 @mslusarz mslusarz committed Jul 19, 2014
Showing with 68 additions and 0 deletions.
  1. +57 −0 mmt/mmt_nouveau_ioctl.c
  2. +1 −0 mmt/mmt_nv_ioctl.c
  3. +10 −0 mmt/vki-linux-drm-nouveau.h
View
57 mmt/mmt_nouveau_ioctl.c
@@ -49,6 +49,60 @@ void mmt_nouveau_ioctl_post_close(UWord *args)
FD_CLR(fd, &nouveau_fds);
}
+static void mmt_nouveau_pushbuf(struct vki_drm_nouveau_gem_pushbuf *pushbuf)
+{
+ struct vki_drm_nouveau_gem_pushbuf_bo *buffers = ULong_to_Ptr(pushbuf->buffers);
+ struct vki_drm_nouveau_gem_pushbuf_push *push = ULong_to_Ptr(pushbuf->push);
+ struct vki_drm_nouveau_gem_pushbuf_reloc *relocs = ULong_to_Ptr(pushbuf->relocs);
+ int i;
+
+ if (mmt_binary_output)
+ {
+ mmt_bin_write_1('n');
+ mmt_bin_write_1('P');
+ int size = pushbuf->nr_buffers * sizeof(buffers[0]) + pushbuf->nr_push * sizeof(push[0]) + pushbuf->nr_relocs * sizeof(relocs[0]);
+ mmt_bin_write_4(size + 3 * 4);
+ mmt_bin_write_buffer((UChar *)buffers, pushbuf->nr_buffers * sizeof(buffers[0]));
+ mmt_bin_write_buffer((UChar *)push, pushbuf->nr_push * sizeof(push[0]));
+ mmt_bin_write_buffer((UChar *)relocs, pushbuf->nr_relocs * sizeof(relocs[0]));
+ mmt_bin_end();
+ }
+ else
+ {
+ VG_(message)(Vg_DebugMsg, "DRM_NOUVEAU_GEM_PUSHBUF, channel: %d, nr_buffers: %d, buffers: 0x%llx, nr_relocs: %d, "
+ "relocs: 0x%llx, nr_push: %d, push: 0x%llx, suffix0: 0x%x, suffix1: 0x%x, vram_available: %llu, gart_available: %llu\n",
+ pushbuf->channel, pushbuf->nr_buffers, pushbuf->buffers,
+ pushbuf->nr_relocs, pushbuf->relocs, pushbuf->nr_push, pushbuf->push,
+ pushbuf->suffix0, pushbuf->suffix1, pushbuf->vram_available,
+ pushbuf->gart_available);
+
+ for (i = 0; i < pushbuf->nr_buffers; ++i)
+ {
+ VG_(message)(Vg_DebugMsg, "buffer[%d]: handle: %d, user_priv: 0x%llx, read_domains: 0x%x, write_domains: 0x%x, "
+ "valid_domains: 0x%x, presumed.valid: %d, presumed.domain: 0x%x, presumed.offset: %lld\n",
+ i, buffers[i].handle, buffers[i].user_priv, buffers[i].read_domains,
+ buffers[i].write_domains, buffers[i].valid_domains,
+ buffers[i].presumed.valid, buffers[i].presumed.domain,
+ buffers[i].presumed.offset);
+ }
+
+ for (i = 0; i < pushbuf->nr_push; ++i)
+ {
+ VG_(message)(Vg_DebugMsg, "push[%d]: bo_index: %d, offset: 0x%llx, length: 0x%llx\n",
+ i, push[i].bo_index, push[i].offset, push[i].length);
+ }
+
+ for (i = 0; i < pushbuf->nr_relocs; ++i)
+ {
+ VG_(message)(Vg_DebugMsg, "reloc[%d]: reloc_bo_index: %d, reloc_bo_offset: 0x%x, bo_index: %d, flags: 0x%x, "
+ "data: 0x%x, vor: 0x%x, tor: 0x%x\n",
+ i, relocs[i].reloc_bo_index, relocs[i].reloc_bo_offset,
+ relocs[i].bo_index, relocs[i].flags, relocs[i].data,
+ relocs[i].vor, relocs[i].tor);
+ }
+ }
+}
+
void mmt_nouveau_ioctl_pre(UWord *args)
{
int fd = args[0];
@@ -89,6 +143,9 @@ void mmt_nouveau_ioctl_pre(UWord *args)
}
VG_(message) (Vg_DebugMsg, "%s\n", line);
}
+
+ if ((id & 0xff) == 0x40 + 0x41) // DRM_NOUVEAU_GEM_PUSHBUF
+ mmt_nouveau_pushbuf((void *)data);
}
else
VG_(message)(Vg_DebugMsg, "pre_ioctl, fd: %d, wrong id:0x%x\n", fd, id);
View
1 mmt/mmt_nv_ioctl.c
@@ -56,6 +56,7 @@ static int trace_mark_cnt = 0;
* m = mmap
* o = memory dump
* p = create mapped object
+ * P = nouveau's GEM_PUSHBUF data
* r = create driver object
* t = create dma object
* v = create device object
View
10 mmt/vki-linux-drm-nouveau.h
@@ -100,6 +100,16 @@ struct vki_drm_nouveau_gem_pushbuf_bo {
struct vki_drm_nouveau_gem_pushbuf_bo_presumed presumed;
};
+struct vki_drm_nouveau_gem_pushbuf_reloc {
+ __vki_u32 reloc_bo_index;
+ __vki_u32 reloc_bo_offset;
+ __vki_u32 bo_index;
+ __vki_u32 flags;
+ __vki_u32 data;
+ __vki_u32 vor;
+ __vki_u32 tor;
+};
+
struct vki_drm_nouveau_gem_pushbuf_push {
__vki_u32 bo_index;
__vki_u32 pad;

0 comments on commit a50d5c8

Please sign in to comment.