Permalink
Browse files

demmt: parse 2 "new" messages: gpu_map2 and gpu_unmap2

  • Loading branch information...
1 parent 0ed18f6 commit 615f5099d611a3c19e2a0876b4cf54c615c913d5 @mslusarz mslusarz committed Jul 6, 2014
Showing with 98 additions and 19 deletions.
  1. +41 −19 rnn/demmt.c
  2. +12 −0 rnn/mmt_bin2dedma_nvidia.c
  3. +24 −0 rnn/mmt_bin_decode_nvidia.c
  4. +21 −0 rnn/mmt_bin_decode_nvidia.h
View
@@ -890,54 +890,64 @@ static void demmt_nv_alloc_map(struct mmt_nvidia_alloc_map *alloc, void *state)
unk_maps = m;
}
-static void demmt_nv_gpu_map(struct mmt_nvidia_gpu_map *map, void *state)
+static void demmt_nv_gpu_map(uint32_t data1, uint32_t data2, uint32_t data3, uint64_t gpu_start, uint32_t len, void *state)
{
- mmt_log("gpu map: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, gpu_start: 0x%08x, len: 0x%08x\n",
- map->data1, map->data2, map->data3, map->gpu_start, map->len);
+ mmt_log("gpu map: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, gpu_start: 0x%08lx, len: 0x%08x\n",
+ data1, data2, data3, gpu_start, len);
struct buffer *buf;
for (buf = buffers_list; buf != NULL; buf = buf->next)
- if (buf->data1 == map->data1 && buf->data2 == map->data3 && buf->length == map->len)
+ if (buf->data1 == data1 && buf->data2 == data3 && buf->length == len)
{
- buf->gpu_start = map->gpu_start;
+ buf->gpu_start = gpu_start;
mmt_log("setting gpu address for buffer %d to 0x%08lx\n", buf->id, buf->gpu_start);
return;
}
struct unk_map *tmp;
for (tmp = unk_maps; tmp != NULL; tmp = tmp->next)
{
- if (tmp->data1 == map->data1 && tmp->data2 == map->data3)
+ if (tmp->data1 == data1 && tmp->data2 == data3)
{
mmt_log("TODO: unk buffer found, demmt_nv_gpu_map needs to be updated!%s\n", "");
break;
}
}
- mmt_log("registering gpu only buffer, size: %d\n", map->len);
+ mmt_log("registering gpu only buffer, size: %d\n", len);
buf = calloc(1, sizeof(struct buffer));
buf->id = -1;
//will allocate when needed
//buf->data = calloc(map->len, 1);
buf->cpu_start = 0;
- buf->gpu_start = map->gpu_start;
- buf->length = map->len;
+ buf->gpu_start = gpu_start;
+ buf->length = len;
buf->mmap_offset = 0;
- buf->data1 = map->data1;
- buf->data2 = map->data3;
+ buf->data1 = data1;
+ buf->data2 = data3;
if (gpu_only_buffers_list)
gpu_only_buffers_list->prev = buf;
buf->next = gpu_only_buffers_list;
gpu_only_buffers_list = buf;
}
-static void demmt_nv_gpu_unmap(struct mmt_nvidia_gpu_unmap *unmap, void *state)
+static void demmt_nv_gpu_map1(struct mmt_nvidia_gpu_map *map, void *state)
{
- mmt_log("gpu unmap: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, gpu_start: 0x%08x\n",
- unmap->data1, unmap->data2, unmap->data3, unmap->gpu_start);
+ demmt_nv_gpu_map(map->data1, map->data2, map->data3, map->gpu_start, map->len, state);
+}
+
+static void demmt_nv_gpu_map2(struct mmt_nvidia_gpu_map2 *map, void *state)
+{
+ demmt_nv_gpu_map(map->data1, map->data2, map->data3, map->gpu_start, map->len, state);
+}
+
+static void demmt_nv_gpu_unmap(uint32_t data1, uint32_t data2, uint32_t data3, uint64_t gpu_start, void *state)
+{
+ mmt_log("gpu unmap: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, gpu_start: 0x%08lx\n",
+ data1, data2, data3, gpu_start);
struct buffer *buf;
for (buf = buffers_list; buf != NULL; buf = buf->next)
- if (buf->data1 == unmap->data1 && buf->data2 == unmap->data3 &&
- buf->gpu_start == unmap->gpu_start)
+ if (buf->data1 == data1 && buf->data2 == data3 &&
+ buf->gpu_start == gpu_start)
{
mmt_log("clearing gpu address for buffer %d (was: 0x%08lx)\n", buf->id, buf->gpu_start);
buf->gpu_start = 0;
@@ -946,7 +956,7 @@ static void demmt_nv_gpu_unmap(struct mmt_nvidia_gpu_unmap *unmap, void *state)
for (buf = gpu_only_buffers_list; buf != NULL; buf = buf->next)
{
- if (buf->data1 == unmap->data1 && buf->data2 == unmap->data3 && buf->gpu_start == unmap->gpu_start)
+ if (buf->data1 == data1 && buf->data2 == data3 && buf->gpu_start == gpu_start)
{
mmt_log("deregistering gpu only buffer of size %d\n", buf->length);
buffer_free(buf);
@@ -957,6 +967,16 @@ static void demmt_nv_gpu_unmap(struct mmt_nvidia_gpu_unmap *unmap, void *state)
mmt_log("gpu only buffer not found%s\n", "");
}
+static void demmt_nv_gpu_unmap1(struct mmt_nvidia_gpu_unmap *unmap, void *state)
+{
+ demmt_nv_gpu_unmap(unmap->data1, unmap->data2, unmap->data3, unmap->gpu_start, state);
+}
+
+static void demmt_nv_gpu_unmap2(struct mmt_nvidia_gpu_unmap2 *unmap, void *state)
+{
+ demmt_nv_gpu_unmap(unmap->data1, unmap->data2, unmap->data3, unmap->gpu_start, state);
+}
+
static void demmt_nv_mmap(struct mmt_nvidia_mmap *mm, void *state)
{
mmt_log("mmap: address: %p, length: 0x%08lx, id: %d, offset: 0x%08lx, data1: 0x%08lx, data2: 0x%08lx\n",
@@ -1053,8 +1073,10 @@ const struct mmt_nvidia_decode_funcs demmt_funcs =
demmt_nv_create_mapped,
demmt_nv_create_dma_object,
demmt_nv_alloc_map,
- demmt_nv_gpu_map,
- demmt_nv_gpu_unmap,
+ demmt_nv_gpu_map1,
+ demmt_nv_gpu_map2,
+ demmt_nv_gpu_unmap1,
+ demmt_nv_gpu_unmap2,
demmt_nv_mmap,
demmt_nv_unmap,
demmt_nv_bind,
View
@@ -111,11 +111,21 @@ static void txt_nv_gpu_map(struct mmt_nvidia_gpu_map *map, void *state)
fprintf(stdout, PFX "gpu map 0x%08x:0x%08x:0x%08x, addr 0x%08x, len 0x%08x\n", map->data1, map->data2, map->data3, map->gpu_start, map->len);
}
+static void txt_nv_gpu_map2(struct mmt_nvidia_gpu_map2 *map, void *state)
+{
+ fprintf(stdout, PFX "gpu map 0x%08x:0x%08x:0x%08x, addr 0x%08lx, len 0x%08x\n", map->data1, map->data2, map->data3, map->gpu_start, map->len);
+}
+
static void txt_nv_gpu_unmap(struct mmt_nvidia_gpu_unmap *unmap, void *state)
{
fprintf(stdout, PFX "gpu unmap 0x%08x:0x%08x:0x%08x addr 0x%08x\n", unmap->data1, unmap->data2, unmap->data3, unmap->gpu_start);
}
+static void txt_nv_gpu_unmap2(struct mmt_nvidia_gpu_unmap2 *unmap, void *state)
+{
+ fprintf(stdout, PFX "gpu unmap 0x%08x:0x%08x:0x%08x addr 0x%08lx\n", unmap->data1, unmap->data2, unmap->data3, unmap->gpu_start);
+}
+
static void txt_nv_mmap(struct mmt_nvidia_mmap *map, void *state)
{
fprintf(stdout, PFX "got new mmap for 0x%08lx:0x%08lx at %p, len: 0x%08lx, offset: 0x%llx, serial: %d\n",
@@ -188,7 +198,9 @@ const struct mmt_nvidia_decode_funcs txt_nvidia_funcs =
txt_nv_create_dma_object,
txt_nv_alloc_map,
txt_nv_gpu_map,
+ txt_nv_gpu_map2,
txt_nv_gpu_unmap,
+ txt_nv_gpu_unmap2,
txt_nv_mmap,
txt_nv_unmap,
txt_nv_bind,
@@ -173,6 +173,18 @@ void mmt_decode_nvidia(struct mmt_nvidia_decode_funcs *funcs, void *state)
mmt_idx += size;
}
+ else if (nv->subtype == 'G')
+ {
+ size = sizeof(struct mmt_nvidia_gpu_map2) + 1;
+ struct mmt_nvidia_gpu_map2 *map = mmt_load_data(size);
+
+ mmt_check_eor(size);
+
+ if (funcs->gpu_map2)
+ funcs->gpu_map2(map, state);
+
+ mmt_idx += size;
+ }
else if (nv->subtype == 'h')
{
size = sizeof(struct mmt_nvidia_gpu_unmap) + 1;
@@ -185,6 +197,18 @@ void mmt_decode_nvidia(struct mmt_nvidia_decode_funcs *funcs, void *state)
mmt_idx += size;
}
+ else if (nv->subtype == 'H')
+ {
+ size = sizeof(struct mmt_nvidia_gpu_unmap2) + 1;
+ struct mmt_nvidia_gpu_unmap2 *unmap = mmt_load_data(size);
+
+ mmt_check_eor(size);
+
+ if (funcs->gpu_unmap2)
+ funcs->gpu_unmap2(unmap, state);
+
+ mmt_idx += size;
+ }
else if (nv->subtype == 'm')
{
size = sizeof(struct mmt_nvidia_mmap) + 1;
@@ -90,6 +90,16 @@ struct mmt_nvidia_gpu_map
uint32_t len;
} __packed;
+struct mmt_nvidia_gpu_map2
+{
+ struct mmt_message_nv msg_type;
+ uint32_t data1;
+ uint32_t data2;
+ uint32_t data3;
+ uint64_t gpu_start;
+ uint32_t len;
+} __packed;
+
struct mmt_nvidia_gpu_unmap
{
struct mmt_message_nv msg_type;
@@ -99,6 +109,15 @@ struct mmt_nvidia_gpu_unmap
uint32_t gpu_start;
} __packed;
+struct mmt_nvidia_gpu_unmap2
+{
+ struct mmt_message_nv msg_type;
+ uint32_t data1;
+ uint32_t data2;
+ uint32_t data3;
+ uint64_t gpu_start;
+} __packed;
+
struct mmt_nvidia_bind
{
struct mmt_message_nv msg_type;
@@ -179,7 +198,9 @@ struct mmt_nvidia_decode_funcs
void (*create_dma_object)(struct mmt_nvidia_create_dma_object *create, void *state);
void (*alloc_map)(struct mmt_nvidia_alloc_map *alloc, void *state);
void (*gpu_map)(struct mmt_nvidia_gpu_map *map, void *state);
+ void (*gpu_map2)(struct mmt_nvidia_gpu_map2 *map, void *state);
void (*gpu_unmap)(struct mmt_nvidia_gpu_unmap *unmap, void *state);
+ void (*gpu_unmap2)(struct mmt_nvidia_gpu_unmap2 *unmap, void *state);
void (*mmap)(struct mmt_nvidia_mmap *map, void *state);
void (*unmap)(struct mmt_nvidia_unmap *unmap, void *state);
void (*bind)(struct mmt_nvidia_bind *bnd, void *state);

0 comments on commit 615f509

Please sign in to comment.