intel/tools/dump_gpu: Add option to print ppgtt mappings.
authorRafael Antognolli <rafael.antognolli@intel.com>
Tue, 3 Jul 2018 18:38:39 +0000 (11:38 -0700)
committerRafael Antognolli <rafael.antognolli@intel.com>
Tue, 10 Jul 2018 16:05:44 +0000 (09:05 -0700)
Using -vv will increase the verbosity, by printing the ppgtt mappings as
they get written into the aub file.

Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/tools/intel_dump_gpu.c
src/intel/tools/intel_dump_gpu.in

index c909d63d88f2bfd22ed219bf4dee2ff285a6d1bd..1201fa35ae0c8c10f7161aa39313bb83a1aef457 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/mman.h>
 #include <dlfcn.h>
 #include <i915_drm.h>
+#include <inttypes.h>
 
 #include "intel_aub.h"
 
@@ -389,6 +390,11 @@ populate_ppgtt_table(struct ppgtt_table *table, int start, int end,
    uint64_t entries[512] = {0};
    int dirty_start = 512, dirty_end = 0;
 
+   if (verbose == 2) {
+      printf("  PPGTT (0x%016" PRIx64 "), lvl %d, start: %x, end: %x\n",
+             table->phys_addr, level, start, end);
+   }
+
    for (int i = start; i <= end; i++) {
       if (!table->subtables[i]) {
          dirty_start = min(dirty_start, i);
@@ -396,11 +402,19 @@ populate_ppgtt_table(struct ppgtt_table *table, int start, int end,
          if (level == 1) {
             table->subtables[i] =
                (void *)(phys_addrs_allocator++ << 12);
+            if (verbose == 2) {
+               printf("   Adding entry: %x, phys_addr: 0x%016" PRIx64 "\n",
+                      i, (uint64_t)table->subtables[i]);
+            }
          } else {
             table->subtables[i] =
                calloc(1, sizeof(struct ppgtt_table));
             table->subtables[i]->phys_addr =
                phys_addrs_allocator++ << 12;
+            if (verbose == 2) {
+               printf("   Adding entry: %x, phys_addr: 0x%016" PRIx64 "\n",
+                      i, table->subtables[i]->phys_addr);
+            }
          }
       }
       entries[i] = 3 /* read/write | present */ |
@@ -434,6 +448,11 @@ map_ppgtt(uint64_t start, uint64_t size)
 #define L2_table(addr) (L3_table(addr)->subtables[L3_index(addr)])
 #define L1_table(addr) (L2_table(addr)->subtables[L2_index(addr)])
 
+   if (verbose == 2) {
+      printf(" Mapping PPGTT address: 0x%" PRIx64 ", size: %" PRIu64"\n",
+             start, size);
+   }
+
    populate_ppgtt_table(&pml4, L4_index(l4_start), L4_index(l4_end), 4);
 
    for (uint64_t l4 = l4_start; l4 < l4_end; l4 += (1ULL << 39)) {
@@ -1072,7 +1091,11 @@ maybe_init(void)
    config = fdopen(3, "r");
    while (fscanf(config, "%m[^=]=%m[^\n]\n", &key, &value) != EOF) {
       if (!strcmp(key, "verbose")) {
-         verbose = 1;
+         if (!strcmp(value, "1")) {
+            verbose = 1;
+         } else if (!strcmp(value, "2")) {
+            verbose = 2;
+         }
       } else if (!strcmp(key, "device")) {
          fail_if(sscanf(value, "%i", &device) != 1,
                  "intel_aubdump: failed to parse device id '%s'",
index 875a67e76822e96e7d0f3f7aae2be2a6550c079e..b9887f0ed2ef287f094cff1f832931c4fdbd2456 100755 (executable)
@@ -17,6 +17,8 @@ contents and execution of the GEM application.
 
   -v                 Enable verbose output
 
+  -vv                Enable extra verbosity - dumps gtt mappings
+
       --help         Display this help message and exit
 
 EOF
@@ -55,6 +57,10 @@ while true; do
             add_arg "verbose=1"
             shift 1
             ;;
+        -vv)
+            add_arg "verbose=2"
+            shift 1
+            ;;
         -o*)
             file=${1##-o}
             add_arg "file=${file:-$(basename ${file}).aub}"