[Mesa-dev] [PATCH 11/14] intel: tools: aubmem: map gtt data to aub file

Lionel Landwerlin lionel.g.landwerlin at intel.com
Thu Aug 2 09:39:23 UTC 2018


This will allow the aubinator viewer tool to modify the aub data that
was loaded at a particular gtt address.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/tools/aub_mem.c | 29 +++++++++++++++++++++++++++++
 src/intel/tools/aub_mem.h |  6 ++++++
 2 files changed, 35 insertions(+)

diff --git a/src/intel/tools/aub_mem.c b/src/intel/tools/aub_mem.c
index 788a2461130..2d29386e57c 100644
--- a/src/intel/tools/aub_mem.c
+++ b/src/intel/tools/aub_mem.c
@@ -55,6 +55,7 @@ struct phys_mem {
    uint64_t fd_offset;
    uint64_t phys_addr;
    uint8_t *data;
+   const uint8_t *aub_data;
 };
 
 static void
@@ -220,6 +221,7 @@ aub_mem_phys_write(void *_mem, uint64_t phys_address,
       uint32_t size_this_page = MIN2(to_write, 4096 - offset);
       to_write -= size_this_page;
       memcpy(pmem->data + offset, data, size_this_page);
+      pmem->aub_data = data - offset;
       data = (const uint8_t *)data + size_this_page;
    }
 }
@@ -389,3 +391,30 @@ aub_mem_fini(struct aub_mem *mem)
    close(mem->mem_fd);
    mem->mem_fd = -1;
 }
+
+struct gen_batch_decode_bo
+aub_mem_get_phys_addr_data(struct aub_mem *mem, uint64_t phys_addr)
+{
+   struct phys_mem *page = search_phys_mem(mem, phys_addr);
+   return page ?
+      (struct gen_batch_decode_bo) { .map = page->data, .addr = page->phys_addr, .size = 4096 } :
+      (struct gen_batch_decode_bo) {};
+}
+
+struct gen_batch_decode_bo
+aub_mem_get_ppgtt_addr_data(struct aub_mem *mem, uint64_t virt_addr)
+{
+   struct phys_mem *page = ppgtt_walk(mem, mem->pml4, virt_addr);
+   return page ?
+      (struct gen_batch_decode_bo) { .map = page->data, .addr = virt_addr & ~((1ULL << 12) - 1), .size = 4096 } :
+      (struct gen_batch_decode_bo) {};
+}
+
+struct gen_batch_decode_bo
+aub_mem_get_ppgtt_addr_aub_data(struct aub_mem *mem, uint64_t virt_addr)
+{
+   struct phys_mem *page = ppgtt_walk(mem, mem->pml4, virt_addr);
+   return page ?
+      (struct gen_batch_decode_bo) { .map = page->aub_data, .addr = virt_addr & ~((1ULL << 12) - 1), .size = 4096 } :
+      (struct gen_batch_decode_bo) {};
+}
diff --git a/src/intel/tools/aub_mem.h b/src/intel/tools/aub_mem.h
index 98e64214b98..1d73d3340f2 100644
--- a/src/intel/tools/aub_mem.h
+++ b/src/intel/tools/aub_mem.h
@@ -65,6 +65,12 @@ void aub_mem_local_write(void *mem, uint64_t virt_address,
 struct gen_batch_decode_bo aub_mem_get_ggtt_bo(void *mem, uint64_t address);
 struct gen_batch_decode_bo aub_mem_get_ppgtt_bo(void *mem, uint64_t address);
 
+struct gen_batch_decode_bo aub_mem_get_phys_addr_data(struct aub_mem *mem, uint64_t phys_addr);
+struct gen_batch_decode_bo aub_mem_get_ppgtt_addr_data(struct aub_mem *mem, uint64_t virt_addr);
+
+struct gen_batch_decode_bo aub_mem_get_ppgtt_addr_aub_data(struct aub_mem *mem, uint64_t virt_addr);
+
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.18.0



More information about the mesa-dev mailing list