From: Alyssa Rosenzweig Date: Mon, 19 Aug 2019 17:55:29 +0000 (-0700) Subject: pan/decode: Allow updating mmaps X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b072d0357be060ceb67f0d565ad5e24c57be328f;p=mesa.git 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 --- 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); }