aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2018-08-27 00:19:29 +0100
committerLionel Landwerlin <[email protected]>2019-03-07 15:08:31 +0000
commit69ee5bde4e3ce8c88e16bb16e0bccf440cf516ac (patch)
treedaa536ad6ac14a9f0abf26046824f1322e70a914 /src
parent01443f34b4133e23b04718a0a26f317d658de760 (diff)
intel/aub_write: write header in init
Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Rafael Antognolli <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/intel/tools/aub_write.c152
-rw-r--r--src/intel/tools/aub_write.h3
-rw-r--r--src/intel/tools/error2aub.c4
-rw-r--r--src/intel/tools/intel_dump_gpu.c7
4 files changed, 84 insertions, 82 deletions
diff --git a/src/intel/tools/aub_write.c b/src/intel/tools/aub_write.c
index fa5c302bf70..2c121d91b53 100644
--- a/src/intel/tools/aub_write.c
+++ b/src/intel/tools/aub_write.c
@@ -114,11 +114,86 @@ aub_ppgtt_table_finish(struct aub_ppgtt_table *table, int level)
}
}
+
+static void
+data_out(struct aub_file *aub, const void *data, size_t size)
+{
+ if (size == 0)
+ return;
+
+ fail_if(fwrite(data, 1, size, aub->file) == 0,
+ "Writing to output failed\n");
+}
+
+static void
+dword_out(struct aub_file *aub, uint32_t data)
+{
+ data_out(aub, &data, sizeof(data));
+}
+
+static void
+write_execlists_header(struct aub_file *aub, const char *name)
+{
+ char app_name[8 * 4];
+ int app_name_len, dwords;
+
+ app_name_len =
+ snprintf(app_name, sizeof(app_name), "PCI-ID=0x%X %s",
+ aub->pci_id, name);
+ app_name_len = ALIGN(app_name_len, sizeof(uint32_t));
+
+ dwords = 5 + app_name_len / sizeof(uint32_t);
+ dword_out(aub, CMD_MEM_TRACE_VERSION | (dwords - 1));
+ dword_out(aub, AUB_MEM_TRACE_VERSION_FILE_VERSION);
+ dword_out(aub, aub->devinfo.simulator_id << AUB_MEM_TRACE_VERSION_DEVICE_SHIFT);
+ dword_out(aub, 0); /* version */
+ dword_out(aub, 0); /* version */
+ data_out(aub, app_name, app_name_len);
+}
+
+static void
+write_legacy_header(struct aub_file *aub, const char *name)
+{
+ char app_name[8 * 4];
+ char comment[16];
+ int comment_len, comment_dwords, dwords;
+
+ comment_len = snprintf(comment, sizeof(comment), "PCI-ID=0x%x", aub->pci_id);
+ comment_dwords = ((comment_len + 3) / 4);
+
+ /* Start with a (required) version packet. */
+ dwords = 13 + comment_dwords;
+ dword_out(aub, CMD_AUB_HEADER | (dwords - 2));
+ dword_out(aub, (4 << AUB_HEADER_MAJOR_SHIFT) |
+ (0 << AUB_HEADER_MINOR_SHIFT));
+
+ /* Next comes a 32-byte application name. */
+ strncpy(app_name, name, sizeof(app_name));
+ app_name[sizeof(app_name) - 1] = 0;
+ data_out(aub, app_name, sizeof(app_name));
+
+ dword_out(aub, 0); /* timestamp */
+ dword_out(aub, 0); /* timestamp */
+ dword_out(aub, comment_len);
+ data_out(aub, comment, comment_dwords * 4);
+}
+
+
+static void
+aub_write_header(struct aub_file *aub, const char *app_name)
+{
+ if (aub_use_execlists(aub))
+ write_execlists_header(aub, app_name);
+ else
+ write_legacy_header(aub, app_name);
+}
+
void
-aub_file_init(struct aub_file *aub, FILE *file, uint16_t pci_id)
+aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, const char *app_name)
{
memset(aub, 0, sizeof(*aub));
+ aub->verbose_log_file = debug;
aub->file = file;
aub->pci_id = pci_id;
fail_if(!gen_get_device_info(pci_id, &aub->devinfo),
@@ -126,6 +201,8 @@ aub_file_init(struct aub_file *aub, FILE *file, uint16_t pci_id)
aub->addr_bits = aub->devinfo.gen >= 8 ? 48 : 32;
aub->pml4.phys_addr = PML4_PHYS_ADDR;
+
+ aub_write_header(aub, app_name);
}
void
@@ -142,22 +219,6 @@ aub_gtt_size(struct aub_file *aub)
}
static void
-data_out(struct aub_file *aub, const void *data, size_t size)
-{
- if (size == 0)
- return;
-
- fail_if(fwrite(data, 1, size, aub->file) == 0,
- "Writing to output failed\n");
-}
-
-static void
-dword_out(struct aub_file *aub, uint32_t data)
-{
- data_out(aub, &data, sizeof(data));
-}
-
-static void
mem_trace_memory_write_header_out(struct aub_file *aub, uint64_t addr,
uint32_t len, uint32_t addr_space,
const char *desc)
@@ -307,63 +368,6 @@ ppgtt_lookup(struct aub_file *aub, uint64_t ppgtt_addr)
}
static void
-write_execlists_header(struct aub_file *aub, const char *name)
-{
- char app_name[8 * 4];
- int app_name_len, dwords;
-
- app_name_len =
- snprintf(app_name, sizeof(app_name), "PCI-ID=0x%X %s",
- aub->pci_id, name);
- app_name_len = ALIGN(app_name_len, sizeof(uint32_t));
-
- dwords = 5 + app_name_len / sizeof(uint32_t);
- dword_out(aub, CMD_MEM_TRACE_VERSION | (dwords - 1));
- dword_out(aub, AUB_MEM_TRACE_VERSION_FILE_VERSION);
- dword_out(aub, aub->devinfo.simulator_id << AUB_MEM_TRACE_VERSION_DEVICE_SHIFT);
- dword_out(aub, 0); /* version */
- dword_out(aub, 0); /* version */
- data_out(aub, app_name, app_name_len);
-}
-
-static void
-write_legacy_header(struct aub_file *aub, const char *name)
-{
- char app_name[8 * 4];
- char comment[16];
- int comment_len, comment_dwords, dwords;
-
- comment_len = snprintf(comment, sizeof(comment), "PCI-ID=0x%x", aub->pci_id);
- comment_dwords = ((comment_len + 3) / 4);
-
- /* Start with a (required) version packet. */
- dwords = 13 + comment_dwords;
- dword_out(aub, CMD_AUB_HEADER | (dwords - 2));
- dword_out(aub, (4 << AUB_HEADER_MAJOR_SHIFT) |
- (0 << AUB_HEADER_MINOR_SHIFT));
-
- /* Next comes a 32-byte application name. */
- strncpy(app_name, name, sizeof(app_name));
- app_name[sizeof(app_name) - 1] = 0;
- data_out(aub, app_name, sizeof(app_name));
-
- dword_out(aub, 0); /* timestamp */
- dword_out(aub, 0); /* timestamp */
- dword_out(aub, comment_len);
- data_out(aub, comment, comment_dwords * 4);
-}
-
-
-void
-aub_write_header(struct aub_file *aub, const char *app_name)
-{
- if (aub_use_execlists(aub))
- write_execlists_header(aub, app_name);
- else
- write_legacy_header(aub, app_name);
-}
-
-static void
write_execlists_default_setup(struct aub_file *aub)
{
/* GGTT PT */
diff --git a/src/intel/tools/aub_write.h b/src/intel/tools/aub_write.h
index 53bd14c75a0..2597234c1c7 100644
--- a/src/intel/tools/aub_write.h
+++ b/src/intel/tools/aub_write.h
@@ -54,7 +54,7 @@ struct aub_file {
struct aub_ppgtt_table pml4;
};
-void aub_file_init(struct aub_file *aub, FILE *file, uint16_t pci_id);
+void aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, const char *app_name);
void aub_file_finish(struct aub_file *aub);
static inline bool aub_use_execlists(const struct aub_file *aub)
@@ -74,7 +74,6 @@ aub_write_reloc(const struct gen_device_info *devinfo, void *p, uint64_t v)
}
}
-void aub_write_header(struct aub_file *aub, const char *app_name);
void aub_write_default_setup(struct aub_file *aub);
void aub_map_ppgtt(struct aub_file *aub, uint64_t start, uint64_t size);
void aub_write_trace_block(struct aub_file *aub,
diff --git a/src/intel/tools/error2aub.c b/src/intel/tools/error2aub.c
index e0eca2778e7..fff36085fef 100644
--- a/src/intel/tools/error2aub.c
+++ b/src/intel/tools/error2aub.c
@@ -218,11 +218,11 @@ main(int argc, char *argv[])
int matched = sscanf(line, "PCI ID: 0x%04x\n", &pci_id);
fail_if(!matched, "Invalid error state file!\n");
- aub_file_init(&aub, aub_file, pci_id);
+ aub_file_init(&aub, aub_file,
+ NULL, pci_id, "error_state");
fail_if(!aub_use_execlists(&aub),
"%s currently only works on gen8+\n", argv[0]);
- aub_write_header(&aub, "error state");
aub_write_default_setup(&aub);
continue;
}
diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c
index 937b4f568a0..3dd1ff68999 100644
--- a/src/intel/tools/intel_dump_gpu.c
+++ b/src/intel/tools/intel_dump_gpu.c
@@ -208,10 +208,9 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
fail_if(!gen_get_device_info(device, &devinfo),
"failed to identify chipset=0x%x\n", device);
- aub_file_init(&aub_file, output_file, device);
- if (verbose == 2)
- aub_file.verbose_log_file = stdout;
- aub_write_header(&aub_file, program_invocation_short_name);
+ aub_file_init(&aub_file, output_file,
+ verbose == 2 ? stdout : NULL,
+ device, program_invocation_short_name);
aub_write_default_setup(&aub_file);
if (verbose)