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 <alyssa.rosenzweig@collabora.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user