summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-08-19 10:55:29 -0700
committerAlyssa Rosenzweig <[email protected]>2019-08-21 08:40:52 -0700
commitb072d0357be060ceb67f0d565ad5e24c57be328f (patch)
tree4a2ebf26e099dcc86ae6d0875578b0179ec63040 /src
parent52101e48f8851433d2c72b39d82ece793f8cfa1f (diff)
pan/decode: Allow updating mmaps
This allows the caller to call track_mmap multiple times for the same gpu_va for the purpose of updating the mmap. This is used to trace invisible BOs with kbase and doesn't apply to native traces. Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/panfrost/pandecode/common.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/panfrost/pandecode/common.c b/src/panfrost/pandecode/common.c
index 0678e459066..86cb01938e2 100644
--- a/src/panfrost/pandecode/common.c
+++ b/src/panfrost/pandecode/common.c
@@ -47,9 +47,39 @@ pandecode_find_mapped_gpu_mem_containing(uint64_t addr)
return NULL;
}
+static void
+pandecode_add_name(struct pandecode_mapped_memory *mem, uint64_t gpu_va, const char *name)
+{
+ if (!name) {
+ /* If we don't have a name, assign one */
+
+ snprintf(mem->name, ARRAY_SIZE(mem->name) - 1,
+ "memory_%" PRIx64, gpu_va);
+ } else {
+ assert((strlen(name) + 1) < ARRAY_SIZE(mem->name));
+ memcpy(mem->name, name, strlen(name) + 1);
+ }
+}
+
void
pandecode_inject_mmap(uint64_t gpu_va, void *cpu, unsigned sz, const char *name)
{
+ /* First, search if we already mapped this and are just updating an address */
+
+ list_for_each_entry(struct pandecode_mapped_memory, pos, &mmaps.node, node) {
+ if (pos->gpu_va == gpu_va) {
+ /* TODO: Resizing weirdness. Only applies to tracing
+ * the legacy driver, not for native traces */
+
+ pos->length = sz;
+ pos->addr = cpu;
+ pandecode_add_name(pos, gpu_va, name);
+
+ return;
+ }
+ }
+
+ /* Otherwise, add a fresh mapping */
struct pandecode_mapped_memory *mapped_mem = NULL;
mapped_mem = malloc(sizeof(*mapped_mem));
@@ -58,16 +88,7 @@ pandecode_inject_mmap(uint64_t gpu_va, void *cpu, unsigned sz, const char *name)
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) + 1) < ARRAY_SIZE(mapped_mem->name));
- memcpy(mapped_mem->name, name, strlen(name) + 1);
- }
+ pandecode_add_name(mapped_mem, gpu_va, name);
list_add(&mapped_mem->node, &mmaps.node);
}