[Mesa-dev] [PATCH 02/20] intel/aub_write: split comment section from HW setup
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Tue Sep 25 08:23:41 UTC 2018
In the future we'll want error2aub to reuse the context image saved by
i915 instead of the default one we write in intel_dump_gpu.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/tools/aub_write.c | 75 +++++++++++++++++++++-----------
src/intel/tools/aub_write.h | 1 +
src/intel/tools/error2aub.c | 1 +
src/intel/tools/intel_dump_gpu.c | 1 +
4 files changed, 52 insertions(+), 26 deletions(-)
diff --git a/src/intel/tools/aub_write.c b/src/intel/tools/aub_write.c
index 5d59b4ef28a..69ce284e3d3 100644
--- a/src/intel/tools/aub_write.c
+++ b/src/intel/tools/aub_write.c
@@ -324,7 +324,48 @@ write_execlists_header(struct aub_file *aub, const char *name)
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 */
uint32_t ggtt_ptes = STATIC_GGTT_MAP_SIZE >> 12;
@@ -403,32 +444,10 @@ write_execlists_header(struct aub_file *aub, const char *name)
register_write_out(aub, GFX_MODE_BCSUNIT, 0x80008000 /* execlist enable */);
}
-static void write_legacy_header(struct aub_file *aub, const char *name)
+static void write_legacy_default_setup(struct aub_file *aub)
{
- char app_name[8 * 4];
- char comment[16];
- int comment_len, comment_dwords, dwords;
uint32_t entry = 0x200003;
- 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);
-
/* Set up the GTT. The max we can handle is 64M */
dword_out(aub, CMD_AUB_TRACE_HEADER_BLOCK |
((aub->addr_bits > 32 ? 6 : 5) - 2));
@@ -446,13 +465,17 @@ static void write_legacy_header(struct aub_file *aub, const char *name)
}
}
+/**
+ * Sets up a default GGTT/PPGTT address space and execlists context (when
+ * supported).
+ */
void
-aub_write_header(struct aub_file *aub, const char *app_name)
+aub_write_default_setup(struct aub_file *aub)
{
if (aub_use_execlists(aub))
- write_execlists_header(aub, app_name);
+ write_execlists_default_setup(aub);
else
- write_legacy_header(aub, app_name);
+ write_legacy_default_setup(aub);
}
/**
diff --git a/src/intel/tools/aub_write.h b/src/intel/tools/aub_write.h
index 6a09c1747b9..53bd14c75a0 100644
--- a/src/intel/tools/aub_write.h
+++ b/src/intel/tools/aub_write.h
@@ -75,6 +75,7 @@ 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,
uint32_t type, void *virtual,
diff --git a/src/intel/tools/error2aub.c b/src/intel/tools/error2aub.c
index 8a23d5ef1e7..5af98ff5034 100644
--- a/src/intel/tools/error2aub.c
+++ b/src/intel/tools/error2aub.c
@@ -222,6 +222,7 @@ main(int argc, char *argv[])
"%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 a71103f1889..af12ee6ef8e 100644
--- a/src/intel/tools/intel_dump_gpu.c
+++ b/src/intel/tools/intel_dump_gpu.c
@@ -210,6 +210,7 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
if (verbose == 2)
aub_file.verbose_log_file = stdout;
aub_write_header(&aub_file, program_invocation_short_name);
+ aub_write_default_setup(&aub_file);
if (verbose)
printf("[running, output file %s, chipset id 0x%04x, gen %d]\n",
--
2.19.0
More information about the mesa-dev
mailing list