summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost/pandecode
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/panfrost/pandecode')
-rw-r--r--src/gallium/drivers/panfrost/pandecode/cmdline.c64
-rw-r--r--src/gallium/drivers/panfrost/pandecode/common.c102
-rw-r--r--src/gallium/drivers/panfrost/pandecode/decode.c2
-rw-r--r--src/gallium/drivers/panfrost/pandecode/decode.h (renamed from src/gallium/drivers/panfrost/pandecode/mmap.h)12
4 files changed, 118 insertions, 62 deletions
diff --git a/src/gallium/drivers/panfrost/pandecode/cmdline.c b/src/gallium/drivers/panfrost/pandecode/cmdline.c
index 87e6defcb56..38053aa1072 100644
--- a/src/gallium/drivers/panfrost/pandecode/cmdline.c
+++ b/src/gallium/drivers/panfrost/pandecode/cmdline.c
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2019 Alyssa Rosenzweig
- * Copyright (C) 2017-2018 Lyude Paul
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -28,45 +27,7 @@
#include <stdint.h>
#include <string.h>
-#include "mmap.h"
-int pandecode_replay_jc(mali_ptr jc_gpu_va, bool bifrost);
-
-/* Memory handling */
-
-static struct pandecode_mapped_memory mmaps;
-
-struct pandecode_mapped_memory *
-pandecode_find_mapped_gpu_mem_containing(mali_ptr addr)
-{
- list_for_each_entry(struct pandecode_mapped_memory, pos, &mmaps.node, node) {
- if (addr >= pos->gpu_va && addr < pos->gpu_va + pos->length)
- return pos;
- }
-
- return NULL;
-}
-
-char *
-pointer_as_memory_reference(mali_ptr ptr)
-{
- struct pandecode_mapped_memory *mapped;
- char *out = malloc(128);
-
- /* Try to find the corresponding mapped zone */
-
- mapped = pandecode_find_mapped_gpu_mem_containing(ptr);
-
- if (mapped) {
- snprintf(out, 128, "%s + %d", mapped->name, (int) (ptr - mapped->gpu_va));
- return out;
- }
-
- /* Just use the raw address if other options are exhausted */
-
- snprintf(out, 128, MALI_PTR_FMT, ptr);
- return out;
-
-}
+#include "decode.h"
/* Parsing */
@@ -101,21 +62,7 @@ pandecode_read_memory(const char *base, const char *name, mali_ptr gpu_va)
fread(buf, 1, sz, fp);
fclose(fp);
- /* Now that we have the memory loaded in, create a mmap entry for it so
- * we remember it later */
-
- struct pandecode_mapped_memory *mapped_mem = NULL;
-
- mapped_mem = malloc(sizeof(*mapped_mem));
- list_inithead(&mapped_mem->node);
-
- mapped_mem->gpu_va = gpu_va;
- mapped_mem->length = sz;
- mapped_mem->addr = buf;
-
- memcpy(mapped_mem->name, name, strlen(name));
-
- list_add(&mapped_mem->node, &mmaps.node);
+ pandecode_inject_mmap(gpu_va, buf, sz, name);
}
static void
@@ -141,6 +88,8 @@ pandecode_read_job_submit(const char *base, const char *line)
pandecode_replay_jc(addr, is_bifrost);
}
+
+
/* Reads the control file, processing as it goes. */
static void
@@ -180,10 +129,7 @@ main(int argc, char **argv)
fprintf(stderr, "Usage: pandecode [directory]\n");
exit(1);
}
-
- /* Initialize */
- list_inithead(&mmaps.node);
- /* Let's go! */
+ pandecode_initialize();
pandecode_read_control(argv[1]);
}
diff --git a/src/gallium/drivers/panfrost/pandecode/common.c b/src/gallium/drivers/panfrost/pandecode/common.c
new file mode 100644
index 00000000000..dfbf77109ac
--- /dev/null
+++ b/src/gallium/drivers/panfrost/pandecode/common.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2019 Alyssa Rosenzweig
+ * Copyright (C) 2017-2018 Lyude Paul
+ * Copyright (C) 2019 Collabora
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "decode.h"
+#include "util/macros.h"
+
+/* Memory handling */
+
+static struct pandecode_mapped_memory mmaps;
+
+struct pandecode_mapped_memory *
+pandecode_find_mapped_gpu_mem_containing(mali_ptr addr)
+{
+ list_for_each_entry(struct pandecode_mapped_memory, pos, &mmaps.node, node) {
+ if (addr >= pos->gpu_va && addr < pos->gpu_va + pos->length)
+ return pos;
+ }
+
+ return NULL;
+}
+
+void
+pandecode_inject_mmap(mali_ptr gpu_va, void *cpu, unsigned sz, const char *name)
+{
+ struct pandecode_mapped_memory *mapped_mem = NULL;
+
+ mapped_mem = malloc(sizeof(*mapped_mem));
+ list_inithead(&mapped_mem->node);
+
+ mapped_mem->gpu_va = gpu_va;
+ mapped_mem->length = sz;
+ mapped_mem->addr = cpu;
+
+ if (!name) {
+ /* If we don't have a name, assign one */
+
+ snprintf(mapped_mem->name, ARRAY_SIZE(mapped_mem->name) - 1,
+ "memory_%" PRIx64, gpu_va);
+ } else {
+ assert(strlen(name) < ARRAY_SIZE(mapped_mem->name));
+ memcpy(mapped_mem->name, name, strlen(name));
+ }
+
+ list_add(&mapped_mem->node, &mmaps.node);
+}
+
+char *
+pointer_as_memory_reference(mali_ptr ptr)
+{
+ struct pandecode_mapped_memory *mapped;
+ char *out = malloc(128);
+
+ /* Try to find the corresponding mapped zone */
+
+ mapped = pandecode_find_mapped_gpu_mem_containing(ptr);
+
+ if (mapped) {
+ snprintf(out, 128, "%s + %d", mapped->name, (int) (ptr - mapped->gpu_va));
+ return out;
+ }
+
+ /* Just use the raw address if other options are exhausted */
+
+ snprintf(out, 128, MALI_PTR_FMT, ptr);
+ return out;
+
+}
+
+void
+pandecode_initialize(void)
+{
+ list_inithead(&mmaps.node);
+
+}
diff --git a/src/gallium/drivers/panfrost/pandecode/decode.c b/src/gallium/drivers/panfrost/pandecode/decode.c
index 00678a4c5ed..5544f6b72ec 100644
--- a/src/gallium/drivers/panfrost/pandecode/decode.c
+++ b/src/gallium/drivers/panfrost/pandecode/decode.c
@@ -28,7 +28,7 @@
#include <memory.h>
#include <stdbool.h>
#include <stdarg.h>
-#include "mmap.h"
+#include "decode.h"
#include "util/u_math.h"
#include "../pan_pretty_print.h"
diff --git a/src/gallium/drivers/panfrost/pandecode/mmap.h b/src/gallium/drivers/panfrost/pandecode/decode.h
index e9acae877f7..2a78fee1d40 100644
--- a/src/gallium/drivers/panfrost/pandecode/mmap.h
+++ b/src/gallium/drivers/panfrost/pandecode/decode.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef __MMAP_TRACE_H__
-#define __MMAP_TRACE_H__
+#ifndef __PAN_DECODE_H__
+#define __PAN_DECODE_H__
#include <stdlib.h>
#include <stddef.h>
@@ -42,10 +42,15 @@ struct pandecode_mapped_memory {
char name[32];
};
+void pandecode_initialize(void);
+
char *pointer_as_memory_reference(mali_ptr ptr);
struct pandecode_mapped_memory *pandecode_find_mapped_gpu_mem_containing(mali_ptr addr);
+void
+pandecode_inject_mmap(mali_ptr gpu_va, void *cpu, unsigned sz, const char *name);
+
static inline void *
__pandecode_fetch_gpu_mem(const struct pandecode_mapped_memory *mem,
mali_ptr gpu_va, size_t size,
@@ -75,4 +80,7 @@ __pandecode_fetch_gpu_mem(const struct pandecode_mapped_memory *mem,
name = __pandecode_fetch_gpu_mem(mem, gpu_va, sizeof(*name), \
__LINE__, __FILE__)
+/* Common entrypoint */
+int pandecode_replay_jc(mali_ptr jc_gpu_va, bool bifrost);
+
#endif /* __MMAP_TRACE_H__ */