summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorScott D Phillips <[email protected]>2018-04-06 11:02:55 -0700
committerLionel Landwerlin <[email protected]>2018-07-05 11:57:45 +0100
commit3ebee627cb8744d6c9087255ddb0341772ca1483 (patch)
tree8496ea02e0824a35d35641c83b3ad06f634cda71 /src
parent3228335b55c300cd07c4aa69329e58e70afae6a8 (diff)
intel/tools/aubinator: aubinate ppgtt aubs
v2: by Lionel Fix memfd_create compilation issue Fix pml4 address stored on 32 instead of 64bits Return no buffer if first ppgtt page is not mapped v3: Drop additional memfd_create() (Rafael) Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Rafael Antognolli <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/intel/tools/aubinator.c73
1 files changed, 72 insertions, 1 deletions
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 05083dbcda0..8989d558b66 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -327,6 +327,68 @@ get_ggtt_batch_bo(void *user_data, uint64_t address)
return bo;
}
+
+static struct phys_mem *
+ppgtt_walk(uint64_t pml4, uint64_t address)
+{
+ uint64_t shift = 39;
+ uint64_t addr = pml4;
+ for (int level = 4; level > 0; level--) {
+ struct phys_mem *table = search_phys_mem(addr);
+ if (!table)
+ return NULL;
+ int index = (address >> shift) & 0x1ff;
+ uint64_t entry = ((uint64_t *)table->data)[index];
+ if (!(entry & 1))
+ return NULL;
+ addr = entry & ~0xfff;
+ shift -= 9;
+ }
+ return search_phys_mem(addr);
+}
+
+static bool
+ppgtt_mapped(uint64_t pml4, uint64_t address)
+{
+ return ppgtt_walk(pml4, address) != NULL;
+}
+
+static struct gen_batch_decode_bo
+get_ppgtt_batch_bo(void *user_data, uint64_t address)
+{
+ struct gen_batch_decode_bo bo = {0};
+ uint64_t pml4 = *(uint64_t *)user_data;
+
+ address &= ~0xfff;
+
+ if (!ppgtt_mapped(pml4, address))
+ return bo;
+
+ /* Map everything until the first gap since we don't know how much the
+ * decoder actually needs.
+ */
+ uint64_t end = address;
+ while (ppgtt_mapped(pml4, end))
+ end += 4096;
+
+ bo.addr = address;
+ bo.size = end - address;
+ bo.map = mmap(NULL, bo.size, PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ assert(bo.map != MAP_FAILED);
+
+ for (uint64_t page = address; page < end; page += 4096) {
+ struct phys_mem *phys_mem = ppgtt_walk(pml4, page);
+
+ void *res = mmap((uint8_t *)bo.map + (page - bo.addr), 4096, PROT_READ,
+ MAP_SHARED | MAP_FIXED, mem_fd, phys_mem->fd_offset);
+ assert(res != MAP_FAILED);
+ }
+
+ add_gtt_bo_map(bo, true);
+
+ return bo;
+}
+
#define GEN_ENGINE_RENDER 1
#define GEN_ENGINE_BLITTER 2
@@ -368,6 +430,7 @@ handle_trace_block(uint32_t *p)
}
(void)engine; /* TODO */
+ batch_ctx.get_bo = get_ggtt_batch_bo;
gen_print_batch(&batch_ctx, bo.map, bo.size, 0);
clear_bo_maps();
@@ -393,7 +456,7 @@ aubinator_init(uint16_t aub_pci_id, const char *app_name)
batch_flags |= GEN_BATCH_DECODE_FLOATS;
gen_batch_decode_ctx_init(&batch_ctx, &devinfo, outfile, batch_flags,
- xml_path, get_ggtt_batch_bo, NULL, NULL);
+ xml_path, NULL, NULL, NULL);
batch_ctx.max_vbo_decoded_lines = max_vbo_lines;
char *color = GREEN_HEADER, *reset_color = NORMAL;
@@ -533,12 +596,20 @@ handle_memtrace_reg_write(uint32_t *p)
uint32_t ring_buffer_head = context[5];
uint32_t ring_buffer_tail = context[7];
uint32_t ring_buffer_start = context[9];
+ uint64_t pml4 = (uint64_t)context[49] << 32 | context[51];
struct gen_batch_decode_bo ring_bo = get_ggtt_batch_bo(NULL,
ring_buffer_start);
assert(ring_bo.size > 0);
void *commands = (uint8_t *)ring_bo.map + (ring_bo.addr - ring_buffer_start);
+ if (context_descriptor & 0x100 /* ppgtt */) {
+ batch_ctx.get_bo = get_ppgtt_batch_bo;
+ batch_ctx.user_data = &pml4;
+ } else {
+ batch_ctx.get_bo = get_ggtt_batch_bo;
+ }
+
(void)engine; /* TODO */
gen_print_batch(&batch_ctx, commands, ring_buffer_tail - ring_buffer_head,
0);