Skip to content
Permalink
Browse files

demmt: make pb_pointer_found be per-device

Fixes decoding on CUDA + GL traces
  • Loading branch information
imirkin committed Nov 14, 2015
1 parent a34147e commit b90ca5ac8dff8e0eb3aaba9ad10096d28c38544c
Showing with 37 additions and 15 deletions.
  1. +14 −15 demmt/buffer_decode.c
  2. +20 −0 demmt/nvrm.c
  3. +3 −0 demmt/nvrm.h
@@ -30,8 +30,6 @@
#include "config.h"
#include "log.h"

static int pb_pointer_found = 0;//TODO: per device

void buffer_decode_register_write(struct cpu_mapping *mapping, uint32_t start, uint32_t len)
{
char pushbuf_desc[1024];
@@ -47,13 +45,14 @@ void buffer_decode_register_write(struct cpu_mapping *mapping, uint32_t start, u
if (gpu_addr)
gpu_addr -= start;

if (mapping->fdtype == FDNVIDIA && !pb_pointer_found)
if (mapping->fdtype == FDNVIDIA)
{
struct gpu_object *dev = nvrm_get_device(mapping->object);
int chipset = nvrm_get_chipset(dev);
int ib_supported = chipset == 0x50 || chipset >= 0x80;
bool ib_supported = chipset == 0x50 || chipset >= 0x80;
bool pb_pointer_found = nvrm_get_pb_pointer_found(dev);

if (ib_supported)
if (ib_supported && !pb_pointer_found)
{
uint32_t idx = start / 4;
uint32_t *data = (uint32_t *)mapping->data;
@@ -64,12 +63,12 @@ void buffer_decode_register_write(struct cpu_mapping *mapping, uint32_t start, u
struct gpu_object *fifo = nvrm_get_fifo(mapping->object, gpu_addr + addr, 1);
if (fifo && is_fifo_and_addr_belongs(fifo, gpu_addr + addr))
{
pb_pointer_found = 1;
nvrm_device_set_pb_pointer_found(dev, true);
mapping->ib.entries = get_fifo_state(fifo)->ib.entries;
}
}

if (!pb_pointer_found)
if (!nvrm_get_pb_pointer_found(dev))
{
uint64_t pb_gpu_addr = (((uint64_t)(data[idx] & 0xff)) << 32) | (data[idx - 1] & 0xfffffffc);
struct gpu_object *obj;
@@ -81,17 +80,17 @@ void buffer_decode_register_write(struct cpu_mapping *mapping, uint32_t start, u
if (gpu_mapping->address == pb_gpu_addr &&
gpu_mapping->length >= 4 * ((data[idx] & 0x7fffffff) >> 10))
{
pb_pointer_found = 1;
nvrm_device_set_pb_pointer_found(dev, true);
break;
}
}

if (pb_pointer_found)
if (nvrm_get_pb_pointer_found(dev))
break;
}
}

if (pb_pointer_found)
if (nvrm_get_pb_pointer_found(dev))
{
if (info && decode_pb)
mmt_printf("IB buffer: %d\n", mapping->id);
@@ -101,7 +100,7 @@ void buffer_decode_register_write(struct cpu_mapping *mapping, uint32_t start, u
}
}
}
else
else if (!pb_pointer_found)
{
if (start == 0x40)
{
@@ -110,16 +109,16 @@ void buffer_decode_register_write(struct cpu_mapping *mapping, uint32_t start, u
{
struct gpu_object *fifo = nvrm_get_fifo(mapping->object, gpu_addr + addr, 1);
if (fifo && is_fifo_and_addr_belongs(fifo, gpu_addr + addr))
pb_pointer_found = 1;
nvrm_device_set_pb_pointer_found(dev, true);

if (!pb_pointer_found)
if (!nvrm_get_pb_pointer_found(dev))
{
struct gpu_mapping *gpu_mapping = gpu_mapping_find(pb_gpu_addr, dev);
if (gpu_mapping)
pb_pointer_found = 1;
nvrm_device_set_pb_pointer_found(dev, true);
}

if (pb_pointer_found)
if (nvrm_get_pb_pointer_found(dev))
{
if (info && decode_pb)
mmt_printf("USER buffer: %d\n", mapping->id);
@@ -22,6 +22,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/

#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
@@ -39,6 +40,7 @@ struct nvrm_device
{
int chipset;
int fifos;
bool pb_pointer_found;
};

static inline struct nvrm_device *nvrm_dev(struct gpu_object *dev)
@@ -249,6 +251,24 @@ int nvrm_get_chipset(struct gpu_object *obj)
demmt_abort();
}

bool nvrm_get_pb_pointer_found(struct gpu_object *obj)
{
struct gpu_object *dev = nvrm_get_device(obj);

assert(dev);
assert(dev->class_data);
return nvrm_dev(dev)->pb_pointer_found;
}

void nvrm_device_set_pb_pointer_found(struct gpu_object *obj, bool pb_pointer_found)
{
struct gpu_object *dev = nvrm_get_device(obj);

assert(dev);
assert(dev->class_data);
nvrm_dev(dev)->pb_pointer_found = pb_pointer_found;
}

static struct gpu_object *nvrm_add_object(uint32_t fd, uint32_t cid, uint32_t parent, uint32_t handle, uint32_t class_)
{
struct gpu_object *obj = gpu_object_add(fd, cid, parent, handle, class_);
@@ -1,13 +1,16 @@
#ifndef DEMMT_NVRM_H
#define DEMMT_NVRM_H

#include <stdbool.h>
#include <stdint.h>
#include "buffer.h"
#include "mmt_bin_decode_nvidia.h"

struct gpu_object *nvrm_get_device(struct gpu_object *obj);
int nvrm_get_chipset(struct gpu_object *obj);
void nvrm_device_set_chipset(struct gpu_object *dev, int chipset);
bool nvrm_get_pb_pointer_found(struct gpu_object *obj);
void nvrm_device_set_pb_pointer_found(struct gpu_object *dev, bool found);
struct gpu_object *nvrm_get_fifo(struct gpu_object *obj, uint64_t gpu_addr, int strict);
struct gpu_object *nvrm_get_parent_fifo(struct gpu_object *obj);
int is_fifo_and_addr_belongs(struct gpu_object *obj, uint64_t ctx);

0 comments on commit b90ca5a

Please sign in to comment.
You can’t perform that action at this time.