intel/aub_write: split comment section from HW setup
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 23 Aug 2018 19:36:16 +0000 (20:36 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 7 Mar 2019 15:08:31 +0000 (15:08 +0000)
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@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/intel/tools/aub_write.c
src/intel/tools/aub_write.h
src/intel/tools/error2aub.c
src/intel/tools/intel_dump_gpu.c

index 99b5e0a7b9f77fb56cdb3ae573a743568cd80267..fa5c302bf70fc2c23ed554bde9cce6a41dd9f249 100644 (file)
@@ -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);
 }
 
 /**
index 6a09c1747b9f352d86782872970c9d54cc12a4e0..53bd14c75a05a6257d472242e76c4b0bb43a7d8a 100644 (file)
@@ -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,
index ca01038384776abc4b021fc18abf89315111fd0f..e0eca2778e7c2bcecb9edc6f27485978eeffd352 100644 (file)
@@ -223,6 +223,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;
       }
 
index ea541bb21fe0267ea735008f6df8bff957b0ebcc..937b4f568a0e309a4f407c301c3b00cb2737874f 100644 (file)
@@ -212,6 +212,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",